Make WordPress Core

Ticket #11058: 11058-2.diff

File 11058-2.diff, 1.6 KB (added by leewillis77, 13 years ago)

Updated patch for unregister_taxonomy_from_object_type(). Removed get_post_type_object check as per conversation with nacin in IRC

  • wp-includes/taxonomy.php

     
    466466 * @param string $object_type Name of the object type
    467467 * @return bool True if successful, false if not
    468468 */
    469 function register_taxonomy_for_object_type( $taxonomy, $object_type) {
     469function register_taxonomy_for_object_type( $taxonomy, $object_type ) {
    470470        global $wp_taxonomies;
    471471
    472         if ( !isset($wp_taxonomies[$taxonomy]) )
     472        if ( ! isset( $wp_taxonomies[$taxonomy] ) )
    473473                return false;
    474474
    475         if ( ! get_post_type_object($object_type) )
     475        if ( ! get_post_type_object( $object_type ) )
    476476                return false;
    477477
    478478        if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) )
     
    481481        return true;
    482482}
    483483
     484/**
     485 * Remove an already registered taxonomy from an object type.
     486 *
     487 * @package WordPress
     488 * @subpackage Taxonomy
     489 * @since 3.7.0
     490 * @uses $wp_taxonomies Modifies taxonomy object
     491 *
     492 * @param string $taxonomy Name of taxonomy object
     493 * @param string $object_type Name of the object type
     494 * @return bool True if successful, false if not
     495 */
     496function unregister_taxonomy_from_object_type( $taxonomy, $object_type ) {
     497        global $wp_taxonomies;
     498
     499        if ( ! isset( $wp_taxonomies[$taxonomy] ) )
     500                return false;
     501
     502        foreach ( array_keys( $wp_taxonomies[$taxonomy]->object_type ) as $array_key ) {
     503                if ( $wp_taxonomies[$taxonomy]->object_type[$array_key] === $object_type ) {
     504                        unset( $wp_taxonomies[$taxonomy]->object_type[$array_key] );
     505                        return true;
     506                }
     507        }
     508       
     509        return false;
     510}
     511
    484512//
    485513// Term API
    486514//