wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
unregister_post_type › WordPress Function
Seit4.5.0
Veraltetn/v
› unregister_post_type ( $post_type )
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Unregisters a post type.
Cannot be used to unregister built-in post types.Ähnliche Funktionen: register_post_type, unregister_post_meta, unregister_block_type, register_post_meta, register_block_type
Quellcode
function unregister_post_type( $post_type ) {
global $post_type_meta_caps, $wp_post_types;
$post_type_object = get_post_type_object( $post_type );
if ( ! $post_type_object ) {
return new WP_Error( 'invalid_post_type', __( 'Invalid post type.' ) );
}
// Do not allow unregistering internal post types.
if ( $post_type_object->_builtin ) {
return new WP_Error( 'invalid_post_type', __( 'Unregistering a built-in post type is not allowed' ) );
}
$post_type_object->remove_supports();
$post_type_object->remove_rewrite_rules();
$post_type_object->unregister_meta_boxes();
$post_type_object->remove_hooks();
$post_type_object->unregister_taxonomies();
unset( $wp_post_types[ $post_type ] );
/*
* Rebuild the meta capabilities of the post types that remain.
*
* They are keyed by the custom capability name, so a single entry may be owed to any
* number of registered post types. Removing the entries for this post type alone could
* therefore remove entries that the others still depend on.
*/
$post_type_meta_caps = array();
foreach ( $wp_post_types as $registered_post_type ) {
if ( $registered_post_type->map_meta_cap ) {
_post_type_meta_capabilities( get_object_vars( $registered_post_type->cap ) );
}
}
/**
* Fires after a post type was unregistered.
*
* @since 4.5.0
*
* @param string $post_type Post type key.
*/
do_action( 'unregistered_post_type', $post_type );
return true;
}