Created
January 4, 2012 15:49
-
-
Save shawnsandy/1560633 to your computer and use it in GitHub Desktop.
meta-box
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /** | |
* ***************************************************************************** | |
* Add Metaboxes | |
* ***************************************************************************** | |
*/ | |
//add_action( 'add_meta_boxes', 'cwpt_custom_metaboxes' ); | |
function cwpt_custom_metaboxes(){ | |
add_meta_box('cwpt_preview', 'Site Preview', 'cwpt_preview_box', 'cwp_custom_options', 'normal', 'high'); | |
} | |
$cwpt_prefix = '_cwpt_'; // Prefix for all fields | |
function cwp_options_metaboxes($meta_boxes) { | |
global $cwpt_prefix; | |
$meta_boxes[] = array( | |
'id' => 'custom_options', | |
'title' => 'Custom Theme Options', | |
'pages' => array('cwp_custom_options'), // post type | |
'context' => 'normal', | |
'priority' => 'high', | |
'show_names' => true, // Show field names on the left | |
'fields' => array( | |
array( | |
'name' => 'Theme Home Page Custom Options', | |
'desc' => 'Copy / text / content / elements, used on the theme Home page', | |
'type' => 'title', | |
'id' => $cwpt_prefix . 'copy_title', | |
), | |
array( | |
'name' => 'Home Page Content / Copy', | |
'desc' => 'Appears as the theme main content', | |
'id' => $cwpt_prefix . 'main_copy', | |
'type' => 'wysiwyg', | |
'options' => array( | |
'wpautop' => true, // use wpautop? | |
'media_buttons' => true, // show insert/upload button(s) | |
//'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here | |
'textarea_rows' => get_option('default_post_edit_rows', 4), // rows="..." | |
'tabindex' => '', | |
'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped". | |
'editor_class' => '', // add extra class(es) to the editor textarea | |
'teeny' => true, // output the minimal editor config used in Press This | |
'dfw' => false, // replace the default fullscreen with DFW (needs specific css) | |
'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() | |
'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array() | |
), | |
), | |
array( | |
'name' => 'General Theme Custom Options', | |
'desc' => 'Copy / text / content used on the theme Home page', | |
'type' => 'title', | |
'id' => $cwpt_prefix . 'copy_title', | |
), | |
array( | |
'name' => 'Header Copy / Text', | |
'desc' => 'Enter copy for theme header', | |
'id' => $cwpt_prefix . 'header_copy', | |
'type' => 'textarea_small' | |
), | |
array( | |
'name' => 'Footer Copy / Text', | |
'desc' => 'Copy / Text for the theme footer', | |
'id' => $cwpt_prefix . 'footer_copy', | |
'type' => 'textarea_small' | |
), | |
array( | |
'name' => 'Subscribe Slug / Text', | |
'desc' => 'Copy / Text for the theme footer', | |
'id' => $cwpt_prefix . 'subscribe_copy', | |
'type' => 'textarea_small' | |
), | |
array( | |
'name' => 'Copyright Slug', | |
'desc' => 'This text is append to your copyrights', | |
'id' => $cwpt_prefix . 'copyright_text', | |
'type' => 'text' | |
), | |
array( | |
'name' => 'Contact Slug', | |
'desc' => 'This is used for the contact us text', | |
'id' => $cwpt_prefix . 'contact_text', | |
'type' => 'text' | |
), | |
//******************* offline *************************************** | |
array( | |
'name' => 'Offline Custom Options', | |
'desc' => 'Copy / text / content / elements, used when the site is offline', | |
'type' => 'title', | |
'id' => $cwpt_prefix . 'copy_title', | |
), | |
), | |
); | |
return $meta_boxes; | |
} | |
add_filter('cmb_meta_boxes', 'cwp_options_metaboxes'); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment