Make WordPress Core


Ignore:
Timestamp:
09/24/2013 02:54:00 AM (12 years ago)
Author:
nacin
Message:

Introduce register_taxonomy_for_object_type().

props leewillis77.
fixes #11058.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r25576 r25596  
    508508}
    509509
     510/**
     511 * Remove an already registered taxonomy from an object type.
     512 *
     513 * @since 3.7.0
     514 *
     515 * @param string $taxonomy    Name of taxonomy object.
     516 * @param string $object_type Name of the object type.
     517 * @return bool True if successful, false if not.
     518 */
     519function unregister_taxonomy_for_object_type( $taxonomy, $object_type ) {
     520    global $wp_taxonomies;
     521
     522    if ( ! isset( $wp_taxonomies[ $taxonomy ] ) )
     523        return false;
     524
     525    if ( ! get_post_type_object( $object_type ) )
     526        return false;
     527
     528    $key = array_search( $object_type, $wp_taxonomies[ $taxonomy ]->object_type, true );
     529    if ( false === $key )
     530        return false;
     531
     532    unset( $wp_taxonomies[ $taxonomy ]->object_type[ $key ] );
     533    return true;
     534}
     535
    510536//
    511537// Term API
Note: See TracChangeset for help on using the changeset viewer.