Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page template tests don't recognise default templates #305

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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