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
// Metaboxes | |
require_once('library/metaboxes.php'); |
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
//// Load scripts and styles for Meta box */ | |
// enqueue scripts and styles, but only if is_admin | |
if(is_admin()) { | |
wp_enqueue_script('jquery-ui-datepicker'); | |
wp_enqueue_script('jquery-ui-slider'); | |
wp_enqueue_script('custom-js', get_template_directory_uri().'/library/metaboxes/js/custom-js.js'); | |
wp_enqueue_style('jquery-ui-custom', get_template_directory_uri().'/library/metaboxes/css/jquery-ui-custom.css'); | |
} |
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
// Wrap all categories in a function | |
function wcat2() { | |
$out = array(); | |
$categories = get_categories(); | |
foreach( $categories as $category ) { | |
$out[$category->term_id] = array( | |
'label' => $category->slug, | |
'value' => $category->term_id | |
); | |
} |
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
// Field Array | |
$prefix = 'pages_'; | |
$page_custom_meta_fields = array( | |
array( | |
'label' => 'Slider On/Off', | |
'desc' => 'Tick here if you would like a slider on this page (This will override the theme settings).', | |
'id' => $prefix.'slider_default_onoff', | |
'type' => 'select', | |
'options' => array ( | |
'one' => array ( |
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
// The Callback | |
function page_show_custom_meta_box() { | |
global $page_custom_meta_fields, $post; | |
// Use nonce for verification | |
echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />'; | |
// Begin the field table and loop | |
echo '<table class="form-table">'; | |
foreach ($page_custom_meta_fields as $field) { | |
// get value of this field if it exists for this post |
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
// Save the Data | |
function page_save_custom_meta($post_id) { | |
global $page_custom_meta_fields; | |
// verify nonce | |
if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) | |
return $post_id; | |
// check autosave | |
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) | |
return $post_id; |
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
$prefix = 'pages_'; | |
'id' => $prefix.'slider_default_onoff', |
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
$home = get_post_meta( $post->ID, 'home_slider_default_onoff', true ); |
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
$prefix = 'pages_'; | |
'id' => $prefix.'slider_default_onoff', |
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
if ( $home == on ) { | |
// do something | |
} |
OlderNewer