WordPress.org

Make WordPress Core

Ticket #9547: 9547.diff

File 9547.diff, 3.1 KB (added by wonderboymusic, 5 years ago)
  • wp-includes/category-template.php

    diff --git wp-includes/category-template.php wp-includes/category-template.php
    index e45734a..9a0e1a2 100644
    function term_description( $term = 0, $taxonomy = 'post_tag' ) { 
    10541054 *
    10551055 * @since 2.5.0
    10561056 *
     1057 * @see wp_get_object_terms() for reference on the $args param
     1058 *
    10571059 * @param mixed $post Post ID or object.
    10581060 * @param string $taxonomy Taxonomy name.
     1061 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms.
    10591062 * @return array|bool False on failure. Array of term objects on success.
    10601063 */
    1061 function get_the_terms( $post, $taxonomy ) {
     1064function get_the_terms( $post, $taxonomy, $args = array() ) {
    10621065        if ( ! $post = get_post( $post ) )
    10631066                return false;
    10641067
    1065         $terms = get_object_term_cache( $post->ID, $taxonomy );
     1068        $key = "{$post->ID}:$taxonomy:" . md5( serialize( $args ) );
     1069        $group = "{$taxonomy}_relationships";
     1070        $terms = wp_cache_get( $key, $group );
     1071
    10661072        if ( false === $terms ) {
    1067                 $terms = wp_get_object_terms( $post->ID, $taxonomy );
    1068                 wp_cache_add($post->ID, $terms, $taxonomy . '_relationships');
     1073                $terms = wp_get_object_terms( $post->ID, $taxonomy, $args );
     1074                wp_cache_add( $key, $terms, $group );
    10691075        }
    10701076
    10711077        $terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
    function get_the_terms( $post, $taxonomy ) { 
    10811087 *
    10821088 * @since 2.5.0
    10831089 *
     1090 * @see wp_get_object_terms() for reference on the $args param
     1091 *
    10841092 * @param int $id Post ID.
    10851093 * @param string $taxonomy Taxonomy name.
    10861094 * @param string $before Optional. Before list.
    10871095 * @param string $sep Optional. Separate items using this.
    10881096 * @param string $after Optional. After list.
     1097 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms.
    10891098 * @return string
    10901099 */
    1091 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
    1092         $terms = get_the_terms( $id, $taxonomy );
     1100function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '', $args = array() ) {
     1101        $terms = get_the_terms( $id, $taxonomy, $args );
    10931102
    10941103        if ( is_wp_error( $terms ) )
    10951104                return $terms;
    function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' 
    11191128 * @param string $before Optional. Before list.
    11201129 * @param string $sep Optional. Separate items using this.
    11211130 * @param string $after Optional. After list.
     1131 * @param array $args Accepts the same arguments as the $args param for wp_get_object_terms.
    11221132 * @return null|bool False on WordPress error. Returns null when displaying.
    11231133 */
    1124 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
    1125         $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
     1134function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '', $args = array() ) {
     1135        $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after, $args );
    11261136
    11271137        if ( is_wp_error( $term_list ) )
    11281138                return false;
    11291139
    1130         echo apply_filters('the_terms', $term_list, $taxonomy, $before, $sep, $after);
     1140        echo apply_filters( 'the_terms', $term_list, $taxonomy, $before, $sep, $after );
    11311141}
    11321142
    11331143/**