Make WordPress Core

Ticket #33369: 33369.2.diff

File 33369.2.diff, 5.8 KB (added by iamfriendly, 8 years ago)

Refreshed the patch as the functions have moved files, also added the @since docs

  • wp-includes/taxonomy-functions.php

    diff --git wp-includes/taxonomy-functions.php wp-includes/taxonomy-functions.php
    index a13424b..466e3f8 100644
    function get_terms( $taxonomies, $args = '' ) { 
    10721072                'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 'description__like' => '',
    10731073                'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core',
    10741074                'update_term_meta_cache' => true, 'meta_query' => '' );
     1075
     1076        // Keep a pristine copy of `$args` to pass to filters.
     1077        $_args = $args;
     1078
    10751079        $args = wp_parse_args( $args, $defaults );
    10761080        $args['number'] = absint( $args['number'] );
    10771081        $args['offset'] = absint( $args['offset'] );
    function get_terms( $taxonomies, $args = '' ) { 
    11061110         * Filter the terms query arguments.
    11071111         *
    11081112         * @since 3.1.0
     1113         * @since 4.4.0 Added the `$_args` parameter
    11091114         *
    11101115         * @param array $args       An array of get_term() arguments.
    11111116         * @param array $taxonomies An array of taxonomies.
     1117         * @param array $_args      Array of `get_terms()` arguments, as passed to the function.
    11121118         */
    1113         $args = apply_filters( 'get_terms_args', $args, $taxonomies );
     1119        $args = apply_filters( 'get_terms_args', $args, $taxonomies, $_args );
    11141120
    11151121        // Avoid the query if the queried parent/child_of term has no descendants.
    11161122        $child_of = $args['child_of'];
    function get_terms( $taxonomies, $args = '' ) { 
    11551161                 * Filter the given taxonomy's terms cache.
    11561162                 *
    11571163                 * @since 2.3.0
     1164                 * @since 4.4.0 Added the `$_args` parameter
    11581165                 *
    11591166                 * @param array $cache      Cached array of terms for the given taxonomy.
    11601167                 * @param array $taxonomies An array of taxonomies.
    11611168                 * @param array $args       An array of get_terms() arguments.
     1169                 * @param array $_args      Array of `get_terms()` arguments, as passed to the function.
    11621170                 */
    1163                 return apply_filters( 'get_terms', $cache, $taxonomies, $args );
     1171                return apply_filters( 'get_terms', $cache, $taxonomies, $args, $_args );
    11641172        }
    11651173
    11661174        $_orderby = strtolower( $args['orderby'] );
    function get_terms( $taxonomies, $args = '' ) { 
    11891197         * Filter the ORDERBY clause of the terms query.
    11901198         *
    11911199         * @since 2.8.0
     1200         * @since 4.4.0 Added the `$_args` parameter
    11921201         *
    11931202         * @param string $orderby    `ORDERBY` clause of the terms query.
    11941203         * @param array  $args       An array of terms query arguments.
    11951204         * @param array  $taxonomies An array of taxonomies.
     1205         * @param array  $_args      Array of `get_terms()` arguments, as passed to the function.
    11961206         */
    1197         $orderby = apply_filters( 'get_terms_orderby', $orderby, $args, $taxonomies );
     1207        $orderby = apply_filters( 'get_terms_orderby', $orderby, $args, $taxonomies, $_args );
    11981208
    11991209        $order = strtoupper( $args['order'] );
    12001210        if ( ! empty( $orderby ) ) {
    function get_terms( $taxonomies, $args = '' ) { 
    12611271         * Filter the terms to exclude from the terms query.
    12621272         *
    12631273         * @since 2.3.0
     1274         * @since 4.4.0 Added the `$_args` parameter
    12641275         *
    12651276         * @param string $exclusions `NOT IN` clause of the terms query.
    12661277         * @param array  $args       An array of terms query arguments.
    12671278         * @param array  $taxonomies An array of taxonomies.
     1279         * @param array  $_args      Array of `get_terms()` arguments, as passed to the function.
    12681280         */
    1269         $exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args, $taxonomies );
     1281        $exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args, $taxonomies, $_args );
    12701282
    12711283        if ( ! empty( $exclusions ) ) {
    12721284                $where .= $exclusions;
    function get_terms( $taxonomies, $args = '' ) { 
    13791391         * Use of this filter can result in unpredictable behavior, and is not recommended.
    13801392         *
    13811393         * @since 2.8.0
     1394         * @since 4.4.0 Added the `$_args` parameter
    13821395         *
    13831396         * @param array $selects    An array of fields to select for the terms query.
    13841397         * @param array $args       An array of term query arguments.
    13851398         * @param array $taxonomies An array of taxonomies.
     1399         * @param array $_args      Array of `get_terms()` arguments, as passed to the function.
    13861400         */
    1387         $fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) );
     1401        $fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies, $_args ) );
    13881402
    13891403        $join .= " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
    13901404
    function get_terms( $taxonomies, $args = '' ) { 
    13941408         * Filter the terms query SQL clauses.
    13951409         *
    13961410         * @since 3.1.0
     1411         * @since Added the `$_args` parameter
    13971412         *
    13981413         * @param array $pieces     Terms query SQL clauses.
    13991414         * @param array $taxonomies An array of taxonomies.
    14001415         * @param array $args       An array of terms query arguments.
     1416         * @param array $_args      Array of `get_terms()` arguments, as passed to the function.
    14011417         */
    1402         $clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args );
     1418        $clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args, $_args );
    14031419
    14041420        $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : '';
    14051421        $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : '';
    function get_terms( $taxonomies, $args = '' ) { 
    14291445                wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS );
    14301446
    14311447                /** This filter is documented in wp-includes/taxonomy-functions.php */
    1432                 return apply_filters( 'get_terms', array(), $taxonomies, $args );
     1448                return apply_filters( 'get_terms', array(), $taxonomies, $args, $_args );
    14331449        }
    14341450
    14351451        if ( $child_of ) {
    function get_terms( $taxonomies, $args = '' ) { 
    15011517
    15021518        wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS );
    15031519
    1504         /** This filter is documented in wp-includes/taxonomy */
    1505         return apply_filters( 'get_terms', $terms, $taxonomies, $args );
     1520        /** This filter is documented in wp-includes/taxonomy-functions.php */
     1521        return apply_filters( 'get_terms', $terms, $taxonomies, $args, $_args );
    15061522}
    15071523
    15081524/**