Last active
December 21, 2015 09:29
-
-
Save hereswhatidid/6285264 to your computer and use it in GitHub Desktop.
Display currently active post types and list their source.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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