我正在开发一个wordpress插件,我想检查一下我是否在正确的屏幕上,并且我采用了这种方法。
class Tome_Places
{
function __construct( $loader )
{
$this->loader = $loader;
$this->define_admin_hooks();
}
private function define_admin_hooks()
{
$this->loader->add_action('in_admin_header', $this, 'current_screen');
}
function start_wrapper() {
global $pagenow, $post_type;
if ( $pagenow == 'post.php' && $post_type == 'tome_place' )
echo '<div class="chapter-wrapper">';
}
function end_wrapper() {
global $pagenow, $post_type;
if ( $pagenow == 'post.php' && $post_type == 'tome_place' )
echo '</div>';
}
}
有没有更好的方法,而不是询问每个函数if ( $pagenow == 'post.php' && $post_type == 'tome_place'
?
谢谢