/** * Retrieve the permalink for the comments feed of the search results. * * @since 2.5.0 * * @global WP_Rewrite $wp_rewrite * * @param string $search_query Optional. Search query. * @param string $feed Optional. Feed type. * @return string The comments feed search results permalink. */ function get_search_comments_feed_link($search_query = '', $feed = '') { global $wp_rewrite; if (empty($feed)) { $feed = get_default_feed(); } $link = get_search_feed_link($search_query, $feed); $permastruct = $wp_rewrite->get_search_permastruct(); if (empty($permastruct)) { $link = add_query_arg('feed', 'comments-' . $feed, $link); } else { $link = add_query_arg('withcomments', 1, $link); } /** This filter is documented in wp-includes/link-template.php */ return apply_filters('search_feed_link', $link, $feed, 'comments'); }
/** * Display the links to the extra feeds such as category feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */ function feed_links_extra($args = array()) { $defaults = array('separator' => _x('»', 'feed link'), 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), 'cattitle' => __('%1$s %2$s %3$s Category Feed'), 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'), 'posttypetitle' => __('%1$s %2$s %3$s Feed')); $args = wp_parse_args($args, $defaults); if (is_singular()) { $id = 0; $post = get_post($id); if (comments_open() || pings_open() || $post->comment_count > 0) { $title = sprintf($args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute(array('echo' => false))); $href = get_post_comments_feed_link($post->ID); } } elseif (is_post_type_archive()) { $post_type = get_query_var('post_type'); if (is_array($post_type)) { $post_type = reset($post_type); } $post_type_obj = get_post_type_object($post_type); $title = sprintf($args['posttypetitle'], get_bloginfo('name'), $args['separator'], $post_type_obj->labels->name); $href = get_post_type_archive_feed_link($post_type_obj->name); } elseif (is_category()) { $term = get_queried_object(); if ($term) { $title = sprintf($args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name); $href = get_category_feed_link($term->term_id); } } elseif (is_tag()) { $term = get_queried_object(); if ($term) { $title = sprintf($args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name); $href = get_tag_feed_link($term->term_id); } } elseif (is_author()) { $author_id = intval(get_query_var('author')); $title = sprintf($args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta('display_name', $author_id)); $href = get_author_feed_link($author_id); } elseif (is_search()) { $title = sprintf($args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query(false)); $href = get_search_feed_link(); } elseif (is_post_type_archive()) { $title = sprintf($args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title('', false)); $post_type_obj = get_queried_object(); if ($post_type_obj) { $href = get_post_type_archive_feed_link($post_type_obj->name); } } if (isset($title) && isset($href)) { echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr($title) . '" href="' . esc_url($href) . '" />' . "\n"; } }
/** * Retrieve the permalink for the comments feed of the search results. * * @since 2.5.0 * * @param string $search_query Optional. Search query. * @param string $feed Optional. Feed type. * @return string */ function get_search_comments_feed_link($search_query = '', $feed = '') { global $wp_rewrite; if (empty($feed)) { $feed = get_default_feed(); } $link = get_search_feed_link($search_query, $feed); $permastruct = $wp_rewrite->get_search_permastruct(); if (empty($permastruct)) { $link = add_query_arg('feed', 'comments-' . $feed, $link); } else { $link = add_query_arg('withcomments', 1, $link); } $link = apply_filters('search_feed_link', $link, $feed, 'comments'); return $link; }
public function getSearch() { $pathway = array(); $terms = get_search_query(); // rss $pathway['first'] = array($title . ' taxonomy feeds', array('href' => get_search_feed_link($terms), 'type' => 'application/rss+xml', 'title' => __($terms . ' | Subscribe to this search feed', WPI_META), 'hreflang' => get_hreflang(), 'rel' => self::RSS_REL, 'class' => 'rtxt rss16', 'rev' => 'feed:rss2')); // home $pathway['home'] = $this->getFrontpage(); $pathway['archive'] = array(__('Search', WPI_META), array('href' => '#content-top', 'title' => __('Search | Skip to content', WPI_META))); $pathway['last'] = array($terms, array('href' => '#content-top', 'title' => __('Skip to content | ' . $terms, WPI_META), 'class' => self::CAT_LINK_CLASS . ' ' . self::DN_ARROW, 'rev' => 'site:archive')); return $pathway; }
/** * Display the links to the extra feeds such as category feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */ function feed_links_extra($args) { $defaults = array('separator' => _x('»', 'feed link'), 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), 'cattitle' => __('%1$s %2$s %3$s Category Feed'), 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed')); $args = wp_parse_args($args, $defaults); if (is_single() || is_page()) { $post =& get_post($id = 0); if (comments_open() || pings_open() || $post->comment_count > 0) { $title = esc_attr(sprintf($args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html(get_the_title()))); $href = get_post_comments_feed_link($post->ID); } } elseif (is_category()) { $cat_id = intval(get_query_var('cat')); $title = esc_attr(sprintf($args['cattitle'], get_bloginfo('name'), $args['separator'], get_cat_name($cat_id))); $href = get_category_feed_link($cat_id); } elseif (is_tag()) { $tag_id = intval(get_query_var('tag_id')); $tag = get_tag($tag_id); $title = esc_attr(sprintf($args['tagtitle'], get_bloginfo('name'), $args['separator'], $tag->name)); $href = get_tag_feed_link($tag_id); } elseif (is_author()) { $author_id = intval(get_query_var('author')); $title = esc_attr(sprintf($args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta('display_name', $author_id))); $href = get_author_feed_link($author_id); } elseif (is_search()) { $title = esc_attr(sprintf($args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query())); $href = get_search_feed_link(); } if (isset($title) && isset($href)) { echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n"; } }
/** * Debug Function * * 要开启本插件Debug, 去掉第一行 defined('WPCC_DEBUG', true')...注释. * Debug信息将输出在页面footer位置( wp_footer action) * */ function wpcc_debug() { global $wpcc_noconversion_url, $wpcc_target_lang, $wpcc_langs_urls, $wpcc_deubg_data, $wpcc_langs, $wpcc_options, $wp_rewrite; echo '<!--'; echo '<p style="font-size:20px;color:red;">'; echo 'WP Chinese Conversion Plugin Debug Output:<br />'; echo '默认URL: <a href="' . $wpcc_noconversion_url . '">' . $wpcc_noconversion_url . '</a><br />'; echo '当前语言(空则是不转换): ' . $wpcc_target_lang . "<br />"; echo 'Query String: ' . $_SERVER['QUERY_STRING'] . '<br />'; echo 'Request URI: ' . $_SERVER['REQUEST_URI'] . '<br />'; foreach ($wpcc_langs_urls as $key => $value) { echo $key . ' URL: <a href="' . $value . '">' . $value . '</a><br />'; } echo 'Category feed link: ' . get_category_feed_link(1) . '<br />'; echo 'Search feed link: ' . get_search_feed_link('test'); echo 'Rewrite Rules: <br />'; echo nl2br(htmlspecialchars(var_export($wp_rewrite->rewrite_rules(), true))) . '<br />'; echo 'Debug Data: <br />'; echo nl2br(htmlspecialchars(var_export($wpcc_deubg_data, true))); echo '</p>'; echo '-->'; }
?> </div> <?php } else { ?> <?php if (have_posts()) { get_search_form(); ?> <h3 class="recent-posts clearfix"> <?php printf(__('Your search for <span class="search-term">%s</span> returned ', 'largo'), get_search_query()); printf(_n('%s result', '%s results', $wp_query->found_posts), number_format_i18n($wp_query->found_posts)); printf('<a class="rss-link" href="%1$s"><i class="icon-rss"></i></a>', get_search_feed_link()); ?> </h3> <?php while (have_posts()) { the_post(); $partial = largo_get_partial_by_post_type('search', get_post_type($post), 'search'); get_template_part('partials/content', $partial); } largo_content_nav('nav-below'); } else { get_template_part('partials/content', 'not-found'); } } ?>
$term = get_queried_object(); print '<li><a href="' . get_category_feed_link($term->term_id) . '">' . sprintf(__('Posts in %s', 'Arjuna'), '<em>' . single_cat_title(NULL, false) . '</em>') . '</a></li>'; print '<li class="separator"></li>'; } elseif (is_author()) { $author = get_queried_object(); print '<li><a href="' . get_author_feed_link($author->ID) . '">' . sprintf(__('Posts by %s', 'Arjuna'), '<em>' . ($author->display_name ? $author->display_name : $author->nickname) . '</em>') . '</a></li>'; print '<li class="separator"></li>'; } elseif (is_single()) { $post = get_queried_object(); global $authordata; print '<li><a href="' . get_post_comments_feed_link($post->ID) . '">' . __('Post Comments', 'Arjuna') . '</a></li>'; print '<li><a href="' . get_author_feed_link($post->post_author) . '">' . sprintf(__('Posts by %s', 'Arjuna'), '<em>' . ($authordata->display_name ? $authordata->display_name : $authordata->nickname) . '</em>') . '</a></li>'; print '<li class="separator"></li>'; } elseif (is_search()) { $search = get_query_var('s'); print '<li><a href="' . get_search_feed_link($search) . '">' . __('Search Results', 'Arjuna') . '</a></li>'; print '<li class="separator"></li>'; } print '<li><a href="' . get_bloginfo('rss2_url') . '">' . __('Latest Posts', 'Arjuna') . '</a></li>'; print '<li><a href="' . get_bloginfo('comments_rss2_url') . '">' . __('Latest Comments', 'Arjuna') . '</a></li>'; print '</ul>'; print '</div>'; print $arjunaOptions['sidebarButtons']['RSS']['label']; print '</div>'; } else { ?> <a class="rssBtn" href="<?php bloginfo('rss2_url'); ?> "><?php print $arjunaOptions['sidebarButtons']['RSS']['label'];
/** * Display the links to the extra feeds such as category feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */ function feed_links_extra($args) { $defaults = array('seperator' => _c('»|Seperator character feed titles in theme head'), 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), 'cattitle' => __('%1$s %2$s %3$s Category Feed'), 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), 'searchtitle' => __('%1$s %2$s Search Results for "%3$s" Feed')); $args = wp_parse_args($args, $defaults); if (is_single() || is_page()) { $post =& get_post($id = 0); if (comments_open() || pings_open() || $post->comment_count > 0) { echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . sprintf($args['singletitle'], get_bloginfo('name'), $args['seperator'], wp_specialchars(get_the_title())) . '" href="' . get_post_comments_feed_link($post->ID) . "\" />\n"; } } elseif (is_category()) { $cat_id = intval(get_query_var('cat')); echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . sprintf($args['cattitle'], get_bloginfo('name'), $args['seperator'], get_cat_name($cat_id)) . '" href="' . get_category_feed_link($cat_id) . "\" />\n"; } elseif (is_tag()) { $tag_id = intval(get_query_var('tag_id')); $tag = get_tag($tag_id); echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . sprintf($args['tagtitle'], get_bloginfo('name'), $args['seperator'], $tag->name) . '" href="' . get_tag_feed_link($tag_id) . "\" />\n"; } elseif (is_author()) { $author_id = intval(get_query_var('author')); echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . sprintf($args['authortitle'], get_bloginfo('name'), $args['seperator'], get_author_name($author_id)) . '" href="' . get_author_feed_link($author_id) . "\" />\n"; } elseif (is_search()) { echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . sprintf($args['searchtitle'], get_bloginfo('name'), $args['seperator'], get_search_query()) . '" href="' . get_search_feed_link() . "\" />\n"; } }
/** * Generate RSS or Atom feed link elements appropriate to the context. * * @hook filter tarski_feeds * Filter the RSS or Atam feed link elements before they're printed to the * document. */ function feeds() { global $comments; if (is_single() || is_page() && ($comments || comments_open())) { global $post; $title = sprintf(__('Commments feed for %s', 'tarski'), get_the_title()); $link = get_post_comments_feed_link($post->ID); $source = 'post_comments'; } elseif (is_archive()) { if (is_category()) { $title = sprintf(__('Category feed for %s', 'tarski'), single_cat_title('', '', false)); $link = get_category_feed_link(get_query_var('cat')); $source = 'category'; } elseif (is_tag()) { $title = sprintf(__('Tag feed for %s', 'tarski'), single_tag_title('', '', false)); $link = get_tag_feed_link(get_query_var('tag_id')); $source = 'tag'; } elseif (is_author()) { $title = sprintf(__('Articles feed for %s', 'tarski'), the_archive_author_displayname()); $link = get_author_feed_link(get_query_var('author')); $source = 'author'; } elseif (is_date()) { if (is_day()) { $title = sprintf(__('Daily archive feed for %s', 'tarski'), get_the_time(get_option('date_format'))); $link = get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d')); $source = 'day'; } elseif (is_month()) { $title = sprintf(__('Monthly archive feed for %s', 'tarski'), get_the_time('F Y')); $link = get_month_link(get_the_time('Y'), get_the_time('m')); $source = 'month'; } elseif (is_year()) { $title = sprintf(__('Yearly archive feed for %s', 'tarski'), get_the_time('Y')); $link = get_year_link(get_the_time('Y')); $source = 'year'; } if (get_settings('permalink_structure')) { $link .= 'feed/'; } else { $link .= '&feed=' . get_default_feed(); } } } elseif (is_search()) { $search_query = attribute_escape(get_search_query()); $feeds['search'] = generate_feed_link(sprintf(__('Search feed for %s', 'tarski'), $search_query), get_search_feed_link('', $type), feed_link_type($type)); $title = sprintf(__('Search comments feed for %s', 'tarski'), $search_query); $link = get_search_comments_feed_link('', $type); $source = 'search_comments'; } else { $title = false; } if ($title && $link) { $feeds[$source] = generate_feed_link($title, $link, feed_link_type(get_default_feed())); } $feeds['site'] = generate_feed_link(sprintf(__('%s feed', 'tarski'), get_bloginfo('name')), get_feed_link(), feed_link_type(get_default_feed())); $this->feeds = apply_filters('tarski_feeds', $feeds); }
/** * Display the links to the extra feeds such as category feeds. * * Copy from WP default, but without comment feed; no filter available. * * @since 04/08/2013 * * @param array $args Optional argument. */ public function feed_links_extra($args = array()) { $defaults = ['separator' => _x('»', 'feed link'), 'cattitle' => __('%1$s %2$s %3$s Category Feed'), 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'), 'posttypetitle' => __('%1$s %2$s %3$s Feed')]; $args = wp_parse_args($args, $defaults); if (is_category()) { $term = get_queried_object(); $title = sprintf($args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name); $href = get_category_feed_link($term->term_id); } elseif (is_tag()) { $term = get_queried_object(); $title = sprintf($args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name); $href = get_tag_feed_link($term->term_id); } elseif (is_author()) { $author_id = intval(get_query_var('author')); $title = sprintf($args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta('display_name', $author_id)); $href = get_author_feed_link($author_id); } elseif (is_search()) { $title = sprintf($args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query(FALSE)); $href = get_search_feed_link(); } elseif (is_post_type_archive()) { $title = sprintf($args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title('', FALSE)); $href = get_post_type_archive_feed_link(get_queried_object()->name); } if (isset($title) && isset($href)) { echo '<link rel="alternate" type="' . esc_attr(feed_content_type()) . '" title="' . esc_attr($title) . '" href="' . esc_url($href) . '" />' . "\n"; } }
?> <div class="content"> <?php if (have_posts()) { ?> <header class="archive-header page-header"> <?php $allsearch =& new WP_Query("s={$s}&showposts=-1"); $key = esc_html($s, 1); $count = $allsearch->post_count; ?> <a href="<?php echo get_search_feed_link(); ?> " title="<?php _e('Subscribe to this search results', 'panamazonica'); ?> " class="icon-alone feed-link"><span aria-hidden="true" data-icon=""></span><span class="assistive-text"><?php _e('Search results feed', 'panamazonica'); ?> </span></a> <h1 class="archive-title page-title"><?php printf(__('%1$s Results for %2$s', 'panamazonica'), $count, get_search_query()); ?> </h1> </header> <?php