Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 1, 2012 15:49
Show Gist options
  • Save billerickson/1547637 to your computer and use it in GitHub Desktop.
Save billerickson/1547637 to your computer and use it in GitHub Desktop.
Create session metaboxes
<?php
add_action( 'init', 'be_initialize_meta_boxes' );
/**
* Initialize the metabox code library
* Since this code might be in the theme and multiple plugins,
* see if it exists already before initializing it.
*
*/
function initialize_meta_boxes() {
if ( !class_exists( 'cmb_Meta_Box' ) ) {
require_once( 'lib/metabox/init.php' );
}
}
add_filter( 'cmb_meta_boxes', 'be_session_metabox' );
/**
* Create Metaboxes
*
*/
function be_session_metabox() {
$meta_boxes[] = array(
'id' => 'session-details',
'title' => 'Session Details',
'pages' => array( 'sessions' ),
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
'fields' => array(
array(
'name' => 'Date',
'id' => 'be_session_date',
'desc' => '',
'type' => 'text_date_timestamp'
),
array(
'name' => 'Time',
'id' => 'be_session_time',
'desc' => '',
'type' => 'text_time'
),
array(
'name' => 'Location',
'id' => 'be_session_location',
'desc' => '',
'type' => 'wysiwyg',
'options' => array(
'textarea_rows' => 5,
'media_buttons' => false,
)
)
)
);
return $meta_boxes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment