/** * STEP 2: REGISTER YOUR SETTINGS… * * Register your settings here with MetaBox::register_setting(). Once registered, saving is handled for you and you * have access to functions that can automatically generate metaboxes and/or fields. * * Examples are provided below. The register_setting() method takes 3 arguments… * * $meta_key Required. String. The database key the data will be saved under & the id and name attributes for form elements. * $box_id Required. String. The id/slug of the meta box that this setting should be associated with. * $args Optional. Array. Additional customization of your setting as an associative array. Options include… * * 'label' The visible text to use for the form elements <label> * 'type' The type of form field to use with this setting. Valid values include: text, textarea, select, radio, checkbox, hidden * 'placeholder' Text to use as the form elements HTML5 placeholder attribute. * 'value' The default value or selection for the form element. * 'list' An associative array of items to include in radio, checkbox, and select elements, in 'value' => 'Display Text' format * 'howto' Help text to display beneath the form element. * 'save' Whether or not the setting should be automagically saved by the plugin. * 'serialize' Serialize the setting under this key instead of storing separately. * * Note: The order of registration controls the order of display. */ public static function register_settings() { // * * * * * * * * * * * * * * * * * * * * * * * // AUTOMAGIC META BOX // * * * * * * * * * * * * * * * * * * * * * * * MetaBox::register_setting('_nv_example_meta_field', 'magic-meta-box', array('label' => __('Example Field', 'nvLangScope'), 'placeholder' => __('Enter a value…', 'nvLangScope'))); MetaBox::register_setting('_nv_example_meta_checkboxes', 'magic-meta-box', array('type' => 'checkbox', 'label' => __('Example Checklist', 'nvLangScope'), 'list' => array('cb1' => __('Item 1', 'nvLangScope'), 'cb2' => __('Item 2', 'nvLangScope'), 'cb3' => __('Item 3', 'nvLangScope')))); MetaBox::register_setting('_nv_example_meta_radio', 'magic-meta-box', array('type' => 'radio', 'label' => __('Example Radio List', 'nvLangScope'), 'list' => array('radio1' => __('Item 1', 'nvLangScope'), 'radio2' => __('Item 2', 'nvLangScope'), 'radio3' => __('Item 3', 'nvLangScope')), 'value' => 'radio1')); MetaBox::register_setting('example_serialized_checkbox', 'magic-meta-box', array('type' => 'checkbox', 'label' => __('Example single checkbox', 'nvLangScope'), 'serialize' => '_nv_example_serialized')); MetaBox::register_setting('example_serialized_textarea', 'magic-meta-box', array('type' => 'textarea', 'label' => __('Example Textarea', 'nvLangScope'), 'placeholder' => __('Your text goes here!', 'nvLangScope'), 'howto' => __('You can add a paragraph of help text below any setting.', 'nvLangScope'), 'serialize' => '_nv_example_serialized')); // * * * * * * * * * * * * * * * * * * * * * * * // CUSTOM (HAND-CRAFTED) META BOX // * * * * * * * * * * * * * * * * * * * * * * * MetaBox::register_setting('_nv_example_meta_field2', 'custom-meta-box', array('label' => __('Example Field', 'nvLangScope'), 'placeholder' => __('Enter a value…', 'nvLangScope'))); MetaBox::register_setting('_nv_example_meta_dropdown', 'custom-meta-box', array('type' => 'select', 'label' => __('Example Dropdown', 'nvLangScope'), 'list' => array('' => __('-- Select One --', 'nvLangScope'), '1' => __('Option 1', 'nvLangScope'), '2' => __('Option 2', 'nvLangScope')))); }