用于获取tagcloud的Ajax处理程序。

原型

wp_ajax_get_tagcloud()

源文件

路径:wp-admin/includes/ajax-actions.php

<?php
...
function wp_ajax_get_tagcloud() {
	if ( ! isset( $_POST['tax'] ) ) {
		wp_die( 0 );
	}
	$taxonomy = sanitize_key( $_POST['tax'] );
	$tax = get_taxonomy( $taxonomy );
	if ( ! $tax ) {
		wp_die( 0 );
	}
	if ( ! current_user_can( $tax->cap->assign_terms ) ) {
		wp_die( -1 );
	}
	$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
	if ( empty( $tags ) )
		wp_die( $tax->labels->not_found );
	if ( is_wp_error( $tags ) )
		wp_die( $tags->get_error_message() );
	foreach ( $tags as $key => $tag ) {
		$tags[ $key ]->link = '#';
		$tags[ $key ]->id = $tag->term_id;
	}
	// We need raw tag names here, so don't filter the output
	$return = wp_generate_tag_cloud( $tags, array( 'filter' => 0, 'format' => 'list' ) );
	if ( empty($return) )
		wp_die( 0 );
	echo $return;
	wp_die();
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_ajax_get_tagcloud/