[wp-trac] [WordPress Trac] #21561: is_page_template() doesn't work in admin edit page screen
WordPress Trac
wp-trac at lists.automattic.com
Mon Aug 13 10:13:00 UTC 2012
#21561: is_page_template() doesn't work in admin edit page screen
-----------------------------+-----------------------------
Reporter: l3rady | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.4.1
Severity: trivial | Keywords: needs-patch
-----------------------------+-----------------------------
Take this use case scenario:
''I want to show a meta box on the page edit screen when a certain
template is set.''
To do the above I'd use some code like this:
{{{
public static function add_meta_boxes( $post_type, $post )
{
if( "page" != $post_type )
return;
if ( ! is_page_template('templates/with-solutions.php') )
return;
add_meta_box("bs_SolutionsMeta-meta", "Solutions", array(
__CLASS__, "solutions_meta" ), "page", "normal", "low");
}
}}}
Unfortunately the above won't work as is_page_template() does an is_page()
check in its function which will fail when run in admin.
I'd like to propose that the function be worked on to allow this function
work in the admin some way.
I have found a work around and used:
{{{
if ( 'templates/with-solutions.php' != get_page_template_slug(
$post->ID ) )
return;
}}}
for now but I'd love to see that function functional in admin.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21561>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list