Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: category-template.php
* 'current-cat' class. Default 0.
[500] Fix | Delete
* @type int $depth Category depth. Used for tab indentation. Default 0.
[501] Fix | Delete
* @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, or their
[502] Fix | Delete
* bool equivalents. Default 1.
[503] Fix | Delete
* @type int[]|string $exclude Array or comma/space-separated string of term IDs to exclude.
[504] Fix | Delete
* If `$hierarchical` is true, descendants of `$exclude` terms will also
[505] Fix | Delete
* be excluded; see `$exclude_tree`. See get_terms().
[506] Fix | Delete
* Default empty string.
[507] Fix | Delete
* @type int[]|string $exclude_tree Array or comma/space-separated string of term IDs to exclude, along
[508] Fix | Delete
* with their descendants. See get_terms(). Default empty string.
[509] Fix | Delete
* @type string $feed Text to use for the feed link. Default 'Feed for all posts filed
[510] Fix | Delete
* under [cat name]'.
[511] Fix | Delete
* @type string $feed_image URL of an image to use for the feed link. Default empty string.
[512] Fix | Delete
* @type string $feed_type Feed type. Used to build feed link. See get_term_feed_link().
[513] Fix | Delete
* Default empty string (default feed).
[514] Fix | Delete
* @type bool $hide_title_if_empty Whether to hide the `$title_li` element if there are no terms in
[515] Fix | Delete
* the list. Default false (title will always be shown).
[516] Fix | Delete
* @type string $separator Separator between links. Default '<br />'.
[517] Fix | Delete
* @type bool|int $show_count Whether to include post counts. Accepts 0, 1, or their bool equivalents.
[518] Fix | Delete
* Default 0.
[519] Fix | Delete
* @type string $show_option_all Text to display for showing all categories. Default empty string.
[520] Fix | Delete
* @type string $show_option_none Text to display for the 'no categories' option.
[521] Fix | Delete
* Default 'No categories'.
[522] Fix | Delete
* @type string $style The style used to display the categories list. If 'list', categories
[523] Fix | Delete
* will be output as an unordered list. If left empty or another value,
[524] Fix | Delete
* categories will be output separated by `<br>` tags. Default 'list'.
[525] Fix | Delete
* @type string $taxonomy Name of the taxonomy to retrieve. Default 'category'.
[526] Fix | Delete
* @type string $title_li Text to use for the list title `<li>` element. Pass an empty string
[527] Fix | Delete
* to disable. Default 'Categories'.
[528] Fix | Delete
* @type bool|int $use_desc_for_title Whether to use the category description as the title attribute.
[529] Fix | Delete
* Accepts 0, 1, or their bool equivalents. Default 0.
[530] Fix | Delete
* @type Walker $walker Walker object to use to build the output. Default empty which results
[531] Fix | Delete
* in a Walker_Category instance being used.
[532] Fix | Delete
* }
[533] Fix | Delete
* @return void|string|false Void if 'echo' argument is true, HTML list of categories if 'echo' is false.
[534] Fix | Delete
* False if the taxonomy does not exist.
[535] Fix | Delete
*/
[536] Fix | Delete
function wp_list_categories( $args = '' ) {
[537] Fix | Delete
$defaults = array(
[538] Fix | Delete
'child_of' => 0,
[539] Fix | Delete
'current_category' => 0,
[540] Fix | Delete
'depth' => 0,
[541] Fix | Delete
'echo' => 1,
[542] Fix | Delete
'exclude' => '',
[543] Fix | Delete
'exclude_tree' => '',
[544] Fix | Delete
'feed' => '',
[545] Fix | Delete
'feed_image' => '',
[546] Fix | Delete
'feed_type' => '',
[547] Fix | Delete
'hide_empty' => 1,
[548] Fix | Delete
'hide_title_if_empty' => false,
[549] Fix | Delete
'hierarchical' => true,
[550] Fix | Delete
'order' => 'ASC',
[551] Fix | Delete
'orderby' => 'name',
[552] Fix | Delete
'separator' => '<br />',
[553] Fix | Delete
'show_count' => 0,
[554] Fix | Delete
'show_option_all' => '',
[555] Fix | Delete
'show_option_none' => __( 'No categories' ),
[556] Fix | Delete
'style' => 'list',
[557] Fix | Delete
'taxonomy' => 'category',
[558] Fix | Delete
'title_li' => __( 'Categories' ),
[559] Fix | Delete
'use_desc_for_title' => 0,
[560] Fix | Delete
);
[561] Fix | Delete
[562] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[563] Fix | Delete
[564] Fix | Delete
if ( ! isset( $parsed_args['pad_counts'] ) && $parsed_args['show_count'] && $parsed_args['hierarchical'] ) {
[565] Fix | Delete
$parsed_args['pad_counts'] = true;
[566] Fix | Delete
}
[567] Fix | Delete
[568] Fix | Delete
// Descendants of exclusions should be excluded too.
[569] Fix | Delete
if ( $parsed_args['hierarchical'] ) {
[570] Fix | Delete
$exclude_tree = array();
[571] Fix | Delete
[572] Fix | Delete
if ( $parsed_args['exclude_tree'] ) {
[573] Fix | Delete
$exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $parsed_args['exclude_tree'] ) );
[574] Fix | Delete
}
[575] Fix | Delete
[576] Fix | Delete
if ( $parsed_args['exclude'] ) {
[577] Fix | Delete
$exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $parsed_args['exclude'] ) );
[578] Fix | Delete
}
[579] Fix | Delete
[580] Fix | Delete
$parsed_args['exclude_tree'] = $exclude_tree;
[581] Fix | Delete
$parsed_args['exclude'] = '';
[582] Fix | Delete
}
[583] Fix | Delete
[584] Fix | Delete
if ( ! isset( $parsed_args['class'] ) ) {
[585] Fix | Delete
$parsed_args['class'] = ( 'category' === $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy'];
[586] Fix | Delete
}
[587] Fix | Delete
[588] Fix | Delete
if ( ! taxonomy_exists( $parsed_args['taxonomy'] ) ) {
[589] Fix | Delete
return false;
[590] Fix | Delete
}
[591] Fix | Delete
[592] Fix | Delete
$show_option_all = $parsed_args['show_option_all'];
[593] Fix | Delete
$show_option_none = $parsed_args['show_option_none'];
[594] Fix | Delete
[595] Fix | Delete
$categories = get_categories( $parsed_args );
[596] Fix | Delete
[597] Fix | Delete
$output = '';
[598] Fix | Delete
[599] Fix | Delete
if ( $parsed_args['title_li'] && 'list' === $parsed_args['style']
[600] Fix | Delete
&& ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] )
[601] Fix | Delete
) {
[602] Fix | Delete
$output = '<li class="' . esc_attr( $parsed_args['class'] ) . '">' . $parsed_args['title_li'] . '<ul>';
[603] Fix | Delete
}
[604] Fix | Delete
[605] Fix | Delete
if ( empty( $categories ) ) {
[606] Fix | Delete
if ( ! empty( $show_option_none ) ) {
[607] Fix | Delete
if ( 'list' === $parsed_args['style'] ) {
[608] Fix | Delete
$output .= '<li class="cat-item-none">' . $show_option_none . '</li>';
[609] Fix | Delete
} else {
[610] Fix | Delete
$output .= $show_option_none;
[611] Fix | Delete
}
[612] Fix | Delete
}
[613] Fix | Delete
} else {
[614] Fix | Delete
if ( ! empty( $show_option_all ) ) {
[615] Fix | Delete
[616] Fix | Delete
$posts_page = '';
[617] Fix | Delete
[618] Fix | Delete
// For taxonomies that belong only to custom post types, point to a valid archive.
[619] Fix | Delete
$taxonomy_object = get_taxonomy( $parsed_args['taxonomy'] );
[620] Fix | Delete
if ( ! in_array( 'post', $taxonomy_object->object_type, true ) && ! in_array( 'page', $taxonomy_object->object_type, true ) ) {
[621] Fix | Delete
foreach ( $taxonomy_object->object_type as $object_type ) {
[622] Fix | Delete
$_object_type = get_post_type_object( $object_type );
[623] Fix | Delete
[624] Fix | Delete
// Grab the first one.
[625] Fix | Delete
if ( ! empty( $_object_type->has_archive ) ) {
[626] Fix | Delete
$posts_page = get_post_type_archive_link( $object_type );
[627] Fix | Delete
break;
[628] Fix | Delete
}
[629] Fix | Delete
}
[630] Fix | Delete
}
[631] Fix | Delete
[632] Fix | Delete
// Fallback for the 'All' link is the posts page.
[633] Fix | Delete
if ( ! $posts_page ) {
[634] Fix | Delete
if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) {
[635] Fix | Delete
$posts_page = get_permalink( get_option( 'page_for_posts' ) );
[636] Fix | Delete
} else {
[637] Fix | Delete
$posts_page = home_url( '/' );
[638] Fix | Delete
}
[639] Fix | Delete
}
[640] Fix | Delete
[641] Fix | Delete
$posts_page = esc_url( $posts_page );
[642] Fix | Delete
if ( 'list' === $parsed_args['style'] ) {
[643] Fix | Delete
$output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>";
[644] Fix | Delete
} else {
[645] Fix | Delete
$output .= "<a href='$posts_page'>$show_option_all</a>";
[646] Fix | Delete
}
[647] Fix | Delete
}
[648] Fix | Delete
[649] Fix | Delete
if ( empty( $parsed_args['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
[650] Fix | Delete
$current_term_object = get_queried_object();
[651] Fix | Delete
if ( $current_term_object && $parsed_args['taxonomy'] === $current_term_object->taxonomy ) {
[652] Fix | Delete
$parsed_args['current_category'] = get_queried_object_id();
[653] Fix | Delete
}
[654] Fix | Delete
}
[655] Fix | Delete
[656] Fix | Delete
if ( $parsed_args['hierarchical'] ) {
[657] Fix | Delete
$depth = $parsed_args['depth'];
[658] Fix | Delete
} else {
[659] Fix | Delete
$depth = -1; // Flat.
[660] Fix | Delete
}
[661] Fix | Delete
$output .= walk_category_tree( $categories, $depth, $parsed_args );
[662] Fix | Delete
}
[663] Fix | Delete
[664] Fix | Delete
if ( $parsed_args['title_li'] && 'list' === $parsed_args['style']
[665] Fix | Delete
&& ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] )
[666] Fix | Delete
) {
[667] Fix | Delete
$output .= '</ul></li>';
[668] Fix | Delete
}
[669] Fix | Delete
[670] Fix | Delete
/**
[671] Fix | Delete
* Filters the HTML output of a taxonomy list.
[672] Fix | Delete
*
[673] Fix | Delete
* @since 2.1.0
[674] Fix | Delete
*
[675] Fix | Delete
* @param string $output HTML output.
[676] Fix | Delete
* @param array|string $args An array or query string of taxonomy-listing arguments. See
[677] Fix | Delete
* wp_list_categories() for information on accepted arguments.
[678] Fix | Delete
*/
[679] Fix | Delete
$html = apply_filters( 'wp_list_categories', $output, $args );
[680] Fix | Delete
[681] Fix | Delete
if ( $parsed_args['echo'] ) {
[682] Fix | Delete
echo $html;
[683] Fix | Delete
} else {
[684] Fix | Delete
return $html;
[685] Fix | Delete
}
[686] Fix | Delete
}
[687] Fix | Delete
[688] Fix | Delete
/**
[689] Fix | Delete
* Displays a tag cloud.
[690] Fix | Delete
*
[691] Fix | Delete
* Outputs a list of tags in what is called a 'tag cloud', where the size of each tag
[692] Fix | Delete
* is determined by how many times that particular tag has been assigned to posts.
[693] Fix | Delete
*
[694] Fix | Delete
* @since 2.3.0
[695] Fix | Delete
* @since 2.8.0 Added the `taxonomy` argument.
[696] Fix | Delete
* @since 4.8.0 Added the `show_count` argument.
[697] Fix | Delete
*
[698] Fix | Delete
* @param array|string $args {
[699] Fix | Delete
* Optional. Array or string of arguments for displaying a tag cloud. See wp_generate_tag_cloud()
[700] Fix | Delete
* and get_terms() for the full lists of arguments that can be passed in `$args`.
[701] Fix | Delete
*
[702] Fix | Delete
* @type int $number The number of tags to display. Accepts any positive integer
[703] Fix | Delete
* or zero to return all. Default 45.
[704] Fix | Delete
* @type string $link Whether to display term editing links or term permalinks.
[705] Fix | Delete
* Accepts 'edit' and 'view'. Default 'view'.
[706] Fix | Delete
* @type string $post_type The post type. Used to highlight the proper post type menu
[707] Fix | Delete
* on the linked edit page. Defaults to the first post type
[708] Fix | Delete
* associated with the taxonomy.
[709] Fix | Delete
* @type bool $echo Whether or not to echo the return value. Default true.
[710] Fix | Delete
* }
[711] Fix | Delete
* @return void|string|string[] Void if 'echo' argument is true, or on failure. Otherwise, tag cloud
[712] Fix | Delete
* as a string or an array, depending on 'format' argument.
[713] Fix | Delete
*/
[714] Fix | Delete
function wp_tag_cloud( $args = '' ) {
[715] Fix | Delete
$defaults = array(
[716] Fix | Delete
'smallest' => 8,
[717] Fix | Delete
'largest' => 22,
[718] Fix | Delete
'unit' => 'pt',
[719] Fix | Delete
'number' => 45,
[720] Fix | Delete
'format' => 'flat',
[721] Fix | Delete
'separator' => "\n",
[722] Fix | Delete
'orderby' => 'name',
[723] Fix | Delete
'order' => 'ASC',
[724] Fix | Delete
'exclude' => '',
[725] Fix | Delete
'include' => '',
[726] Fix | Delete
'link' => 'view',
[727] Fix | Delete
'taxonomy' => 'post_tag',
[728] Fix | Delete
'post_type' => '',
[729] Fix | Delete
'echo' => true,
[730] Fix | Delete
'show_count' => 0,
[731] Fix | Delete
);
[732] Fix | Delete
[733] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[734] Fix | Delete
[735] Fix | Delete
$tags = get_terms(
[736] Fix | Delete
array_merge(
[737] Fix | Delete
$args,
[738] Fix | Delete
array(
[739] Fix | Delete
'orderby' => 'count',
[740] Fix | Delete
'order' => 'DESC',
[741] Fix | Delete
)
[742] Fix | Delete
)
[743] Fix | Delete
); // Always query top tags.
[744] Fix | Delete
[745] Fix | Delete
if ( empty( $tags ) || is_wp_error( $tags ) ) {
[746] Fix | Delete
return;
[747] Fix | Delete
}
[748] Fix | Delete
[749] Fix | Delete
foreach ( $tags as $key => $tag ) {
[750] Fix | Delete
if ( 'edit' === $args['link'] ) {
[751] Fix | Delete
$link = get_edit_term_link( $tag, $tag->taxonomy, $args['post_type'] );
[752] Fix | Delete
} else {
[753] Fix | Delete
$link = get_term_link( $tag, $tag->taxonomy );
[754] Fix | Delete
}
[755] Fix | Delete
[756] Fix | Delete
if ( is_wp_error( $link ) ) {
[757] Fix | Delete
return;
[758] Fix | Delete
}
[759] Fix | Delete
[760] Fix | Delete
$tags[ $key ]->link = $link;
[761] Fix | Delete
$tags[ $key ]->id = $tag->term_id;
[762] Fix | Delete
}
[763] Fix | Delete
[764] Fix | Delete
// Here's where those top tags get sorted according to $args.
[765] Fix | Delete
$return = wp_generate_tag_cloud( $tags, $args );
[766] Fix | Delete
[767] Fix | Delete
/**
[768] Fix | Delete
* Filters the tag cloud output.
[769] Fix | Delete
*
[770] Fix | Delete
* @since 2.3.0
[771] Fix | Delete
*
[772] Fix | Delete
* @param string|string[] $return Tag cloud as a string or an array, depending on 'format' argument.
[773] Fix | Delete
* @param array $args An array of tag cloud arguments. See wp_tag_cloud()
[774] Fix | Delete
* for information on accepted arguments.
[775] Fix | Delete
*/
[776] Fix | Delete
$return = apply_filters( 'wp_tag_cloud', $return, $args );
[777] Fix | Delete
[778] Fix | Delete
if ( 'array' === $args['format'] || empty( $args['echo'] ) ) {
[779] Fix | Delete
return $return;
[780] Fix | Delete
}
[781] Fix | Delete
[782] Fix | Delete
echo $return;
[783] Fix | Delete
}
[784] Fix | Delete
[785] Fix | Delete
/**
[786] Fix | Delete
* Default topic count scaling for tag links.
[787] Fix | Delete
*
[788] Fix | Delete
* @since 2.9.0
[789] Fix | Delete
*
[790] Fix | Delete
* @param int $count Number of posts with that tag.
[791] Fix | Delete
* @return int Scaled count.
[792] Fix | Delete
*/
[793] Fix | Delete
function default_topic_count_scale( $count ) {
[794] Fix | Delete
return round( log10( $count + 1 ) * 100 );
[795] Fix | Delete
}
[796] Fix | Delete
[797] Fix | Delete
/**
[798] Fix | Delete
* Generates a tag cloud (heatmap) from provided data.
[799] Fix | Delete
*
[800] Fix | Delete
* @todo Complete functionality.
[801] Fix | Delete
* @since 2.3.0
[802] Fix | Delete
* @since 4.8.0 Added the `show_count` argument.
[803] Fix | Delete
*
[804] Fix | Delete
* @param WP_Term[] $tags Array of WP_Term objects to generate the tag cloud for.
[805] Fix | Delete
* @param string|array $args {
[806] Fix | Delete
* Optional. Array or string of arguments for generating a tag cloud.
[807] Fix | Delete
*
[808] Fix | Delete
* @type int $smallest Smallest font size used to display tags. Paired
[809] Fix | Delete
* with the value of `$unit`, to determine CSS text
[810] Fix | Delete
* size unit. Default 8 (pt).
[811] Fix | Delete
* @type int $largest Largest font size used to display tags. Paired
[812] Fix | Delete
* with the value of `$unit`, to determine CSS text
[813] Fix | Delete
* size unit. Default 22 (pt).
[814] Fix | Delete
* @type string $unit CSS text size unit to use with the `$smallest`
[815] Fix | Delete
* and `$largest` values. Accepts any valid CSS text
[816] Fix | Delete
* size unit. Default 'pt'.
[817] Fix | Delete
* @type int $number The number of tags to return. Accepts any
[818] Fix | Delete
* positive integer or zero to return all.
[819] Fix | Delete
* Default 0.
[820] Fix | Delete
* @type string $format Format to display the tag cloud in. Accepts 'flat'
[821] Fix | Delete
* (tags separated with spaces), 'list' (tags displayed
[822] Fix | Delete
* in an unordered list), or 'array' (returns an array).
[823] Fix | Delete
* Default 'flat'.
[824] Fix | Delete
* @type string $separator HTML or text to separate the tags. Default "\n" (newline).
[825] Fix | Delete
* @type string $orderby Value to order tags by. Accepts 'name' or 'count'.
[826] Fix | Delete
* Default 'name'. The {@see 'tag_cloud_sort'} filter
[827] Fix | Delete
* can also affect how tags are sorted.
[828] Fix | Delete
* @type string $order How to order the tags. Accepts 'ASC' (ascending),
[829] Fix | Delete
* 'DESC' (descending), or 'RAND' (random). Default 'ASC'.
[830] Fix | Delete
* @type int|bool $filter Whether to enable filtering of the final output
[831] Fix | Delete
* via {@see 'wp_generate_tag_cloud'}. Default 1.
[832] Fix | Delete
* @type array $topic_count_text Nooped plural text from _n_noop() to supply to
[833] Fix | Delete
* tag counts. Default null.
[834] Fix | Delete
* @type callable $topic_count_text_callback Callback used to generate nooped plural text for
[835] Fix | Delete
* tag counts based on the count. Default null.
[836] Fix | Delete
* @type callable $topic_count_scale_callback Callback used to determine the tag count scaling
[837] Fix | Delete
* value. Default default_topic_count_scale().
[838] Fix | Delete
* @type bool|int $show_count Whether to display the tag counts. Default 0. Accepts
[839] Fix | Delete
* 0, 1, or their bool equivalents.
[840] Fix | Delete
* }
[841] Fix | Delete
* @return string|string[] Tag cloud as a string or an array, depending on 'format' argument.
[842] Fix | Delete
*/
[843] Fix | Delete
function wp_generate_tag_cloud( $tags, $args = '' ) {
[844] Fix | Delete
$defaults = array(
[845] Fix | Delete
'smallest' => 8,
[846] Fix | Delete
'largest' => 22,
[847] Fix | Delete
'unit' => 'pt',
[848] Fix | Delete
'number' => 0,
[849] Fix | Delete
'format' => 'flat',
[850] Fix | Delete
'separator' => "\n",
[851] Fix | Delete
'orderby' => 'name',
[852] Fix | Delete
'order' => 'ASC',
[853] Fix | Delete
'topic_count_text' => null,
[854] Fix | Delete
'topic_count_text_callback' => null,
[855] Fix | Delete
'topic_count_scale_callback' => 'default_topic_count_scale',
[856] Fix | Delete
'filter' => 1,
[857] Fix | Delete
'show_count' => 0,
[858] Fix | Delete
);
[859] Fix | Delete
[860] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[861] Fix | Delete
[862] Fix | Delete
$return = ( 'array' === $args['format'] ) ? array() : '';
[863] Fix | Delete
[864] Fix | Delete
if ( empty( $tags ) ) {
[865] Fix | Delete
return $return;
[866] Fix | Delete
}
[867] Fix | Delete
[868] Fix | Delete
// Juggle topic counts.
[869] Fix | Delete
if ( isset( $args['topic_count_text'] ) ) {
[870] Fix | Delete
// First look for nooped plural support via topic_count_text.
[871] Fix | Delete
$translate_nooped_plural = $args['topic_count_text'];
[872] Fix | Delete
} elseif ( ! empty( $args['topic_count_text_callback'] ) ) {
[873] Fix | Delete
// Look for the alternative callback style. Ignore the previous default.
[874] Fix | Delete
if ( 'default_topic_count_text' === $args['topic_count_text_callback'] ) {
[875] Fix | Delete
/* translators: %s: Number of items (tags). */
[876] Fix | Delete
$translate_nooped_plural = _n_noop( '%s item', '%s items' );
[877] Fix | Delete
} else {
[878] Fix | Delete
$translate_nooped_plural = false;
[879] Fix | Delete
}
[880] Fix | Delete
} elseif ( isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
[881] Fix | Delete
// If no callback exists, look for the old-style single_text and multiple_text arguments.
[882] Fix | Delete
// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingular,WordPress.WP.I18n.NonSingularStringLiteralPlural
[883] Fix | Delete
$translate_nooped_plural = _n_noop( $args['single_text'], $args['multiple_text'] );
[884] Fix | Delete
} else {
[885] Fix | Delete
// This is the default for when no callback, plural, or argument is passed in.
[886] Fix | Delete
/* translators: %s: Number of items (tags). */
[887] Fix | Delete
$translate_nooped_plural = _n_noop( '%s item', '%s items' );
[888] Fix | Delete
}
[889] Fix | Delete
[890] Fix | Delete
/**
[891] Fix | Delete
* Filters how the items in a tag cloud are sorted.
[892] Fix | Delete
*
[893] Fix | Delete
* @since 2.8.0
[894] Fix | Delete
*
[895] Fix | Delete
* @param WP_Term[] $tags Ordered array of terms.
[896] Fix | Delete
* @param array $args An array of tag cloud arguments.
[897] Fix | Delete
*/
[898] Fix | Delete
$tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );
[899] Fix | Delete
if ( empty( $tags_sorted ) ) {
[900] Fix | Delete
return $return;
[901] Fix | Delete
}
[902] Fix | Delete
[903] Fix | Delete
if ( $tags_sorted !== $tags ) {
[904] Fix | Delete
$tags = $tags_sorted;
[905] Fix | Delete
unset( $tags_sorted );
[906] Fix | Delete
} else {
[907] Fix | Delete
if ( 'RAND' === $args['order'] ) {
[908] Fix | Delete
shuffle( $tags );
[909] Fix | Delete
} else {
[910] Fix | Delete
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
[911] Fix | Delete
if ( 'name' === $args['orderby'] ) {
[912] Fix | Delete
uasort( $tags, '_wp_object_name_sort_cb' );
[913] Fix | Delete
} else {
[914] Fix | Delete
uasort( $tags, '_wp_object_count_sort_cb' );
[915] Fix | Delete
}
[916] Fix | Delete
[917] Fix | Delete
if ( 'DESC' === $args['order'] ) {
[918] Fix | Delete
$tags = array_reverse( $tags, true );
[919] Fix | Delete
}
[920] Fix | Delete
}
[921] Fix | Delete
}
[922] Fix | Delete
[923] Fix | Delete
if ( $args['number'] > 0 ) {
[924] Fix | Delete
$tags = array_slice( $tags, 0, $args['number'] );
[925] Fix | Delete
}
[926] Fix | Delete
[927] Fix | Delete
$counts = array();
[928] Fix | Delete
$real_counts = array(); // For the alt tag.
[929] Fix | Delete
foreach ( (array) $tags as $key => $tag ) {
[930] Fix | Delete
$real_counts[ $key ] = $tag->count;
[931] Fix | Delete
$counts[ $key ] = call_user_func( $args['topic_count_scale_callback'], $tag->count );
[932] Fix | Delete
}
[933] Fix | Delete
[934] Fix | Delete
$min_count = min( $counts );
[935] Fix | Delete
$spread = max( $counts ) - $min_count;
[936] Fix | Delete
if ( $spread <= 0 ) {
[937] Fix | Delete
$spread = 1;
[938] Fix | Delete
}
[939] Fix | Delete
$font_spread = $args['largest'] - $args['smallest'];
[940] Fix | Delete
if ( $font_spread < 0 ) {
[941] Fix | Delete
$font_spread = 1;
[942] Fix | Delete
}
[943] Fix | Delete
$font_step = $font_spread / $spread;
[944] Fix | Delete
[945] Fix | Delete
$aria_label = false;
[946] Fix | Delete
/*
[947] Fix | Delete
* Determine whether to output an 'aria-label' attribute with the tag name and count.
[948] Fix | Delete
* When tags have a different font size, they visually convey an important information
[949] Fix | Delete
* that should be available to assistive technologies too. On the other hand, sometimes
[950] Fix | Delete
* themes set up the Tag Cloud to display all tags with the same font size (setting
[951] Fix | Delete
* the 'smallest' and 'largest' arguments to the same value).
[952] Fix | Delete
* In order to always serve the same content to all users, the 'aria-label' gets printed out:
[953] Fix | Delete
* - when tags have a different size
[954] Fix | Delete
* - when the tag count is displayed (for example when users check the checkbox in the
[955] Fix | Delete
* Tag Cloud widget), regardless of the tags font size
[956] Fix | Delete
*/
[957] Fix | Delete
if ( $args['show_count'] || 0 !== $font_spread ) {
[958] Fix | Delete
$aria_label = true;
[959] Fix | Delete
}
[960] Fix | Delete
[961] Fix | Delete
// Assemble the data that will be used to generate the tag cloud markup.
[962] Fix | Delete
$tags_data = array();
[963] Fix | Delete
foreach ( $tags as $key => $tag ) {
[964] Fix | Delete
$tag_id = isset( $tag->id ) ? $tag->id : $key;
[965] Fix | Delete
[966] Fix | Delete
$count = $counts[ $key ];
[967] Fix | Delete
$real_count = $real_counts[ $key ];
[968] Fix | Delete
[969] Fix | Delete
if ( $translate_nooped_plural ) {
[970] Fix | Delete
$formatted_count = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) );
[971] Fix | Delete
} else {
[972] Fix | Delete
$formatted_count = call_user_func( $args['topic_count_text_callback'], $real_count, $tag, $args );
[973] Fix | Delete
}
[974] Fix | Delete
[975] Fix | Delete
$tags_data[] = array(
[976] Fix | Delete
'id' => $tag_id,
[977] Fix | Delete
'url' => ( '#' !== $tag->link ) ? $tag->link : '#',
[978] Fix | Delete
'role' => ( '#' !== $tag->link ) ? '' : ' role="button"',
[979] Fix | Delete
'name' => $tag->name,
[980] Fix | Delete
'formatted_count' => $formatted_count,
[981] Fix | Delete
'slug' => $tag->slug,
[982] Fix | Delete
'real_count' => $real_count,
[983] Fix | Delete
'class' => 'tag-cloud-link tag-link-' . $tag_id,
[984] Fix | Delete
'font_size' => $args['smallest'] + ( $count - $min_count ) * $font_step,
[985] Fix | Delete
'aria_label' => $aria_label ? sprintf( ' aria-label="%1$s (%2$s)"', esc_attr( $tag->name ), esc_attr( $formatted_count ) ) : '',
[986] Fix | Delete
'show_count' => $args['show_count'] ? '<span class="tag-link-count"> (' . $real_count . ')</span>' : '',
[987] Fix | Delete
);
[988] Fix | Delete
}
[989] Fix | Delete
[990] Fix | Delete
/**
[991] Fix | Delete
* Filters the data used to generate the tag cloud.
[992] Fix | Delete
*
[993] Fix | Delete
* @since 4.3.0
[994] Fix | Delete
*
[995] Fix | Delete
* @param array[] $tags_data An array of term data arrays for terms used to generate the tag cloud.
[996] Fix | Delete
*/
[997] Fix | Delete
$tags_data = apply_filters( 'wp_generate_tag_cloud_data', $tags_data );
[998] Fix | Delete
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function