wp_ajax_get_tagcloud()
Ajax handler for getting a tagcloud.
Description Description
Source Source
File: wp-admin/includes/ajax-actions.php
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 | 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(); } |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |