Post Types: Introduce unregister_post_type().

This new function can be used to completely unregister non built-in post types.

Fixes #14761.

git-svn-id: https://develop.svn.wordpress.org/trunk@36316 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2016-01-15 12:19:15 +00:00
parent 8e8cdb2ef4
commit a111eafd41
4 changed files with 313 additions and 16 deletions

View File

@@ -335,14 +335,7 @@ if ( !function_exists( 'str_getcsv' ) ) {
* Removes the post type and its taxonomy associations.
*/
function _unregister_post_type( $cpt_name ) {
unset( $GLOBALS['wp_post_types'][ $cpt_name ] );
unset( $GLOBALS['_wp_post_type_features'][ $cpt_name ] );
foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy ) {
if ( false !== $key = array_search( $cpt_name, $taxonomy->object_type ) ) {
unset( $taxonomy->object_type[$key] );
}
}
unregister_post_type( $cpt_name );
}
function _unregister_taxonomy( $taxonomy_name ) {