本文整理汇总了PHP中get_edit_tag_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_edit_tag_link函数的具体用法?PHP get_edit_tag_link怎么用?PHP get_edit_tag_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_edit_tag_link函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: seo_tag_cloud
/**
* Display tag cloud.
*
* The text size is set by the 'smallest' and 'largest' arguments, which will
* use the 'unit' argument value for the CSS text size unit. The 'format'
* argument can be 'flat' (default), 'list', 'nolink', or 'array'. The flat value for the
* 'format' argument will separate tags with spaces. The list value for the
* 'format' argument will format the tags in a UL HTML list. The nolink value for the
* 'format' argument will display the tags without links. The array value for the
* 'format' argument will return in PHP array type format.
*
* The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
* The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'.
*
* The 'number' argument is how many tags to return. By default, the limit will
* be to return the top 20 tags in the tag cloud list.
*
* The 'topic_count_text_callback' argument is a function, which, given the count
* of the posts with that tag, returns a text for the tooltip of the tag link.
* @see default_topic_count_text
*
* The 'exclude' and 'include' arguments are used for the {@link get_tags()}
* function. Only one should be used, because only one will be used and the
* other ignored, if they are both set.
*
* @since 2.3.0
*
* @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.
*/
function seo_tag_cloud($args = '')
{
$defaults = array('largest' => 10, 'number' => 20, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'target' => '');
$args = wp_parse_args($args, $defaults);
$tags = get_tags(array_merge($args, array('orderby' => 'count', 'order' => 'DESC')));
// Always query top tags
if (empty($tags)) {
return;
}
foreach ($tags as $key => $tag) {
if ('edit' == $args['link']) {
$link = get_edit_tag_link($tag->term_id);
} else {
$link = get_tag_link($tag->term_id);
}
if (is_wp_error($link)) {
return false;
}
$tags[$key]->link = $link;
$tags[$key]->id = $tag->term_id;
}
$return = seo_tag_cloud_generate($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']) {
return $return;
}
echo $return;
}
示例2: wp_tag_cloud
/**
* Display tag cloud.
*
* The text size is set by the 'smallest' and 'largest' arguments, which will
* use the 'unit' argument value for the CSS text size unit. The 'format'
* argument can be 'flat' (default), 'list', or 'array'. The flat value for the
* 'format' argument will separate tags with spaces. The list value for the
* 'format' argument will format the tags in a UL HTML list. The array value for
* the 'format' argument will return in PHP array type format.
*
* The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
* The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'.
*
* The 'number' argument is how many tags to return. By default, the limit will
* be to return the top 45 tags in the tag cloud list.
*
* The 'topic_count_text_callback' argument is a function, which, given the count
* of the posts with that tag, returns a text for the tooltip of the tag link.
*
* The 'exclude' and 'include' arguments are used for the {@link get_tags()}
* function. Only one should be used, because only one will be used and the
* other ignored, if they are both set.
*
* @since 2.3.0
*
* @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.
*/
function wp_tag_cloud($args = '')
{
$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 = get_edit_tag_link($tag->term_id, $tag->taxonomy);
} else {
$link = 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;
}
示例3: edit_tag_link
/**
* Display or retrieve edit tag link with formatting.
*
* @since 2.7.0
*
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param int|object $tag Tag object or ID
* @return string|null HTML content, if $echo is set to false.
*/
function edit_tag_link($link = '', $before = '', $after = '', $tag = null)
{
$tax = get_taxonomy('post_tag');
if (!current_user_can($tax->cap->edit_terms)) {
return;
}
$tag = get_term($tag, 'post_tag');
if (empty($link)) {
$link = __('Edit This');
}
$link = '<a href="' . get_edit_tag_link($tag->term_id) . '" title="' . __('Edit Tag') . '">' . $link . '</a>';
echo $before . apply_filters('edit_tag_link', $link, $tag->term_id) . $after;
}
示例4: nk_wp_tag_cloud
/**
* Display tag cloud.
*
* The text size is set by the 'smallest' and 'largest' arguments, which will
* use the 'unit' argument value for the CSS text size unit. The 'format'
* argument can be 'flat' (default), 'list', or 'array'. The flat value for the
* 'format' argument will separate tags with spaces. The list value for the
* 'format' argument will format the tags in a UL HTML list. The array value for
* the 'format' argument will return in PHP array type format.
*
* The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
* The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'.
*
* The 'number' argument is how many tags to return. By default, the limit will
* be to return the top 45 tags in the tag cloud list.
*
* The 'topic_count_text_callback' argument is a function, which, given the count
* of the posts with that tag, returns a text for the tooltip of the tag link.
*
* The 'exclude' and 'include' arguments are used for the {@link get_tags()}
* function. Only one should be used, because only one will be used and the
* other ignored, if they are both set.
*
* The 'single' parameters is used to display only a single post's tags inside
* the loop.
*
* The 'categories' parameter will add categories to the tag cloud if set to 'Yes'
*
* The 'replace' paramter, if set to 'Yes', will change all blanks ' ' to
*
* The 'mincount' parameter will hide all tags that aren't used more often than
* mincount.
*
* The 'separator' will be printed between tags.
*
* 'inject_count' will add a counter to the tags is set to 'Yes'.
* 'inject_count_outside' will put this counter outside the tag link.
*
* @since 2.3.0
*
* @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.
*/
function nk_wp_tag_cloud($args = '')
{
$defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'single' => 'No', 'categories' => 'No', 'replace' => 'No', 'mincount' => '0', 'separator' => '', 'hidelastseparator' => 'No', 'inject_count' => 'No', 'inject_count_outside' => 'Yes', 'post_id' => null, 'nofollow' => 'No', 'taxonomy' => 'post_tag');
$args = wp_parse_args($args, $defaults);
if (intval($args['post_id']) != 0) {
$my_query = new WP_Query("cat={$category}");
if ($my_query->have_posts()) {
while ($my_query->have_posts()) {
$my_query->the_post();
$tags = apply_filters('get_the_tags', get_the_terms(null, 'post_tag'));
}
}
$GLOBALS['post'] = $GLOBALS['wp_query']->post;
// restore $post
} elseif ($args['single'] == 'Yes' || $args['single'] == 'yes') {
$tags = apply_filters('get_the_tags', get_the_terms(null, $args['taxonomy']));
} else {
$tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC')));
}
// nkuttler
if ($args['categories'] == 'Yes') {
$tags = array_merge($tags, get_categories());
}
if (empty($tags)) {
return;
}
foreach ($tags as $key => $tag) {
if ('edit' == $args['link']) {
$link = get_edit_tag_link($tag->term_id);
} else {
if (isset($tag->cat_ID)) {
$link = get_category_link($tag->term_id);
} else {
$link = get_term_link($tag, $args['taxonomy']);
}
}
if (is_wp_error($link)) {
return false;
}
$tags[$key]->link = $link;
$tags[$key]->id = $tag->term_id;
}
$return = nk_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']) {
return $return;
}
// nkuttler - always return
return $return;
//echo $return;
}
示例5: popular_tags_from_category
function popular_tags_from_category($catid, $days, $limit = 15)
{
global $wpdb;
$now = gmdate("Y-m-d H:i:s", time());
//$datelimit = gmdate("Y-m-d H:i:s",gmmktime(date("H"), date("i"), date("s"), date("m"),date("d")-30,date("Y")));
$popterms = "SELECT DISTINCT terms2.*, t2.count as count FROM {$wpdb->posts} as p1 LEFT JOIN {$wpdb->term_relationships} as r1 ON p1.ID = r1.object_ID LEFT JOIN {$wpdb->term_taxonomy} as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id LEFT JOIN {$wpdb->terms} as terms1 ON t1.term_id = terms1.term_id, {$wpdb->posts} as p2 LEFT JOIN {$wpdb->term_relationships} as r2 ON p2.ID = r2.object_ID LEFT JOIN {$wpdb->term_taxonomy} as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id \tLEFT JOIN {$wpdb->terms} as terms2 ON t2.term_id = terms2.term_id \tWHERE t1.taxonomy = 'category' AND p1.post_status = 'publish' AND p1.post_date <= '{$now}' AND p1.post_date > '" . date('Y-m-d H:i:s', strtotime('-' . $days . ' days')) . "' AND terms1.term_id = '{$catid}' AND t2.taxonomy = 'post_tag' AND p2.post_status = 'publish' AND p2.post_date <= '{$now}' AND \tp2.post_date > '" . date('Y-m-d H:i:s', strtotime('-' . $days . ' days')) . "' AND \tp1.ID = p2.ID ORDER BY count DESC LIMIT {$limit}";
$terms = $wpdb->get_results($popterms);
if ($terms) {
$args = array('smallest' => 18, 'largest' => 18, 'unit' => 'px', 'number' => $limit, 'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC', 'link' => 'view', 'taxonomy' => 'post_tag', 'echo' => true);
// Create links
foreach ($terms as $key => $tag) {
if ('edit' == $args['link']) {
$link = get_edit_tag_link($tag->term_id, $args['taxonomy']);
} else {
$link = get_term_link(intval($tag->term_id), $args['taxonomy']);
}
if (is_wp_error($link)) {
return false;
}
$tag_link = '#' != $tag->link ? esc_url($link) : '#';
$tag_id = isset($tag->term_id) ? $tag->term_id : $key;
$tag_name = $terms[$key]->name;
echo "<a href='{$tag_link}' class='tag-link-{$tag_id}' title='" . esc_attr($tag->count) . " posts'>{$tag_name}</a>";
}
//echo wp_generate_tag_cloud( $terms, $args );
}
}
示例6: edit_tag_link
/**
* Display or retrieve edit tag link with formatting.
*
* @since 2.7.0
*
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param int|object $tag Tag object or ID
* @return string|null HTML content, if $echo is set to false.
*/
function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
$tag = get_term($tag, 'post_tag');
if ( !current_user_can('manage_categories') )
return;
if ( empty($link) )
$link = __('Edit This');
$link = '<a href="' . get_edit_tag_link( $tag->term_id ) . '" title="' . __( 'Edit tag' ) . '">' . $link . '</a>';
echo $before . apply_filters( 'edit_tag_link', $link, $tag->term_id ) . $after;
}
示例7: mla_tag_cloud
//.........这里部分代码省略.........
return $cloud;
}
echo $cloud;
return;
}
/*
* Fill in the item_specific link properties, calculate cloud parameters
*/
if (isset($tags['found_rows'])) {
$found_rows = $tags['found_rows'];
unset($tags['found_rows']);
} else {
$found_rows = count($tags);
}
$min_count = 0x7fffffff;
$max_count = 0;
$min_scaled_count = 0x7fffffff;
$max_scaled_count = 0;
foreach ($tags as $key => $tag) {
$tag_count = isset($tag->count) ? $tag->count : 0;
$tag->scaled_count = apply_filters('mla_tag_cloud_scale', round(log10($tag_count + 1) * 100), $attr, $arguments, $tag);
if ($tag_count < $min_count) {
$min_count = $tag_count;
}
if ($tag_count > $max_count) {
$max_count = $tag_count;
}
if ($tag->scaled_count < $min_scaled_count) {
$min_scaled_count = $tag->scaled_count;
}
if ($tag->scaled_count > $max_scaled_count) {
$max_scaled_count = $tag->scaled_count;
}
$link = get_edit_tag_link($tag->term_id, $tag->taxonomy);
if (!is_wp_error($link)) {
$tags[$key]->edit_link = $link;
$link = get_term_link(intval($tag->term_id), $tag->taxonomy);
$tags[$key]->term_link = $link;
}
if (is_wp_error($link)) {
$cloud = '<strong>' . __('ERROR', 'media-library-assistant') . ': ' . $link->get_error_message() . '</strong>, ' . $link->get_error_data($link->get_error_code());
if ('array' == $arguments['mla_output']) {
return array($cloud);
}
if (empty($arguments['echo'])) {
return $cloud;
}
echo $cloud;
return;
}
if ('edit' == $arguments['link']) {
$tags[$key]->link = $tags[$key]->edit_link;
} else {
$tags[$key]->link = $tags[$key]->term_link;
}
}
// foreach tag
/*
* The default MLA style template includes "margin: 1.5%" to put a bit of
* minimum space between the columns. "mla_margin" can be used to change
* this. "mla_itemwidth" can be used with "columns=0" to achieve a
* "responsive" layout.
*/
$columns = absint($arguments['columns']);
$margin_string = strtolower(trim($arguments['mla_margin']));
if (is_numeric($margin_string) && 0 != $margin_string) {
示例8: wpseo_admin_bar_menu
/**
* Adds an SEO admin bar menu with several options. If the current user is an admin he can also go straight to several settings menu's from here.
*/
function wpseo_admin_bar_menu()
{
// If the current user can't write posts, this is all of no use, so let's not output an admin menu.
if (!current_user_can('edit_posts')) {
return;
}
global $wp_admin_bar, $post;
$admin_menu = current_user_can('manage_options');
if (!$admin_menu && is_multisite()) {
$options = get_site_option('wpseo_ms');
$admin_menu = $options['access'] === 'superadmin' && is_super_admin();
}
$focuskw = '';
$score = '';
$seo_url = '';
$analysis_seo = new WPSEO_Metabox_Analysis_SEO();
$analysis_readability = new WPSEO_Metabox_Analysis_Readability();
if ((is_singular() || is_admin() && in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php'), true)) && isset($post) && is_object($post) && apply_filters('wpseo_use_page_analysis', true) === true) {
$focuskw = WPSEO_Meta::get_value('focuskw', $post->ID);
if ($analysis_seo->is_enabled()) {
$score = wpseo_adminbar_seo_score();
} elseif ($analysis_readability->is_enabled()) {
$score = wpseo_adminbar_content_score();
}
$seo_url = get_edit_post_link($post->ID);
}
if (is_category() || is_tag() || WPSEO_Taxonomy::is_term_edit($GLOBALS['pagenow']) && !WPSEO_Taxonomy::is_term_overview($GLOBALS['pagenow']) || is_tax()) {
if ($analysis_seo->is_enabled()) {
$score = wpseo_tax_adminbar_seo_score();
} elseif ($analysis_readability->is_enabled()) {
$score = wpseo_tax_adminbar_content_score();
}
$seo_url = get_edit_tag_link(filter_input(INPUT_GET, 'tag_ID'), 'category');
}
// Never display notifications for network admin.
$counter = '';
if ($admin_menu) {
$seo_url = get_admin_url(null, 'admin.php?page=' . WPSEO_Admin::PAGE_IDENTIFIER);
if ('' === $score) {
// Notification information.
$notification_center = Yoast_Notification_Center::get();
$notification_count = $notification_center->get_notification_count();
$new_notifications = $notification_center->get_new_notifications();
$new_notifications_count = count($new_notifications);
if ($notification_count > 0) {
// Always show Alerts page when clicking on the main link.
/* translators: %s: number of notifications */
$counter_screen_reader_text = sprintf(_n('%s notification', '%s notifications', $notification_count), number_format_i18n($notification_count));
$counter = sprintf(' <div class="wp-core-ui wp-ui-notification yoast-issue-counter"><span aria-hidden="true">%d</span><span class="screen-reader-text">%s</span></div>', $notification_count, $counter_screen_reader_text);
}
if ($new_notifications_count) {
$notification = sprintf(_n('You have a new issue concerning your SEO!', 'You have %d new issues concerning your SEO!', $new_notifications_count, 'wordpress-seo'), $new_notifications_count);
$counter .= '<div class="yoast-issue-added">' . $notification . '</div>';
}
}
}
// Yoast Icon.
$icon_svg = WPSEO_Utils::get_icon_svg();
$title = '<div id="yoast-ab-icon" class="ab-item yoast-logo svg" style="background-image: url(\'' . $icon_svg . '\');"><span class="screen-reader-text">' . __('SEO', 'wordpress-seo') . '</span></div>';
$wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => $title . $score . $counter, 'href' => $seo_url));
if (!empty($notification_count)) {
$wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-notifications', 'title' => __('Notifications', 'wordpress-seo') . $counter, 'href' => $seo_url));
}
$wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __('Keyword Research', 'wordpress-seo'), 'meta' => array('tabindex' => '0')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-adwordsexternal', 'title' => __('AdWords External', 'wordpress-seo'), 'href' => 'http://adwords.google.com/keywordplanner', 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-googleinsights', 'title' => __('Google Trends', 'wordpress-seo'), 'href' => 'https://www.google.com/trends/explore#q=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-wordtracker', 'title' => __('SEO Book', 'wordpress-seo'), 'href' => 'http://tools.seobook.com/keyword-tools/seobook/?keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
if (!is_admin()) {
$url = WPSEO_Frontend::get_instance()->canonical(false);
if (is_string($url)) {
$wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-analysis', 'title' => __('Analyze this page', 'wordpress-seo'), 'meta' => array('tabindex' => '0')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-inlinks-ose', 'title' => __('Check Inlinks (OSE)', 'wordpress-seo'), 'href' => '//moz.com/researchtools/ose/links?site=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-kwdensity', 'title' => __('Check Keyword Density', 'wordpress-seo'), 'href' => '//www.zippy.co.uk/keyworddensity/index.php?url=' . urlencode($url) . '&keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cache', 'title' => __('Check Google Cache', 'wordpress-seo'), 'href' => '//webcache.googleusercontent.com/search?strip=1&q=cache:' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-header', 'title' => __('Check Headers', 'wordpress-seo'), 'href' => '//quixapp.com/headers/?r=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-richsnippets', 'title' => __('Check Rich Snippets', 'wordpress-seo'), 'href' => '//www.google.com/webmasters/tools/richsnippets?q=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-facebookdebug', 'title' => __('Facebook Debugger', 'wordpress-seo'), 'href' => '//developers.facebook.com/tools/debug/og/object?q=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-pinterestvalidator', 'title' => __('Pinterest Rich Pins Validator', 'wordpress-seo'), 'href' => '//developers.pinterest.com/rich_pins/validator/?link=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-htmlvalidation', 'title' => __('HTML Validator', 'wordpress-seo'), 'href' => '//validator.w3.org/check?uri=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cssvalidation', 'title' => __('CSS Validator', 'wordpress-seo'), 'href' => '//jigsaw.w3.org/css-validator/validator?uri=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-pagespeed', 'title' => __('Google Page Speed Test', 'wordpress-seo'), 'href' => '//developers.google.com/speed/pagespeed/insights/?url=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-modernie', 'title' => __('Modern IE Site Scan', 'wordpress-seo'), 'href' => '//www.modern.ie/en-us/report#' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-google-mobile-friendly', 'title' => __('Mobile-Friendly Test', 'wordpress-seo'), 'href' => 'https://www.google.com/webmasters/tools/mobile-friendly/?url=' . urlencode($url), 'meta' => array('target' => '_blank')));
}
}
// @todo: add links to bulk title and bulk description edit pages.
if ($admin_menu) {
$wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-settings', 'title' => __('SEO Settings', 'wordpress-seo'), 'meta' => array('tabindex' => '0')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-general', 'title' => __('Dashboard', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_dashboard')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles & Metas', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_titles')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-social', 'title' => __('Social', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_social')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-xml', 'title' => __('XML Sitemaps', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_xml')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-wpseo-advanced', 'title' => __('Advanced', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_advanced')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-tools', 'title' => __('Tools', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_tools')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-search-console', 'title' => __('Search Console', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_search_console')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-licenses', 'title' => '<span style="color:#f18500">' . __('Extensions', 'wordpress-seo') . '</span>', 'href' => admin_url('admin.php?page=wpseo_licenses')));
}
//.........这里部分代码省略.........
示例9: _get_term_tree
/**
* Walk a list of terms and find hierarchy, preserving source order.
*
* @since 2.25
*
* @param array $terms Term objects, by reference
* @param array $arguments Shortcode arguments, including defaults
*
* @return array ( [taxonomy] => array( [root terms] => array( [fields], array( 'children' => [child terms] )
*/
private static function _get_term_tree(&$terms, $arguments = array())
{
$term = current($terms);
if (empty($term) or !isset($term->parent)) {
return array();
}
/*
* Set found_rows aside to be restored later
*/
if (isset($terms['found_rows'])) {
$found_rows = $terms['found_rows'];
unset($terms['found_rows']);
} else {
$found_rows = NULL;
}
$child_of = !empty($arguments['child_of']) ? absint($arguments['child_of']) : NULL;
$include_tree = !empty($arguments['include_tree']) ? wp_parse_id_list($arguments['include_tree']) : NULL;
$exclude_tree = empty($include_tree) && !empty($arguments['exclude_tree']) ? wp_parse_id_list($arguments['exclude_tree']) : NULL;
$depth = !empty($arguments['depth']) ? absint($arguments['depth']) : 0;
$term_tree = array();
$root_ids = array();
$parents = array();
$child_ids = array();
foreach ($terms as $term) {
// TODO Make this conditional on $arguments['link']
$link = get_edit_tag_link($term->term_id, $term->taxonomy);
if (!is_wp_error($link)) {
$term->edit_link = $link;
$link = get_term_link(intval($term->term_id), $term->taxonomy);
$term->term_link = $link;
}
if (is_wp_error($link)) {
return $link;
}
if ('edit' == $arguments['link']) {
$term->link = $term->edit_link;
} else {
$term->link = $term->term_link;
}
$term->children = array();
$parent = absint($term->parent);
if (0 == $parent) {
$term_tree[$term->taxonomy][] = $term;
$root_ids[$term->taxonomy][$term->term_id] = count($term_tree[$term->taxonomy]) - 1;
} else {
$parents[$term->taxonomy][$term->parent][] = $term;
$child_ids[$term->taxonomy][$term->term_id] = absint($term->parent);
}
}
/*
* Collapse multi-level children
*/
foreach ($parents as $taxonomy => $tax_parents) {
if (!isset($term_tree[$taxonomy])) {
$term_tree[$taxonomy] = array();
$root_ids[$taxonomy] = array();
}
while (!empty($tax_parents)) {
foreach ($tax_parents as $parent_id => $children) {
foreach ($children as $index => $child) {
if (!array_key_exists($child->term_id, $tax_parents)) {
if (array_key_exists($child->parent, $root_ids[$taxonomy])) {
// Found a root node - attach the leaf
$term_tree[$taxonomy][$root_ids[$taxonomy][$child->parent]]->children[] = $child;
} elseif (isset($child_ids[$taxonomy][$child->parent])) {
// Found a non-root parent node - attach the leaf
$the_parent = $child_ids[$taxonomy][$child->parent];
foreach ($tax_parents[$the_parent] as $candidate_index => $candidate) {
if ($candidate->term_id == $child->parent) {
$parents[$taxonomy][$the_parent][$candidate_index]->children[] = $child;
break;
}
}
// foreach candidate
} else {
// No parent exists; make this a root node
$term_tree[$taxonomy][] = $child;
$root_ids[$taxonomy][$child->term_id] = count($term_tree[$taxonomy]) - 1;
}
// Move the leaf node
unset($tax_parents[$parent_id][$index]);
if (empty($tax_parents[$parent_id])) {
unset($tax_parents[$parent_id]);
}
}
// leaf node; no children
}
// foreach child
}
// foreach parent_id
//.........这里部分代码省略.........
示例10: wp_get_all_tags
function wp_get_all_tags($args = '')
{
$tags = get_terms('post_tag');
foreach ($tags as $key => $tag) {
if ('edit' == 'view') {
$link = get_edit_tag_link($tag->term_id, 'post_tag');
} else {
$link = get_term_link(intval($tag->term_id), 'post_tag');
}
if (is_wp_error($link)) {
return false;
}
$tags[$key]->link = $link;
$tags[$key]->id = $tag->term_id;
$tags[$key]->name = $tag->name;
// echo ' <a href="'. $link .'">' . $tag->name . '</a>';
}
return $tags;
}