WordPress.org

Make WordPress Core

Ticket #7463: 7463.diff

File 7463.diff, 3.3 KB (added by ionfish, 5 years ago)
  • wp-includes/formatting.php

     
    15011501        return '<' . $tag . $link . ' target="' . $target . '">'; 
    15021502} 
    15031503 
     1504/** 
     1505 * Implodes an array and adds a final conjuction. 
     1506 *  
     1507 * Given the array <code>array('John', 'Paul', 'George', 'Ringo')</code> it will 
     1508 * return the string <code>'John, Paul, George and Ringo'</code>. 
     1509 *  
     1510 * @package WordPress 
     1511 * @since 2.7 
     1512 *  
     1513 * @internal 
     1514 * @param array $array 
     1515 * @param string $glue 
     1516 * @param string $conjuction 
     1517 * @return string 
     1518 */ 
     1519function _implode_nicely( $array, $glue = ', ', $conjuction = 'and' ) { 
     1520        if ( !is_array($array) || count($array) == 0 ) 
     1521                return; 
     1522         
     1523        $last_value = array_pop($array); 
     1524         
     1525        if ( count($array) > 0 ) 
     1526                $output = implode($glue, $array) . " $conjuction $last_value"; 
     1527        else 
     1528                $output = $last_value; 
     1529         
     1530        return $output; 
     1531} 
     1532 
    15041533?> 
  • wp-includes/general-template.php

     
    331331} 
    332332 
    333333 
     334/** 
     335 * Outputs tag titles for tag intersections and unions. 
     336 *  
     337 * @package WordPress 
     338 * @since 2.7 
     339 *  
     340 * @global $wpdb object 
     341 * @param $tag_wrapper string 
     342 * @return string 
     343 */ 
     344function multiple_tag_titles($format = '&#8216;%s&#8217;') { 
     345        global $wpdb; 
     346         
     347        if ( !is_tag() ) 
     348                return; 
     349         
     350        if ( $tag_slugs = get_query_var('tag_slug__and') ) 
     351                $connective = __('and'); 
     352        elseif ( $tag_slugs = get_query_var('tag_slug__in') ) 
     353                $connective = __('or'); 
     354        else 
     355                $single_tag = intval( get_query_var('tag_id') ); 
     356         
     357        $tags = array(); 
     358        if ( $tag_slugs ) { 
     359                foreach ( $tag_slugs as $tag_slug ) { 
     360                        $tag = get_term_by('slug', $tag_slug, 'post_tag', OBJECT, 'display'); 
     361                        if ( !is_wp_error($tag) && !empty($tag->name) ) 
     362                                $tags[] = $tag->name; 
     363                } 
     364        } elseif ( $single_tag ) { 
     365                $tag = &get_term($single_tag, 'post_tag', OBJECT, 'display'); 
     366                if ( is_wp_error($tag) || empty($tag->name) ) 
     367                        return false; 
     368                else 
     369                        $tags[] = $tag->name; 
     370        } else { 
     371                return; 
     372        } 
     373         
     374        if ( strlen($format) > 0 ) { 
     375                foreach ( $tags as $index => $tag ) 
     376                        $tags[$index] = sprintf($format, $tag); 
     377        } 
     378                         
     379        $tags = _implode_nicely($tags, __(', '), $connective); 
     380        $tags = apply_filters('multiple_tag_titles', $tags); 
     381        return $tags; 
     382} 
     383 
     384 
    334385function single_month_title($prefix = '', $display = true ) { 
    335386        global $wp_locale; 
    336387 
  • wp-content/themes/default/archive.php

     
    88          <?php /* If this is a category archive */ if (is_category()) { ?> 
    99                <h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2> 
    1010          <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?> 
    11                 <h2 class="pagetitle">Posts Tagged &#8216;<?php single_tag_title(); ?>&#8217;</h2> 
     11                <h2 class="pagetitle">Posts Tagged <?php echo multiple_tag_titles(); ?></h2> 
    1212          <?php /* If this is a daily archive */ } elseif (is_day()) { ?> 
    1313                <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2> 
    1414          <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>