Make WordPress Core

Ticket #33990: 33990.patch

File 33990.patch, 1.1 KB (added by tyxla, 11 years ago)

Introducing a register_taxonomy_args filter that allows to modify the $args when registering a taxonomy.

  • src/wp-includes/taxonomy-functions.php

     
    346346        if ( ! is_array( $wp_taxonomies ) )
    347347                $wp_taxonomies = array();
    348348
     349        $args = wp_parse_args( $args );
     350
     351        /**
     352         * Filter the arguments for registering a taxonomy.
     353         *
     354         * @since 4.4.0
     355         *
     356         * @param array  $args      Array of arguments for registering a taxonomy.
     357         * @param string $taxonomy  Taxonomy key.
     358         */
     359        $args = apply_filters( 'register_taxonomy_args', $args, $taxonomy );
     360
    349361        $defaults = array(
    350362                'labels'                => array(),
    351363                'description'           => '',
    … …  
    364376                'update_count_callback' => '',
    365377                '_builtin'              => false,
    366378        );
    367         $args = wp_parse_args( $args, $defaults );
     379        $args = array_merge( $defaults, $args );
    368380
    369381        if ( empty( $taxonomy ) || strlen( $taxonomy ) > 32 ) {
    370382                _doing_it_wrong( __FUNCTION__, __( 'Taxonomy names must be between 1 and 32 characters in length.' ), '4.2' );