{"action":"created","issue":{"url":"https://api.github.com/repos/aristath/kirki/issues/393","labels_url":"https://api.github.com/repos/aristath/kirki/issues/393/labels{/name}","comments_url":"https://api.github.com/repos/aristath/kirki/issues/393/comments","events_url":"https://api.github.com/repos/aristath/kirki/issues/393/events","html_url":"https://github.com/aristath/kirki/issues/393","id":108732935,"number":393,"title":"New Control: Preset","user":{"login":"aristath","id":588688,"avatar_url":"https://avatars.githubusercontent.com/u/588688?v=3","gravatar_id":"","url":"https://api.github.com/users/aristath","html_url":"https://github.com/aristath","followers_url":"https://api.github.com/users/aristath/followers","following_url":"https://api.github.com/users/aristath/following{/other_user}","gists_url":"https://api.github.com/users/aristath/gists{/gist_id}","starred_url":"https://api.github.com/users/aristath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aristath/subscriptions","organizations_url":"https://api.github.com/users/aristath/orgs","repos_url":"https://api.github.com/users/aristath/repos","events_url":"https://api.github.com/users/aristath/events{/privacy}","received_events_url":"https://api.github.com/users/aristath/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aristath/kirki/labels/enhancement","name":"enhancement","color":"009800"},{"url":"https://api.github.com/repos/aristath/kirki/labels/help%20wanted","name":"help wanted","color":"fbca04"},{"url":"https://api.github.com/repos/aristath/kirki/labels/priority:%20normal","name":"priority: normal","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/aristath/kirki/milestones/3","html_url":"https://github.com/aristath/kirki/milestones/1.1","labels_url":"https://api.github.com/repos/aristath/kirki/milestones/3/labels","id":1173510,"number":3,"title":"1.1","description":null,"creator":{"login":"aristath","id":588688,"avatar_url":"https://avatars.githubusercontent.com/u/588688?v=3","gravatar_id":"","url":"https://api.github.com/users/aristath","html_url":"https://github.com/aristath","followers_url":"https://api.github.com/users/aristath/followers","following_url":"https://api.github.com/users/aristath/following{/other_user}","gists_url":"https://api.github.com/users/aristath/gists{/gist_id}","starred_url":"https://api.github.com/users/aristath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aristath/subscriptions","organizations_url":"https://api.github.com/users/aristath/orgs","repos_url":"https://api.github.com/users/aristath/repos","events_url":"https://api.github.com/users/aristath/events{/privacy}","received_events_url":"https://api.github.com/users/aristath/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":42,"state":"open","created_at":"2015-06-20T15:35:55Z","updated_at":"2015-10-12T13:02:17Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-09-28T19:46:44Z","updated_at":"2015-10-12T14:13:56Z","closed_at":null,"body":"This has been requested for a long time and I always wanted to do it, so here it goes:\r\n\r\nWe now have a new \"preset\" control.\r\n\r\nThis is how to create a new preset control:\r\n\r\n```php\r\nKirki::add_field( 'kirki_demo', array(\r\n\t'type'        => 'preset',\r\n\t'settings'    => 'preset_demo',\r\n\t'label'       => __( 'Preset control', 'kirki-demo' ),\r\n\t'description' => __( 'Bulk-changes the value of other controls.', 'kirki-demo' ),\r\n\t'section'     => 'select',\r\n\t'default'     => '1',\r\n\t'priority'    => 10,\r\n\t'multiple'    => 3,\r\n\t'choices'     => array(\r\n\t\t'preset-1' => array(\r\n\t\t\t'label'    => __( 'Preset 1', 'kirki-demo' ),\r\n\t\t\t'settings' => array(\r\n\t\t\t\t'sub_field_1' => 'value',\r\n\t\t\t\t'sub_field_2' => 'value',\r\n\t\t\t\t'sub_field_3' => 'value',\r\n\t\t\t\t'sub_field_4' => 'value',\r\n\t\t\t\t'sub_field_5' => 'value',\r\n\t\t\t),\r\n\t\t),\r\n\t\t'preset-2' => array(\r\n\t\t\t'label'    => __( 'Preset 2', 'kirki-demo' ),\r\n\t\t\t'settings' => array(\r\n\t\t\t\t'sub_field_1' => 'value',\r\n\t\t\t\t'sub_field_2' => 'value',\r\n\t\t\t\t'sub_field_3' => 'value',\r\n\t\t\t\t'sub_field_4' => 'value',\r\n\t\t\t\t'sub_field_5' => 'value',\r\n\t\t\t),\r\n\t\t),\r\n\t),\r\n) );\r\n```\r\nThe `sub_field_1`, `sub_field_2` etc are the controls whose values we want to control, and in the array we can define the ID of the control and the value we want that control to take when the user selects this particular preset.\r\n\r\nWhen the user selects a preset the values of other controls are auto-updated and the preview is refreshed.\r\n\r\nThe only bug we currently have is this:\r\nValues are properly saved and if the user refreshes the page they can see the new values have changed in the controls themselves.\r\nIn order to make the values of the controls change automatically as we select different presets we have to write some scripts and take into account the structure of each control. \r\nSo far these controls have been fixed and we only have a few remaining:\r\n\r\n* [x] checkbox\r\n* [x] code\r\n* [x] color\r\n* [x] color-alpha\r\n* [x] dimension\r\n* [ ] editor\r\n* [x] multicheck\r\n* [x] number\r\n* [ ] palette\r\n* [x] radio\r\n* [x] radio-buttonset\r\n* [x] radio-image\r\n* [ ] repeater\r\n* [x] select\r\n* [x] slider\r\n* [ ] sortable\r\n* [ ] spacing\r\n* [x] switch\r\n* [x] textarea\r\n* [x] toggle\r\n* [ ] typography\r\n\r\nThe script is on `assets/js/controls/preset.js` in the [develop branch](https://github.com/aristath/kirki/tree/develop) so if anyone can assist we'll be able to finish this one faster."},"comment":{"url":"https://api.github.com/repos/aristath/kirki/issues/comments/147410148","html_url":"https://github.com/aristath/kirki/issues/393#issuecomment-147410148","issue_url":"https://api.github.com/repos/aristath/kirki/issues/393","id":147410148,"user":{"login":"Anydog","id":1732234,"avatar_url":"https://avatars.githubusercontent.com/u/1732234?v=3","gravatar_id":"","url":"https://api.github.com/users/Anydog","html_url":"https://github.com/Anydog","followers_url":"https://api.github.com/users/Anydog/followers","following_url":"https://api.github.com/users/Anydog/following{/other_user}","gists_url":"https://api.github.com/users/Anydog/gists{/gist_id}","starred_url":"https://api.github.com/users/Anydog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anydog/subscriptions","organizations_url":"https://api.github.com/users/Anydog/orgs","repos_url":"https://api.github.com/users/Anydog/repos","events_url":"https://api.github.com/users/Anydog/events{/privacy}","received_events_url":"https://api.github.com/users/Anydog/received_events","type":"User","site_admin":false},"created_at":"2015-10-12T14:13:56Z","updated_at":"2015-10-12T14:13:56Z","body":"Radio image is done, as far as I can see ( and I tested it ). Great !\r\nLittle, tiny advice (if you don't mind) - there are really a lot of field types now, which provide really a lot of control options. Perhaps stop adding fields / features (for the moment) and concentrate on polishing this great tool  ? ;)"}}