wp_ajax_get_tagcloud() - WordPress 函数参考中文文档

返回介绍

wp_ajax_get_tagcloud()

发布于 2017-09-11 字数1885 浏览 853 评论 0

wp_ajax_get_tagcloud()

Ajax handler for getting a tagcloud.


描述


源代码

File: wp-admin/includes/ajax-actions.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) );

	if ( empty($return) )
		wp_die( 0 );

	echo $return;

	wp_die();
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-includes/capabilities.php:
    current_user_can()
  • wp-includes/category-template.php:
    wp_generate_tag_cloud()
  • wp-includes/formatting.php:
    sanitize_key()
  • wp-includes/functions.php:
    wp_die()
  • wp-includes/taxonomy.php:
    get_terms()
  • wp-includes/taxonomy.php:
    get_taxonomy()
  • wp-includes/load.php:
    is_wp_error()
  • Show 2 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!