{"action":"closed","issue":{"url":"https://api.github.com/repos/Charitable/Charitable/issues/531","repository_url":"https://api.github.com/repos/Charitable/Charitable","labels_url":"https://api.github.com/repos/Charitable/Charitable/issues/531/labels{/name}","comments_url":"https://api.github.com/repos/Charitable/Charitable/issues/531/comments","events_url":"https://api.github.com/repos/Charitable/Charitable/issues/531/events","html_url":"https://github.com/Charitable/Charitable/issues/531","id":299917525,"number":531,"title":"Add single Campaign Settings meta box, powered by Campaign Fields API","user":{"login":"ericnicolaas","id":676582,"avatar_url":"https://avatars0.githubusercontent.com/u/676582?v=4","gravatar_id":"","url":"https://api.github.com/users/ericnicolaas","html_url":"https://github.com/ericnicolaas","followers_url":"https://api.github.com/users/ericnicolaas/followers","following_url":"https://api.github.com/users/ericnicolaas/following{/other_user}","gists_url":"https://api.github.com/users/ericnicolaas/gists{/gist_id}","starred_url":"https://api.github.com/users/ericnicolaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericnicolaas/subscriptions","organizations_url":"https://api.github.com/users/ericnicolaas/orgs","repos_url":"https://api.github.com/users/ericnicolaas/repos","events_url":"https://api.github.com/users/ericnicolaas/events{/privacy}","received_events_url":"https://api.github.com/users/ericnicolaas/received_events","type":"User","site_admin":false},"labels":[{"id":772818923,"url":"https://api.github.com/repos/Charitable/Charitable/labels/gutenberg","name":"gutenberg","color":"d979ea","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/Charitable/Charitable/milestones/18","html_url":"https://github.com/Charitable/Charitable/milestone/18","labels_url":"https://api.github.com/repos/Charitable/Charitable/milestones/18/labels","id":1948754,"number":18,"title":"1.6.0","description":"","creator":{"login":"ericnicolaas","id":676582,"avatar_url":"https://avatars0.githubusercontent.com/u/676582?v=4","gravatar_id":"","url":"https://api.github.com/users/ericnicolaas","html_url":"https://github.com/ericnicolaas","followers_url":"https://api.github.com/users/ericnicolaas/followers","following_url":"https://api.github.com/users/ericnicolaas/following{/other_user}","gists_url":"https://api.github.com/users/ericnicolaas/gists{/gist_id}","starred_url":"https://api.github.com/users/ericnicolaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericnicolaas/subscriptions","organizations_url":"https://api.github.com/users/ericnicolaas/orgs","repos_url":"https://api.github.com/users/ericnicolaas/repos","events_url":"https://api.github.com/users/ericnicolaas/events{/privacy}","received_events_url":"https://api.github.com/users/ericnicolaas/received_events","type":"User","site_admin":false},"open_issues":30,"closed_issues":5,"state":"open","created_at":"2016-08-18T05:03:40Z","updated_at":"2018-03-13T02:59:28Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2018-02-24T06:37:55Z","updated_at":"2018-03-13T02:59:28Z","closed_at":"2018-03-13T02:59:28Z","author_association":"CONTRIBUTOR","body":"At the moment, most of the campaign settings in the dashboard are located in here:\r\n\r\n![screenshot 2018-02-24 15 48 28](https://user-images.githubusercontent.com/676582/36626434-3bfe2406-197a-11e8-9df2-ed7f6d8ffe4a.png)\r\n\r\nThis is actually a collection of meta boxes, collapsed into one. Why did I do it this way? I'm not sure. 😕 \r\n\r\nTo define a new panel in that interface requires adding a new meta box to the `campaign-advanced` section (a custom area added by Charitable), and define a view for it. If, inside your view, you are also adding some kind of meta field related to campaigns, you also need to add that meta field to the set of fields to be saved. So just adding something new to the admin currently requires three things:\r\n\r\n- Add a new meta box via `charitable_campaign_meta_boxes`.\r\n- Create a view for this meta box.\r\n- Add any meta fields you need to save via `charitable_campaign_meta_keys`.\r\n\r\nI am proposing that we replace this with a single Campaign Settings meta box, which uses a structured way to modify and render the contents of each panel within the Campaign Settings meta box. This goes hand in hand with the Campaign Fields API (https://github.com/Charitable/Charitable/issues/530). \r\n\r\nWhen a campaign field is registered, it should be possible to have it automatically added to one of the existing panels in the Campaign Settings meta box. You don't need to define a view for the field; any field currently available as a field type (see `includes/admin/views/metaboxes/field-types`) will be rendered with that view. You also don't need to add the field to your keys to be saved; that happens automatically.\r\n\r\nHere's a quick idea of what this could look like from a field definition point of view:\r\n\r\n```\r\n// Define a new field.\r\n$field = new Charitable_Campaign_Field( 'select_field', array(\r\n    'label' => __( 'Select Field', 'charitable' ),\r\n    'ambassadors_form' => array( /* various args */ ),\r\n    'admin_form' => array(\r\n        'section' => __( 'Miscellaneous', 'charitable' ),\r\n        'required' => false,\r\n        'options' => array(\r\n            1 => 'Option 1',\r\n            2 => 'Option 2',\r\n        ),\r\n    ),\r\n    'show_in_export' => true,\r\n    'email_tag' => array(\r\n        'description' => __( 'The value of the Select Field' , 'charitable' ),\r\n    ) )\r\n) );\r\n\r\n// Register the field.\r\ncharitable()->campaign_fields()->register( $field );\r\n```\r\n\r\nThis would add a new field *Select Field* to the *Miscellaneous* panel. Stored values will be saved as `_campaign_select_field` to remain consistent with how we save campaign meta."}}
{"actor":{"display_login":"ericnicolaas"}}