Changeset 27376 for trunk/src/wp-includes/category-template.php
- Timestamp:
- 03/03/2014 05:28:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/category-template.php
r27373 r27376 516 516 * be to return the top 45 tags in the tag cloud list. 517 517 * 518 * The 'topic_count_text_callback' argument is a function, which, given the count 519 * of the posts with that tag, returns a text for the tooltip of the tag link. 518 * The 'topic_count_text' argument is a nooped plural from _n_noop() to generate the 519 * text for the tooltip of the tag link. 520 * 521 * The 'topic_count_text_callback' argument is a function, which given the count 522 * of the posts with that tag returns a text for the tooltip of the tag link. 520 523 * 521 524 * The 'exclude' and 'include' arguments are used for the {@link get_tags()} … … 564 567 565 568 /** 566 * Default text for tooltip for tag links567 *568 * @param integer $count number of posts with that tag569 * @return string text for the tooltip of a tag link.570 */571 function default_topic_count_text( $count ) {572 return sprintf( _n('%s topic', '%s topics', $count), number_format_i18n( $count ) );573 }574 575 /**576 569 * Default topic count scaling for tag links 577 570 * … … 604 597 * be to return the entire tag cloud list. 605 598 * 599 * The 'topic_count_text' argument is a nooped plural from _n_noop() to generate the 600 * text for the tooltip of the tag link. 601 * 606 602 * The 'topic_count_text_callback' argument is a function, which given the count 607 * of the posts 603 * of the posts with that tag returns a text for the tooltip of the tag link. 608 604 * 609 605 * @todo Complete functionality. … … 618 614 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0, 619 615 'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC', 620 'topic_count_text _callback' => 'default_topic_count_text',616 'topic_count_text' => null, 'topic_count_text_callback' => null, 621 617 'topic_count_scale_callback' => 'default_topic_count_scale', 'filter' => 1, 622 618 ); 623 619 624 if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {625 $args['topic_count_text_callback'] = '_plugin_topic_count';626 }627 628 620 $args = wp_parse_args( $args, $defaults ); 629 extract( $args );621 extract( $args, EXTR_SKIP ); 630 622 631 623 if ( empty( $tags ) ) 632 624 return; 625 626 // Juggle topic count tooltips: 627 if ( isset( $args['topic_count_text'] ) ) { 628 // First look for nooped plural support via topic_count_text. 629 $translate_nooped_plural = $args['topic_count_text']; 630 } elseif ( ! empty( $args['topic_count_text_callback'] ) ) { 631 // Look for the alternative callback style. Ignore the previous default. 632 if ( $args['topic_count_text_callback'] === 'default_topic_count_text' ) { 633 $translate_nooped_plural = _n_noop( '%s topic', '%s topics' ); 634 } else { 635 $translate_nooped_plural = false; 636 } 637 } elseif ( isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) { 638 // If no callback exists, look for the old-style single_text and multiple_text arguments. 639 $translate_nooped_plural = _n_noop( $args['single_text'], $args['multiple_text'] ); 640 } else { 641 // This is the default for when no callback, plural, or argument is passed in. 642 $translate_nooped_plural = _n_noop( '%s topic', '%s topics' ); 643 } 633 644 634 645 $tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args ); … … 678 689 $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; 679 690 $tag_name = $tags[ $key ]->name; 680 $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( call_user_func( $topic_count_text_callback, $real_count, $tag, $args ) ) . "' style='font-size: " . 691 692 if ( $translate_nooped_plural ) { 693 $title_attribute = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) ); 694 } else { 695 $title_attribute = call_user_func( $topic_count_text_callback, $real_count, $tag, $args ); 696 } 697 698 $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $title_attribute ) . "' style='font-size: " . 681 699 str_replace( ',', '.', ( $smallest + ( ( $count - $min_count ) * $font_step ) ) ) 682 700 . "$unit;'>$tag_name</a>"; … … 721 739 function _wp_object_count_sort_cb( $a, $b ) { 722 740 return ( $a->count > $b->count ); 723 }724 725 /**726 * Default text for tooltip for tag links727 *728 * @since 3.9.0729 * @access private730 *731 * @param integer $count Number of posts with that tag.732 * @param object $tag Tag object.733 * @param array $args Arguments for the tag cloud.734 * @return string Text for the tooltip of a tag link.735 */736 function _plugin_topic_count( $count, $tag, $args ) {737 return sprintf( 1 == $count? $args['single_text'] : $args['multiple_text'], number_format_i18n( $count ) );738 741 } 739 742
Note: See TracChangeset
for help on using the changeset viewer.