Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions class.cmb-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ function add_for_page_template( $display ) {
// Get current template
$current_template = get_post_meta( $post_id, '_wp_page_template', true );

// Do we need to probe deeper?
if ($current_template=='default') {

// If it's just set to "Default Template", check to see if that means front-page or home

if ($post_id == get_option('page_on_front')) {
$current_template = 'front-page.php';
} else if ($post_id == get_option('page_for_posts')) {
$current_template = 'home.php';
}
}

// If value isn't an array, turn it into one
$this->_meta_box['show_on']['page-template'] = ! is_array( $this->_meta_box['show_on']['page-template'] ) ? array( $this->_meta_box['show_on']['page-template'] ) : $this->_meta_box['show_on']['page-template'];

Expand All @@ -220,6 +232,18 @@ function hide_for_page_template( $display ) {
// Get current template
$current_template = get_post_meta( $post_id, '_wp_page_template', true );

// Do we need to probe deeper?
if ($current_template=='default') {

// If it's just set to "Default Template", check to see if that means front-page or home

if ($post_id == get_option('page_on_front')) {
$current_template = 'front-page.php';
} else if ($post_id == get_option('page_for_posts')) {
$current_template = 'home.php';
}
}

// If value isn't an array, turn it into one
$this->_meta_box['hide_on']['page-template'] = ! is_array( $this->_meta_box['hide_on']['page-template'] ) ? array( $this->_meta_box['hide_on']['page-template'] ) : $this->_meta_box['hide_on']['page-template'];

Expand Down