Make WordPress Core

Ticket #53319: 53319.diff

File 53319.diff, 1.6 KB (added by jnylen0, 4 years ago)

I converted the changes in this ticket into a patch file.

  • src/wp-includes/category-template.php

    diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php
    index b9eb6dd689f..ab6f86660fb 100644
    a b function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' 
    12711271 *     @type string $separator Separator for between the terms. Default '/'.
    12721272 *     @type bool   $link      Whether to format as a link. Default true.
    12731273 *     @type bool   $inclusive Include the term to get the parents for. Default true.
     1274 *     @type bool   $reverse   Wether to reverse the hierarchical order of the Terms on output. Default true.
    12741275 * }
    12751276 * @return string|WP_Error A list of term parents on success, WP_Error or empty string on failure.
    12761277 */
    function get_term_parents_list( $term_id, $taxonomy, $args = array() ) { 
    12931294                'separator' => '/',
    12941295                'link'      => true,
    12951296                'inclusive' => true,
     1297                'reverse'   => true,
    12961298        );
    12971299
    12981300        $args = wp_parse_args( $args, $defaults );
    12991301
    1300         foreach ( array( 'link', 'inclusive' ) as $bool ) {
     1302        foreach ( array( 'link', 'inclusive', 'reverse' ) as $bool ) {
    13011303                $args[ $bool ] = wp_validate_boolean( $args[ $bool ] );
    13021304        }
    13031305
    function get_term_parents_list( $term_id, $taxonomy, $args = array() ) { 
    13061308        if ( $args['inclusive'] ) {
    13071309                array_unshift( $parents, $term_id );
    13081310        }
     1311       
     1312        if( $args['reverse'] ){
     1313                $parents = array_reverse( $parents );
     1314        }
    13091315
    1310         foreach ( array_reverse( $parents ) as $term_id ) {
     1316        foreach ( $parents as $term_id ) {
    13111317                $parent = get_term( $term_id, $taxonomy );
    13121318                $name   = ( 'slug' === $args['format'] ) ? $parent->slug : $parent->name;
    13131319