Ticket #40089: 40089.diff
File 40089.diff, 2.2 KB (added by , 7 years ago) |
---|
-
src/wp-includes/taxonomy.php
3847 3847 function get_term_link( $term, $taxonomy = '' ) { 3848 3848 global $wp_rewrite; 3849 3849 3850 if ( ! is_object($term) ) {3850 if ( ! is_object( $term ) ) { 3851 3851 if ( is_int( $term ) ) { 3852 3852 $term = get_term( $term, $taxonomy ); 3853 3853 } else { … … 3855 3855 } 3856 3856 } 3857 3857 3858 if ( ! is_object($term) )3858 if ( ! is_object( $term ) ) 3859 3859 $term = new WP_Error('invalid_term', __('Empty Term')); 3860 3860 3861 3861 if ( is_wp_error( $term ) ) … … 3863 3863 3864 3864 $taxonomy = $term->taxonomy; 3865 3865 3866 $termlink = $wp_rewrite->get_extra_permastruct( $taxonomy);3866 $termlink = $wp_rewrite->get_extra_permastruct( $taxonomy ); 3867 3867 3868 3868 $slug = $term->slug; 3869 $t = get_taxonomy( $taxonomy);3869 $t = get_taxonomy( $taxonomy ); 3870 3870 3871 if ( empty( $termlink) ) {3871 if ( empty( $termlink ) ) { 3872 3872 if ( 'category' == $taxonomy ) 3873 3873 $termlink = '?cat=' . $term->term_id; 3874 3874 elseif ( $t->query_var ) … … 3875 3875 $termlink = "?$t->query_var=$slug"; 3876 3876 else 3877 3877 $termlink = "?taxonomy=$taxonomy&term=$slug"; 3878 $termlink = home_url( $termlink);3878 $termlink = home_url( $termlink ); 3879 3879 } else { 3880 3880 if ( $t->rewrite['hierarchical'] ) { 3881 3881 $hierarchical_slugs = array(); 3882 3882 $ancestors = get_ancestors( $term->term_id, $taxonomy, 'taxonomy' ); 3883 foreach ( ( array)$ancestors as $ancestor ) {3884 $ancestor_term = get_term( $ancestor, $taxonomy);3883 foreach ( ( array )$ancestors as $ancestor ) { 3884 $ancestor_term = get_term( $ancestor, $taxonomy ); 3885 3885 $hierarchical_slugs[] = $ancestor_term->slug; 3886 3886 } 3887 $hierarchical_slugs = array_reverse( $hierarchical_slugs);3887 $hierarchical_slugs = array_reverse( $hierarchical_slugs ); 3888 3888 $hierarchical_slugs[] = $slug; 3889 $termlink = str_replace( "%$taxonomy%", implode('/', $hierarchical_slugs), $termlink);3889 $termlink = str_replace( "%$taxonomy%", implode( '/', $hierarchical_slugs ), $termlink ); 3890 3890 } else { 3891 $termlink = str_replace( "%$taxonomy%", $slug, $termlink);3891 $termlink = str_replace( "%$taxonomy%", $slug, $termlink ); 3892 3892 } 3893 3893 $termlink = home_url( user_trailingslashit($termlink, 'category') ); 3894 3894 }