Created
November 19, 2011 21:24
-
-
Save billerickson/1379377 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Metaboxes | |
* | |
* This file registers any custom metaboxes | |
* | |
* @package BE_Genesis_Child | |
* @author Bill Erickson <[email protected]> | |
* @copyright Copyright (c) 2011, Bill Erickson | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
*/ | |
add_filter( 'cmb_meta_boxes', 'be_sample_metaboxes' ); | |
function be_sample_metaboxes( $meta_boxes ) { | |
global $prefix; | |
$meta_boxes[] = array( | |
'id' => 'test_metabox', | |
'title' => 'Test Metabox', | |
'pages' => array('page'), // post type | |
'context' => 'normal', | |
'priority' => 'high', | |
'show_names' => true, // Show field names on the left | |
'fields' => array( | |
array( | |
'name' => 'Test Text', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_text', | |
'type' => 'text' | |
), | |
array( | |
'name' => 'Test Text Small', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_textsmall', | |
'type' => 'text_small' | |
), | |
array( | |
'name' => 'Test Text Medium', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_textmedium', | |
'type' => 'text_medium' | |
), | |
array( | |
'name' => 'Test Date Picker', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_textdate', | |
'type' => 'text_date' | |
), | |
array( | |
'name' => 'Test Money', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_textmoney', | |
'type' => 'text_money' | |
), | |
array( | |
'name' => 'Test Text Area', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_textarea', | |
'type' => 'textarea' | |
), | |
array( | |
'name' => 'Test Text Area Small', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_textareasmall', | |
'type' => 'textarea_small' | |
), | |
array( | |
'name' => 'Test Title Weeeee', | |
'desc' => 'This is a title description', | |
'type' => 'title', | |
'id' => $prefix . 'test_title' | |
), | |
array( | |
'name' => 'Test Select', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_select', | |
'type' => 'select', | |
'options' => array( | |
array('name' => 'Option One', 'value' => 'standard'), | |
array('name' => 'Option Two', 'value' => 'custom'), | |
array('name' => 'Option Three', 'value' => 'none') | |
) | |
), | |
array( | |
'name' => 'Test Radio inline', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_radio', | |
'type' => 'radio_inline', | |
'options' => array( | |
array('name' => 'Option One', 'value' => 'standard'), | |
array('name' => 'Option Two', 'value' => 'custom'), | |
array('name' => 'Option Three', 'value' => 'none') | |
) | |
), | |
array( | |
'name' => 'Test Radio', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_radio', | |
'type' => 'radio', | |
'options' => array( | |
array('name' => 'Option One', 'value' => 'standard'), | |
array('name' => 'Option Two', 'value' => 'custom'), | |
array('name' => 'Option Three', 'value' => 'none') | |
) | |
), | |
array( | |
'name' => 'Test Taxonomy Radio', | |
'desc' => 'Description Goes Here', | |
'id' => $prefix . 'text_taxonomy_radio', | |
'taxonomy' => '', //Enter Taxonomy Slug | |
'type' => 'taxonomy_radio', | |
), | |
array( | |
'name' => 'Test Taxonomy Select', | |
'desc' => 'Description Goes Here', | |
'id' => $prefix . 'text_taxonomy_select', | |
'taxonomy' => '', //Enter Taxonomy Slug | |
'type' => 'taxonomy_select', | |
), | |
array( | |
'name' => 'Test Checkbox', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_checkbox', | |
'type' => 'checkbox' | |
), | |
array( | |
'name' => 'Test Multi Checkbox', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_multicheckbox', | |
'type' => 'multicheck', | |
'options' => array( | |
'check1' => 'Check One', | |
'check2' => 'Check Two', | |
'check3' => 'Check Three', | |
) | |
), | |
array( | |
'name' => 'Test wysiwyg', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_wysiwyg', | |
'type' => 'wysiwyg', | |
'options' => array( | |
'textarea_rows' => 5, | |
) | |
), | |
array( | |
'name' => 'Test Image', | |
'desc' => 'Upload an image or enter an URL.', | |
'id' => $prefix . 'test_image', | |
'type' => 'file' | |
), | |
) | |
); | |
$meta_boxes[] = array( | |
'id' => 'about_page_metabox', | |
'title' => 'About Page Metabox', | |
'pages' => array('page'), // post type | |
'show_on' => array( 'key' => 'id', 'value' => array( 2 ) ), // specific post ids to display this metabox | |
'context' => 'normal', | |
'priority' => 'high', | |
'show_names' => true, // Show field names on the left | |
'fields' => array( | |
array( | |
'name' => 'Test Text', | |
'desc' => 'field description (optional)', | |
'id' => $prefix . 'test_text', | |
'type' => 'text' | |
), | |
) | |
); | |
return $meta_boxes; | |
} | |
/** | |
* Initialize Metabox Class | |
* see /lib/metabox/example-functions.php for more information | |
* | |
*/ | |
function be_initialize_cmb_meta_boxes() { | |
if ( !class_exists( 'cmb_Meta_Box' ) ) { | |
require_once( BE_DIR . '/lib/metabox/init.php' ); | |
} | |
} | |
add_action( 'init', 'be_initialize_cmb_meta_boxes', 9999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment