本文整理汇总了PHP中wp_generate_tag_cloud函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_generate_tag_cloud函数的具体用法?PHP wp_generate_tag_cloud怎么用?PHP wp_generate_tag_cloud使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_generate_tag_cloud函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_tag_cloud
function generate_tag_cloud($post_type)
{
global $wpdb;
// database calls must be sensitive to multisite
$query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", $post_type);
$attachment_ids = $wpdb->get_col($query);
$terms = wp_get_object_terms($attachment_ids, 'post_tag', array('orderby' => 'count', 'order' => 'DESC'));
$tags = array();
// limit to 45 tags
foreach ($terms as $term) {
$tags[$term->term_id] = $term;
if (count($tags) >= 45) {
break;
}
}
if (empty($tags)) {
die(__('No tags found!', THEMEDOMAIN));
}
if (is_wp_error($tags)) {
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)) {
die('0');
}
echo $return;
exit;
}
示例2: index_action
/**
* Displays the 'tagcloud' display type
*
* @param stdClass|C_Displayed_Gallery|C_DataMapper_Model $displayed_gallery
*/
function index_action($displayed_gallery, $return = FALSE)
{
$display_settings = $displayed_gallery->display_settings;
$application = $this->object->get_registry()->get_utility('I_Router')->get_routed_app();
$tag = $this->param('gallerytag');
// we're looking at a tag, so show images w/that tag as a thumbnail gallery
if (!is_home() && !empty($tag)) {
return $this->object->get_registry()->get_utility('I_Displayed_Gallery_Renderer')->display_images(array('source' => 'tags', 'container_ids' => array(esc_attr($tag)), 'display_type' => $display_settings['display_type'], 'original_display_type' => $displayed_gallery->display_type, 'original_settings' => $display_settings));
}
$defaults = array('exclude' => '', 'format' => 'list', 'include' => $displayed_gallery->get_term_ids_for_tags(), 'largest' => 22, 'link' => 'view', 'number' => $display_settings['number'], 'order' => 'ASC', 'orderby' => 'name', 'smallest' => 8, 'taxonomy' => 'ngg_tag', 'unit' => 'pt');
$args = wp_parse_args('', $defaults);
// Always query top tags
$tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC')));
foreach ($tags as $key => $tag) {
$tags[$key]->link = $this->object->set_param_for($application->get_routed_url(TRUE), 'gallerytag', $tag->slug);
$tags[$key]->id = $tag->term_id;
}
$params = $display_settings;
$params['inner_content'] = $displayed_gallery->inner_content;
$params['storage'] =& $storage;
$params['tagcloud'] = wp_generate_tag_cloud($tags, $args);
$params['displayed_gallery_id'] = $displayed_gallery->id();
$params = $this->object->prepare_display_parameters($displayed_gallery, $params);
return $this->object->render_partial('photocrati-nextgen_basic_tagcloud#nextgen_basic_tagcloud', $params, $return);
}
示例3: test_topic_count_text_callback
public function test_topic_count_text_callback()
{
register_taxonomy('wptests_tax', 'post');
$terms = $this->factory->term->create_many(2, array('taxonomy' => 'wptests_tax'));
$posts = $this->factory->post->create_many(2);
wp_set_post_terms($posts[0], $terms, 'wptests_tax');
wp_set_post_terms($posts[1], array($terms[1]), 'wptests_tax');
$term_objects = $this->retrieve_terms(array('include' => $terms), 'wptests_tax');
$actual = wp_generate_tag_cloud($term_objects, array('format' => 'array', 'topic_count_text_callback' => array($this, 'topic_count_text_callback')));
$this->assertContains("title='1 foo'", $actual[0]);
$this->assertContains("title='2 foo'", $actual[1]);
}
示例4: die
} else {
die('0');
}
$tags = get_terms($taxonomy, array('number' => 45, 'orderby' => 'count', 'order' => 'DESC'));
if (empty($tags)) {
die(__('No tags found!'));
}
if (is_wp_error($tags)) {
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)) {
die('0');
}
echo $return;
exit;
break;
case 'add-comment':
check_ajax_referer($action);
if (!current_user_can('edit_posts')) {
die('-1');
}
$search = isset($_POST['s']) ? $_POST['s'] : false;
$status = isset($_POST['comment_status']) ? $_POST['comment_status'] : 'all';
$per_page = isset($_POST['per_page']) ? (int) $_POST['per_page'] + 8 : 28;
$start = isset($_POST['page']) ? intval($_POST['page']) * $per_page - 1 : $per_page - 1;
示例5: wp_generate_tag_cloud
<div id="download-page-tags" class="download_group">
<h3>Taggar</h3>
<div class="download_tags">
<?php
echo wp_generate_tag_cloud($tags);
?>
</div>
</div>
示例6: install_dashboard
function install_dashboard()
{
?>
<p><?php
printf(__('Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> or upload a plugin in .zip format via <a href="%s">this page</a>.'), self_admin_url('plugin-install.php?tab=upload'));
?>
</p>
<h4><?php
_e('Search');
?>
</h4>
<?php
install_search_form(false);
?>
<h4><?php
_e('Popular tags');
?>
</h4>
<p class="install-help"><?php
_e('You may also browse based on the most popular tags in the Plugin Directory:');
?>
</p>
<?php
$api_tags = install_popular_tags();
echo '<p class="popular-tags">';
if (is_wp_error($api_tags)) {
echo $api_tags->get_error_message();
} else {
//Set up the tags in a way which can be interpreted by wp_generate_tag_cloud()
$tags = array();
foreach ((array) $api_tags as $tag) {
$tags[$tag['name']] = (object) array('link' => esc_url(self_admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name']))), 'name' => $tag['name'], 'id' => sanitize_title_with_dashes($tag['name']), 'count' => $tag['count']);
}
echo wp_generate_tag_cloud($tags, array('single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins')));
}
echo '</p><br class="clear" />';
}
示例7: nggTagCloud
/**
* nggTagCloud() - return a tag cloud based on the wp core tag cloud system
*
* @param array $args
* @param string $template (optional) name for a template file, look for gallery-$template
* @return the content
*/
function nggTagCloud($args = '', $template = '')
{
global $nggRewrite;
// $_GET from wp_query
$tag = get_query_var('gallerytag');
$pageid = get_query_var('pageid');
// look for gallerytag variable
if ($pageid == get_the_ID() || !is_home()) {
if (!empty($tag)) {
$slug = esc_attr($tag);
$out = nggShowGalleryTags($slug);
return $out;
}
}
$defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'ngg_tag');
$args = wp_parse_args($args, $defaults);
$tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC')));
// Always query top tags
foreach ($tags as $key => $tag) {
$tags[$key]->link = $nggRewrite->get_permalink(array('gallerytag' => $tag->slug));
$tags[$key]->id = $tag->term_id;
}
$out = '<div class="ngg-tagcloud">' . wp_generate_tag_cloud($tags, $args) . '</div>';
return $out;
}
示例8: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
echo '<div class="gtags gtags-widget">';
echo wp_generate_tag_cloud(gtags_make_tags(null, $instance['exclude'], $instance['include']), gtags_cloud_args());
echo '</div>';
echo $after_widget;
}
示例9: test_should_include_tag_link_position_class
/**
* @ticket 5172
*/
public function test_should_include_tag_link_position_class()
{
register_taxonomy('wptests_tax', 'post');
$term_ids = self::factory()->term->create_many(3, array('taxonomy' => 'wptests_tax'));
$p = self::factory()->post->create();
wp_set_post_terms($p, $term_ids, 'wptests_tax');
$term_objects = get_terms('wptests_tax', array('include' => $term_ids));
$cloud = wp_generate_tag_cloud($term_objects);
preg_match_all('|tag\\-link\\-position-([0-9]+)|', $cloud, $matches);
$this->assertSame(array(1, 2, 3), array_map('intval', $matches[1]));
}
示例10: widget
function widget($args, $instance)
{
global $site_categories, $current_site;
$site_categories->load_config();
extract($args);
$data = get_site_transient('site-categories-cloud-data-' . $this->number);
if (!$data) {
switch_to_blog($current_site->blog_id);
$defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'echo' => true);
$instance = wp_parse_args($instance, $defaults);
if (isset($instance['category']) && intval($instance['category'])) {
$instance['child_of'] = $instance['category'];
}
$tags = get_terms(SITE_CATEGORIES_TAXONOMY, $instance);
// Always query top tags
if (isset($instance['include_parent']) && $instance['include_parent'] == "on") {
$parent_tag = get_term_by('id', $instance['category'], SITE_CATEGORIES_TAXONOMY);
if (!empty($parent_tag) && !is_wp_error($parent_tag)) {
//echo "parent_tag<pre>"; print_r($parent_tag); echo "</pre>";
$tags[] = $parent_tag;
}
}
if (empty($tags) || is_wp_error($tags)) {
return;
}
foreach ($tags as $key => $tag) {
$tags[$key]->id = $tag->term_id;
if (isset($site_categories->opts['landing_page_rewrite']) && $site_categories->opts['landing_page_rewrite'] == true) {
$tags[$key]->link = trailingslashit($site_categories->opts['landing_page_slug']) . $tag->slug;
} else {
$tags[$key]->link = $site_categories->opts['landing_page_slug'] . '&category_name=' . $tag->slug;
}
}
$data = wp_generate_tag_cloud($tags, $instance);
// Here's where those top tags get sorted according to $args
restore_current_blog();
set_site_transient('site-categories-cloud-data-' . $this->number, $data, 30);
}
if ($data) {
echo $before_widget;
$title = apply_filters('widget_title', $instance['title']);
if ($title) {
echo $before_title . $title . $after_title;
}
echo $data;
echo $after_widget;
}
}
示例11: get_terms
<?php
//引入图片插件入口文件
require_once './wp-content/plugins/nextgen-gallery/ngg-config.php';
require_once './inc/php/cfg.php';
$tags = get_terms('ngg_tag');
foreach ($tags as $tag) {
$tag->link = $cfg['siteurl'] . 'tag/' . $tag->term_id . '-' . $tag->slug . '.html';
}
$args = array('smallest' => 20, 'largest' => 100, 'unit' => 'pt', 'number' => 100, 'format' => 'flat', 'orderby' => 'count', 'order' => 'RAND');
$tags_display = wp_generate_tag_cloud($tags, $args);
//页面title
$page_title = 'FOTO';
$title = 'Tags' . $cfg['sitetitle'];
require_once './inc/html/head.html';
?>
<div id='main'>
<?php
echo $tags_display;
?>
</div>
<?php
require_once './inc/html/foot.html';
示例12: install_themes_dashboard
function install_themes_dashboard()
{
?>
<p><?php
_e('Search for themes by keyword, author, or tag.');
?>
</p>
<?php
install_theme_search_form('<a href="' . add_query_arg('show-help', !isset($_REQUEST['show-help'])) . '" onclick="jQuery(\'#search-help\').toggle(); return false;">' . __('[need help?]') . '</a>');
?>
<div id="search-help" style="display: <?php
echo isset($_REQUEST['show-help']) ? 'block' : 'none';
?>
;">
<p><?php
_e('You may search based on 3 criteria:');
?>
<br />
<?php
_e('<strong>Term:</strong> Searches theme names and descriptions for the specified term');
?>
<br />
<?php
_e('<strong>Tag:</strong> Searches for themes tagged as such');
?>
<br />
<?php
_e('<strong>Author:</strong> Searches for themes created by the Author, or which the Author contributed to.');
?>
</p>
</div>
<h4><?php
_e('Advanced Search');
?>
</h4>
<p><?php
_e('Tag filter goes here');
?>
</p>
<h4><?php
_e('Popular tags');
?>
</h4>
<p><?php
_e('You may also browse based on the most popular tags in the Theme Directory:');
?>
</p>
<?php
$api_tags = install_themes_popular_tags();
//Set up the tags in a way which can be interprated by wp_generate_tag_cloud()
$tags = array();
foreach ((array) $api_tags as $tag) {
$tags[$tag['name']] = (object) array('link' => clean_url(admin_url('theme-install.php?tab=search&type=tag&s=' . urlencode($tag['name']))), 'name' => $tag['name'], 'id' => sanitize_title_with_dashes($tag['name']), 'count' => $tag['count']);
}
echo '<p>';
echo wp_generate_tag_cloud($tags, array('single_text' => __('%d theme'), 'multiple_text' => __('%d themes')));
echo '</p><br class="clear" />';
}
示例13: widget
public function widget($args, $instance)
{
$cache = array();
if (!$this->is_preview()) {
$cache = wp_cache_get('stt2extat_widget_terms_list', 'widget');
}
if (!is_array($cache)) {
$cache = array();
}
if (!isset($args['widget_id'])) {
$args['widget_id'] = $this->id;
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
ob_start();
$title = __('Popular Terms', 'stt2extat');
$post_id = null;
$sort = isset($instance['sort']) ? $instance['sort'] : 'count';
$obj = get_queried_object();
$tax = $cloud = false;
$tax_query = $args_cloud = array();
switch ($sort) {
case 'taxonomy':
if (!isset($obj->term_id)) {
return null;
}
$title .= ' in ' . $obj->name;
$tax_query = array('tax_query' => array('tax_query' => array(array('taxonomy' => $obj->taxonomy, 'terms' => $obj->term_id))));
$sort = 'count';
$tax = true;
break;
case 'post_id':
if (!is_single()) {
return null;
}
$title .= __(' Post', 'stt2extat');
$post_id = $obj->ID;
$sort = 'count';
break;
case 'term_id':
$title = __('Recent Terms', 'stt2extat');
break;
case 'recent':
if (!is_single()) {
return null;
}
$title = __('Recent Terms Post', 'stt2extat');
$post_id = $obj->ID;
$sort = 'term_id';
break;
case 'term_cloud':
$title = __('Term Cloud', 'stt2extat');
$args_cloud = apply_filters('stt2extat_tag_cloud_args', array());
$sort = 'count';
$cloud = true;
break;
default:
$title = $title;
break;
}
$title = apply_filters('widget_title', empty($instance['title']) ? $title : $instance['title'], $instance, $this->id_base);
$interval = isset($instance['interval']) ? $instance['interval'] : 'all';
$number = isset($instance['number']) ? $instance['number'] : 5;
$count = isset($instance['count']) ? $instance['count'] : 'tooltips';
$convert = isset($instance['convert']) ? $instance['convert'] : 'n';
$args_query = array('sort' => $sort, 'number' => $number, 'order' => 'DESC', 'p' => $post_id);
$args_interval = apply_filters('stt2extat_widget_interval_time', array('date_query' => array('after' => $interval)));
if ('all' != $interval) {
$args_query = wp_parse_args($args_interval, $args_query);
}
if ('count' == $sort && $tax) {
$args_query = wp_parse_args($tax_query, $args_query);
}
$set = array('text_header' => '', 'html_heading' => '', 'display' => 'ul', 'count' => $count, 'convert' => $convert);
$args_query = wp_parse_args($args_query, $set);
$result = stt2extat_terms_list($args_query, $widget = (object) array('is_widget' => true, 'cloud' => wp_validate_boolean($cloud)));
if ('count' == $sort && $cloud) {
unset($args_cloud['number']);
// use args_query['number']
$args_cloud['filter'] = false;
$args_cloud['topic_count_text'] = _n_noop('%s hit', '%s hits');
if (has_filter('stt2extat_term_count', 'stt2extat_count_posts')) {
$args_cloud['topic_count_text'] = _n_noop('%s topic', '%s topics');
}
if ('n' == $args_query['count']) {
$args_cloud['topic_count_text'] = '';
}
$result = wp_generate_tag_cloud($result, $args_cloud);
}
if (!empty($result)) {
echo $args['before_widget'];
if ($title) {
echo $args['before_title'] . $title . $args['after_title'];
}
echo $result;
echo $args['after_widget'];
}
if (!$this->is_preview()) {
//.........这里部分代码省略.........
示例14: the_content
the_content(__('› Continue reading'));
the_tags('<p class="tags">Tags: ', ', ', '</p>');
edit_post_link('[edit post]', '<p>', '</p>');
the_time('l, F jS, Y');
the_category(', ');
comments_popup_link(__('No Comments'), __('1 Comment'), __('% Comments'));
}
next_posts_link('« Previous Entries');
?>
<?php
previous_posts_link('Next Entries »');
} else {
?>
<h3>Not found!</h3>
<p><?php
_e('Sorry, no posts matched your criteria.');
?>
</p>
<?php
include TEMPLATEPATH . "/searchform.php";
}
?>
<br>
<?php
wp_generate_tag_cloud();
wp_tag_cloud();
?>
<br>
</div>
</td></tr></table>
<? include("footer.php"); ?>
示例15: wp_tag_cloud
/**
* This function mimics the WordPress function wp_tag_cloud()
* because we cannot hook into the function without receiving errors.
*
* As of 1.1, you can define 'link' as 'cpt_post' if you want the term's
* link to take you to the CPT's post page instead of the term archive.
*
* @since 1.0
* @uses $cpt_onomy
* @param array|string $args Optional. Override default arguments.
* @return array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument.
*/
public function wp_tag_cloud($args = NULL)
{
global $cpt_onomy;
$defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'echo' => true);
$args = wp_parse_args($args, $defaults);
$tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC')));
// Always query top tags
if (empty($tags) || is_wp_error($tags)) {
return;
}
foreach ($tags as $key => $tag) {
if ('edit' == $args['link']) {
$link = $cpt_onomy->get_edit_term_link($tag->term_id, $tag->taxonomy);
} elseif ('cpt_post' == $args['link']) {
$link = get_permalink($tag->term_id);
} else {
$link = $cpt_onomy->get_term_link(intval($tag->term_id), $tag->taxonomy);
}
if (is_wp_error($link)) {
return false;
}
$tags[$key]->link = $link;
$tags[$key]->id = $tag->term_id;
}
$return = wp_generate_tag_cloud($tags, $args);
// Here's where those top tags get sorted according to $args
$return = apply_filters('wp_tag_cloud', $return, $args);
if ('array' == $args['format'] || empty($args['echo'])) {
return $return;
}
echo $return;
}