-
-
Save logoscreative/7daa90a4507eb53eab08 to your computer and use it in GitHub Desktop.
Custom Meta Boxes for Events
This file contains 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 | |
$prefix = 'mb_'; | |
global $meta_boxes; | |
$meta_boxes = array(); | |
$meta_boxes[] = array( | |
// Meta box id, UNIQUE per meta box. Optional since 4.1.5 | |
'id' => 'extra-events-info', | |
// Meta box title - Will appear at the drag and drop handle bar. Required. | |
'title' => 'Extra Event Fields', | |
// Post types, accept custom post types as well - DEFAULT is array('post'). Optional. | |
'pages' => array( 'tribe_events' ), | |
// Where the meta box appear: normal (default), advanced, side. Optional. | |
'context' => 'normal', | |
// Order of meta box: high (default), low. Optional. | |
'priority' => 'high', | |
// List of meta fields | |
'fields' => array( | |
array( | |
// Field name - Will be used as label | |
'name' => 'Registration URL', | |
// Field ID, i.e. the meta key | |
'id' => "regbutton", | |
// Field description (optional) | |
'desc' => '(i.e. http://mymb.mtbethel.org/default.aspx?page=3519&event=6796)', | |
'type' => 'text', | |
'size' => '50' | |
), | |
array( | |
// Field name - Will be used as label | |
'name' => 'Custom Schedule Text', | |
// Field ID, i.e. the meta key | |
'id' => "customsched", | |
// Field description (optional) | |
'desc' => '(i.e. Every Tuesday until the Lord returns)', | |
'type' => 'text', | |
'size' => '50' | |
), | |
array( | |
'name' => 'Hide Specific Dates', | |
'id' => "hidedates", | |
'type' => 'checkbox', | |
// Value can be 0 or 1 | |
'std' => 0 | |
) | |
) | |
); | |
/** | |
* Register meta boxes | |
* | |
* @return void | |
*/ | |
function mb_register_meta_boxes() | |
{ | |
// Make sure there's no errors when the plugin is deactivated or during upgrade | |
if ( !class_exists( 'RW_Meta_Box' ) ) | |
return; | |
global $meta_boxes; | |
foreach ( $meta_boxes as $meta_box ) | |
{ | |
new RW_Meta_Box( $meta_box ); | |
} | |
} | |
add_action( 'admin_init', 'mb_register_meta_boxes' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment