Skip to content

Instantly share code, notes, and snippets.

@hereswhatidid
Last active December 21, 2015 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hereswhatidid/6285264 to your computer and use it in GitHub Desktop.
Save hereswhatidid/6285264 to your computer and use it in GitHub Desktop.
Display currently active post types and list their source.
<?php
add_action( 'registered_post_type', 'display_registered_post_types', 99999, 2 );
global $tempPostTypes;
$tempPostTypes = array();
function display_registered_post_types( $post_type, $args ) {
global $tempPostTypes;
$pluginDir = str_replace( '/', '\\', WP_PLUGIN_DIR );
$themesDir = str_replace( '/', '\\', TEMPLATEPATH );
$backtrace = debug_backtrace();
$filePath = $backtrace[3]['file'];
if ( $args->_builtin ) {
$source = 'Core';
} else {
if ( strpos( $filePath, $pluginDir ) !== false ) {
$source = 'Plugin';
}
if ( strpos( $filePath, $themesDir ) !== false ) {
$source = 'Theme';
}
}
$taxonomies = get_object_taxonomies( $post_type );
$tempPostTypes[] = array( $post_type, $args, $taxonomies, $source, dirname( $filePath ) );
}
add_action( 'admin_init', function() {
global $tempPostTypes;
$activePlugins = get_plugins();
$themes = wp_get_themes();
// var_dump( $taxonomies );
// var_dump( $themes );
// var_dump( $activePlugins );
// var_dump( $tempPostTypes );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment