钩入registered_post_type
并存储来自debug_backtrace()
. 第三个条目应该是调用插件。
示例代码
add_action( \'registered_post_type\', \'track_post_types\', 10, 2);
function track_post_types( $post_type = NULL, $args = array() )
{
static $tracked = array();
if ( \'shutdown\' === current_filter() )
{
print \'<pre>$tracked = \' . esc_html( var_export( $tracked, TRUE ) ) . \'</pre>\';
return;
}
if ( $args->_builtin )
return;
$backtrace = debug_backtrace();
$tracked[ $post_type ] = $backtrace[3];
add_action( \'shutdown\', __FUNCTION__ );
}
样本输出
array (
\'file\' => \'F:\\\\Dropbox\\\\wp-content\\\\plugins\\\\t5-cpt-tester\\\\t5-cpt-tester.php\',
\'line\' => 45,
\'function\' => \'register_post_type\',
\'args\' =>
array (
0 => \'project\',
1 =>
array (
\'can_export\' => true,
\'description\' => \'\',
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'hierarchical\' => false,
\'labels\' =>
array (
\'add_new\' => \'Add new\',
\'add_new_item\' => \'Add new project\',
\'all_items\' => \'All projects\',
\'edit_item\' => \'Edit project\',
\'name\' => \'Projects\',
\'name_admin_bar\' => \'Project\',
\'new_item\' => \'New project\',
\'not_found\' => \'No projects found.\',
\'not_found_in_trash\' => \'No projects in trash.\',
\'parent_item_colon\' => \'Parent project:\',
\'search_items\' => \'Search projects\',
\'singular_name\' => \'Project\',
\'view_item\' => \'View project\',
),
\'menu_icon\' => NULL,
\'menu_position\' => NULL,
\'permalink_epmask\' => 1,
\'public\' => true,
\'publicly_queryable\' => true,
\'query_var\' => \'project\',
\'rewrite\' =>
array (
\'slug\' => \'project\',
\'with_front\' => false,
),
\'show_in_nav_menus\' => true,
\'show_in_menu\' => true,
\'show_in_admin_bar\' => true,
\'show_ui\' => true,
\'supports\' =>
array (
0 => \'author\',
1 => \'comments\',
2 => \'editor\',
3 => \'excerpt\',
4 => \'revisions\',
5 => \'thumbnail\',
6 => \'title\',
),
),
),
)