Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Commit

Permalink
update CMB to 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed Jan 24, 2014
2 parents 2fedd07 + a3753f0 commit 00c5d2c
Show file tree
Hide file tree
Showing 11 changed files with 1,623 additions and 700 deletions.
104 changes: 65 additions & 39 deletions example-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @category YourThemeOrPlugin
* @package Metaboxes
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
* @link https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
* @link https://github.com/webdevstudios/Custom-Metaboxes-and-Fields-for-WordPress
*/

add_filter( 'cmb_meta_boxes', 'cmb_sample_metaboxes' );
Expand Down Expand Up @@ -34,8 +34,10 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'test_text',
'type' => 'text',
// 'repeatable' => true,
// 'on_front' => false, // Optionally designate a field to wp-admin only
// 'sanitization_cb' => 'my_custom_sanitization', // custom sanitization callback parameter
// 'escape_cb' => 'my_custom_escaping', // custom escaping callback parameter
// 'on_front' => false, // Optionally designate a field to wp-admin only
// 'repeatable' => true,
),
array(
'name' => __( 'Test Text Small', 'cmb' ),
Expand Down Expand Up @@ -97,26 +99,29 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
'id' => $prefix . 'test_datetime_timestamp',
'type' => 'text_datetime_timestamp',
),
array(
'name' => __( 'Test Date/Time Picker/Time zone Combo (serialized DateTime object)', 'cmb' ),
// This text_datetime_timestamp_timezone field type
// is only compatible with PHP versions 5.3 or above.
// Feel free to uncomment and use if your server meets the requirement
// array(
// 'name' => __( 'Test Date/Time Picker/Time zone Combo (serialized DateTime object)', 'cmb' ),
// 'desc' => __( 'field description (optional)', 'cmb' ),
// 'id' => $prefix . 'test_datetime_timestamp_timezone',
// 'type' => 'text_datetime_timestamp_timezone',
// ),
array(
'name' => __( 'Test Money', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'test_datetime_timestamp_timezone',
'type' => 'text_datetime_timestamp_timezone',
),
array(
'name' => __( 'Test Money', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'test_textmoney',
'type' => 'text_money',
// 'before' => '£', // override '$' symbol if needed
'id' => $prefix . 'test_textmoney',
'type' => 'text_money',
// 'before' => '£', // override '$' symbol if needed
// 'repeatable' => true,
),
array(
'name' => __( 'Test Color Picker', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'test_colorpicker',
'type' => 'colorpicker',
'std' => '#ffffff'
'name' => __( 'Test Color Picker', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'test_colorpicker',
'type' => 'colorpicker',
'default' => '#ffffff'
),
array(
'name' => __( 'Test Text Area', 'cmb' ),
Expand Down Expand Up @@ -181,6 +186,7 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
'id' => $prefix . 'text_taxonomy_radio',
'type' => 'taxonomy_radio',
'taxonomy' => 'category', // Taxonomy Slug
// 'inline' => true, // Toggles display to inline
),
array(
'name' => __( 'Test Taxonomy Select', 'cmb' ),
Expand All @@ -190,11 +196,12 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
'taxonomy' => 'category', // Taxonomy Slug
),
array(
'name' => __( 'Test Taxonomy Multi Checkbox', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'test_multitaxonomy',
'type' => 'taxonomy_multicheck',
'taxonomy' => 'post_tag', // Taxonomy Slug
'name' => __( 'Test Taxonomy Multi Checkbox', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'test_multitaxonomy',
'type' => 'taxonomy_multicheck',
'taxonomy' => 'post_tag', // Taxonomy Slug
// 'inline' => true, // Toggles display to inline
),
array(
'name' => __( 'Test Checkbox', 'cmb' ),
Expand All @@ -212,13 +219,14 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
'check2' => __( 'Check Two', 'cmb' ),
'check3' => __( 'Check Three', 'cmb' ),
),
// 'inline' => true, // Toggles display to inline
),
array(
'name' => __( 'Test wysiwyg', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'test_wysiwyg',
'type' => 'wysiwyg',
'options' => array( 'textarea_rows' => 5, ),
'options' => array( 'textarea_rows' => 5, ),
),
array(
'name' => __( 'Test Image', 'cmb' ),
Expand Down Expand Up @@ -249,7 +257,7 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
'priority' => 'high',
'show_names' => true, // Show field names on the left
'show_on' => array( 'key' => 'id', 'value' => array( 2, ), ), // Specific post IDs to display this metabox
'fields' => array(
'fields' => array(
array(
'name' => __( 'Test Text', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
Expand All @@ -263,24 +271,24 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
* Metabox for the user profile screen
*/
$meta_boxes['user_edit'] = array(
'id' => 'user_edit',
'title' => __( 'User Profile Metabox', 'cmb' ),
'pages' => array( 'user' ), // Tells CMB to use user_meta vs post_meta
'show_names' => true,
'id' => 'user_edit',
'title' => __( 'User Profile Metabox', 'cmb' ),
'pages' => array( 'user' ), // Tells CMB to use user_meta vs post_meta
'show_names' => true,
// 'cmb_styles' => true, // Show cmb bundled styles.. not needed on user profile page
'fields' => array(
'fields' => array(
array(
'name' => __( 'Extra Info', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'exta_info',
'type' => 'title',
'name' => __( 'Extra Info', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'exta_info',
'type' => 'title',
'on_front' => false,
),
array(
'name' => __( 'Avatar', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'avatar',
'type' => 'file',
'name' => __( 'Avatar', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'avatar',
'type' => 'file',
'save_id' => true,
),
array(
Expand Down Expand Up @@ -316,6 +324,24 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
)
);

/**
* Metabox for an options page
*/
$meta_boxes['options_page'] = array(
'id' => 'options_page',
'title' => __( 'Theme Options Metabox', 'cmb' ),
'show_on' => array( 'key' => 'options-page', 'value' => array( $prefix . 'theme_options', ), ),
'fields' => array(
array(
'name' => __( 'Site Background Color', 'cmb' ),
'desc' => __( 'field description (optional)', 'cmb' ),
'id' => $prefix . 'bg_color',
'type' => 'colorpicker',
'default' => '#ffffff'
),
)
);

// Add other metaboxes as needed

return $meta_boxes;
Expand Down
Loading

0 comments on commit 00c5d2c

Please sign in to comment.