Make WordPress Core

Ticket #11058: 11058_unregister_taxonomy_from_object_type.diff

File 11058_unregister_taxonomy_from_object_type.diff, 1021 bytes (added by leewillis77, 14 years ago)

Patch updated, and re-rolled against 3.4.1

  • taxonomy.php

    old new  
    459459        return true;
    460460}
    461461
     462/**
     463 * Remove an already registered taxonomy from an object type.
     464 *
     465 * @package WordPress
     466 * @subpackage Taxonomy
     467 * @since 3.5
     468 * @uses $wp_taxonomies Modifies taxonomy object
     469 *
     470 * @param string $taxonomy Name of taxonomy object
     471 * @param string $object_type Name of the object type
     472 * @return bool True if successful, false if not
     473 */
     474function unregister_taxonomy_from_object_type($taxonomy, $object_type) {
     475
     476        global $wp_taxonomies;
     477
     478        if ( !isset($wp_taxonomies[$taxonomy]) )
     479                return false;
     480
     481        if ( ! get_post_type_object($object_type) )
     482                return false;
     483
     484        foreach (array_keys($wp_taxonomies[$taxonomy]->object_type) as $array_key) {
     485                if ($wp_taxonomies[$taxonomy]->object_type[$array_key] == $object_type) {
     486                        unset ($wp_taxonomies[$taxonomy]->object_type[$array_key]);
     487                        return true;
     488                }
     489        }
     490        return false;
     491
     492}
    462493//
    463494// Term API
    464495//