/** * evolve_discussion_rss() * * @since 0.3 * @needsdoc */ function evolve_discussion_rss() { global $id; $uri = get_post_comments_feed_link($id); $text = "<span class=\"comment-feed-link\"><a title='" . __('Follow replies', 'evolve') . "' class=\"tipsytext follow-replies\" href=\"{$uri}\"><i class='fa fa-rss'></i></a></span>"; echo $text; }
/** * framework_discussion_rss() * * @since 0.3 * @needsdoc */ function framework_discussion_rss() { global $id; $uri = get_post_comments_feed_link($id); $text = "<p class=\"comment-feed-link\">You can follow all the replies to this entry through the <a href=\"{$uri}\">comments</a> feed.</p>"; echo $text; }
public function test_unattached_pretty_link() { $this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); $attachment_id = $this->factory->attachment->create_object('image.jpg', 0, array('post_mime_type' => 'image/jpeg', 'post_type' => 'attachment')); $link = get_post_comments_feed_link($attachment_id); $expected = add_query_arg('attachment_id', $attachment_id, home_url('/feed/')); $this->assertEquals($expected, $link); }
/** * Post comments; feed link variations. * * @since 150422 Rewrite. * * @param \WP_Post A WordPress post class instance. * * @return array An array of all feed link variations. */ public function postCommentsFeedLinkVariations(\WP_Post $post) { $variations = []; // Initialize. foreach ($this->feed_types as $_feed_type) { $variations[] = get_post_comments_feed_link($post->ID, $_feed_type); } unset($_feed_type); // Housekeeping. return $variations; }
</a></h1> <?php /* Don't remove these lines. */ add_filter('comment_text', 'popuplinks'); if (have_posts()) { while (have_posts()) { the_post(); ?> <h2 id="comments"><?php _e('Comments'); ?> </h2> <p><a href="<?php echo esc_url(get_post_comments_feed_link($post->ID)); ?> "><?php _e('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.'); ?> </a></p> <?php if (pings_open()) { ?> <p><?php printf(__('The <abbr title="Universal Resource Locator">URL</abbr> to TrackBack this entry is: <em>%s</em>'), get_trackback_url()); ?> </p> <?php }
<?php if (is_singular()) { ?> <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?> " href="<?php comments_link_feed(); ?> " /> <link rel="self" type="application/atom+xml" href="<?php echo esc_url(get_post_comments_feed_link('', 'atom')); ?> " /> <id><?php echo esc_url(get_post_comments_feed_link('', 'atom')); ?> </id> <?php } elseif (is_search()) { ?> <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?> " href="<?php echo home_url() . '?s=' . get_search_query(); ?> " /> <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>
<permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" /> <requires rdf:resource="http://web.resource.org/cc/Notice" /> </License> </rdf:RDF> --> </li><?php $cnt++; } /* end for each comment */ ?> <?php wpi_comment_guide($post, $comments, $cnt); ?> </ol> <p class="mgt cb comments-feed"><a type="application/rss+xml" title="RSS 2.0 Comment Feed" href="<?php echo rel(get_post_comments_feed_link()); ?> " rev="site:relative">RSS feed for comments in this post</a></p> <?php } else { // displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) { ?> <ol id="comments-list" class="commentlist r cf"> <?php wpi_comment_guide($post, $comments, 1); ?>
/** * Displays the comment feed link for a post. * * Prints out the comment feed link for a post. Link text is placed in the * anchor. If no link text is specified, default text is used. If no post ID is * specified, the current post is used. * * @since 2.5.0 * * @param string $link_text Optional. Descriptive link text. Default 'Comments Feed'. * @param int $post_id Optional. Post ID. Default is the ID of the global `$post`. * @param string $feed Optional. Feed format. Default empty. */ function post_comments_feed_link($link_text = '', $post_id = '', $feed = '') { $url = get_post_comments_feed_link($post_id, $feed); if (empty($link_text)) { $link_text = __('Comments Feed'); } $link = '<a href="' . esc_url($url) . '">' . $link_text . '</a>'; /** * Filters the post comment feed link anchor tag. * * @since 2.8.0 * * @param string $link The complete anchor tag for the comment feed link. * @param int $post_id Post ID. * @param string $feed The feed type, or an empty string for the default feed type. */ echo apply_filters('post_comments_feed_link_html', $link, $post_id, $feed); }
?> ); body { margin: 3px; } </style> </head> <body id="commentspopup"> <h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?> "><?php echo get_option('blogname'); ?> </a></h1> <h2 id="comments">Comments</h2> <p><a href="<?php echo get_post_comments_feed_link($post->ID); ?> "><abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.</a></p> <?php if ('open' == $post->ping_status) { ?> <p>The <abbr title="Universal Resource Locator">URL</abbr> to TrackBack this entry is: <em><?php trackback_url(); ?> </em></p> <?php } ?> <?php // this line is WordPress' motor, do not delete it. $commenter = wp_get_current_commenter();
/** * Flushes post cache * * @param integer $post_id * @return boolean */ function flush_post($post_id = null) { if (!$post_id) { $post_id = $this->_detect_post_id(); } if ($post_id) { $uris = array(); $domain_url = w3_get_domain_url(); $feeds = $this->_config->get_array('pgcache.purge.feed.types'); if ($this->_config->get_boolean('pgcache.purge.terms') || $this->_config->get_boolean('pgcache.purge.feed.terms')) { $taxonomies = get_post_taxonomies($post_id); $terms = nxt_get_post_terms($post_id, $taxonomies); } switch (true) { case $this->_config->get_boolean('pgcache.purge.author'): case $this->_config->get_boolean('pgcache.purge.archive.daily'): case $this->_config->get_boolean('pgcache.purge.archive.monthly'): case $this->_config->get_boolean('pgcache.purge.archive.yearly'): case $this->_config->get_boolean('pgcache.purge.feed.author'): $post = get_post($post_id); } /** * Home URL */ if ($this->_config->get_boolean('pgcache.purge.home')) { $home_path = w3_get_home_path(); $site_path = w3_get_site_path(); $uris[] = $home_path; if ($site_path != $home_path) { $uris[] = $site_path; } } /** * Post URL */ if ($this->_config->get_boolean('pgcache.purge.post')) { $post_link = post_permalink($post_id); $post_uri = str_replace($domain_url, '', $post_link); $uris[] = $post_uri; } /** * Post comments URLs */ if ($this->_config->get_boolean('pgcache.purge.comments') && function_exists('get_comments_pagenum_link')) { $comments_number = get_comments_number($post_id); $comments_per_page = get_option('comments_per_page'); $comments_pages_number = @ceil($comments_number / $comments_per_page); for ($pagenum = 1; $pagenum <= $comments_pages_number; $pagenum++) { $comments_pagenum_link = $this->_get_comments_pagenum_link($post_id, $pagenum); $comments_pagenum_uri = str_replace($domain_url, '', $comments_pagenum_link); $uris[] = $comments_pagenum_uri; } } /** * Post author URLs */ if ($this->_config->get_boolean('pgcache.purge.author') && $post) { $posts_number = count_user_posts($post->post_author); $posts_per_page = get_option('posts_per_page'); $posts_pages_number = @ceil($posts_number / $posts_per_page); $author_link = get_author_link(false, $post->post_author); $author_uri = str_replace($domain_url, '', $author_link); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $author_pagenum_link = $this->_get_pagenum_link($author_uri, $pagenum); $author_pagenum_uri = str_replace($domain_url, '', $author_pagenum_link); $uris[] = $author_pagenum_uri; } } /** * Post terms URLs */ if ($this->_config->get_boolean('pgcache.purge.terms')) { $posts_per_page = get_option('posts_per_page'); foreach ($terms as $term) { $term_link = get_term_link($term, $term->taxonomy); $term_uri = str_replace($domain_url, '', $term_link); $posts_pages_number = @ceil($term->count / $posts_per_page); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $term_pagenum_link = $this->_get_pagenum_link($term_uri, $pagenum); $term_pagenum_uri = str_replace($domain_url, '', $term_pagenum_link); $uris[] = $term_pagenum_uri; } } } /** * Daily archive URLs */ if ($this->_config->get_boolean('pgcache.purge.archive.daily') && $post) { $post_date = strtotime($post->post_date); $post_year = gmdate('Y', $post_date); $post_month = gmdate('m', $post_date); $post_day = gmdate('d', $post_date); $posts_per_page = get_option('posts_per_page'); $posts_number = $this->_get_archive_posts_count($post_year, $post_month, $post_day); $posts_pages_number = @ceil($posts_number / $posts_per_page); $day_link = get_day_link($post_year, $post_month, $post_day); $day_uri = str_replace($domain_url, '', $day_link); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $day_pagenum_link = $this->_get_pagenum_link($day_uri, $pagenum); $day_pagenum_uri = str_replace($domain_url, '', $day_pagenum_link); $uris[] = $day_pagenum_uri; } } /** * Monthly archive URLs */ if ($this->_config->get_boolean('pgcache.purge.archive.monthly') && $post) { $post_date = strtotime($post->post_date); $post_year = gmdate('Y', $post_date); $post_month = gmdate('m', $post_date); $posts_per_page = get_option('posts_per_page'); $posts_number = $this->_get_archive_posts_count($post_year, $post_month); $posts_pages_number = @ceil($posts_number / $posts_per_page); $month_link = get_month_link($post_year, $post_month); $month_uri = str_replace($domain_url, '', $month_link); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $month_pagenum_link = $this->_get_pagenum_link($month_uri, $pagenum); $month_pagenum_uri = str_replace($domain_url, '', $month_pagenum_link); $uris[] = $month_pagenum_uri; } } /** * Yearly archive URLs */ if ($this->_config->get_boolean('pgcache.purge.archive.yearly') && $post) { $post_date = strtotime($post->post_date); $post_year = gmdate('Y', $post_date); $posts_per_page = get_option('posts_per_page'); $posts_number = $this->_get_archive_posts_count($post_year); $posts_pages_number = @ceil($posts_number / $posts_per_page); $year_link = get_year_link($post_year); $year_uri = str_replace($domain_url, '', $year_link); for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) { $year_pagenum_link = $this->_get_pagenum_link($year_uri, $pagenum); $year_pagenum_uri = str_replace($domain_url, '', $year_pagenum_link); $uris[] = $year_pagenum_uri; } } /** * Feed URLs */ if ($this->_config->get_boolean('pgcache.purge.feed.blog')) { foreach ($feeds as $feed) { $feed_link = get_feed_link($feed); $feed_uri = str_replace($domain_url, '', $feed_link); $uris[] = $feed_uri; } } if ($this->_config->get_boolean('pgcache.purge.feed.comments')) { foreach ($feeds as $feed) { $post_comments_feed_link = get_post_comments_feed_link($post_id, $feed); $post_comments_feed_uri = str_replace($domain_url, '', $post_comments_feed_link); $uris[] = $post_comments_feed_uri; } } if ($this->_config->get_boolean('pgcache.purge.feed.author') && $post) { foreach ($feeds as $feed) { $author_feed_link = get_author_feed_link($post->post_author, $feed); $author_feed_uri = str_replace($domain_url, '', $author_feed_link); $uris[] = $author_feed_uri; } } if ($this->_config->get_boolean('pgcache.purge.feed.terms')) { foreach ($terms as $term) { foreach ($feeds as $feed) { $term_feed_link = get_term_feed_link($term->term_id, $term->taxonomy, $feed); $term_feed_uri = str_replace($domain_url, '', $term_feed_link); $uris[] = $term_feed_uri; } } } /** * Flush cache */ if (count($uris)) { $cache =& $this->_get_cache(); $mobile_groups = $this->_get_mobile_groups(); $referrer_groups = $this->_get_referrer_groups(); $encryptions = $this->_get_encryptions(); $compressions = $this->_get_compressions(); foreach ($uris as $uri) { foreach ($mobile_groups as $mobile_group) { foreach ($referrer_groups as $referrer_group) { foreach ($encryptions as $encryption) { foreach ($compressions as $compression) { $page_key = $this->_get_page_key($uri, $mobile_group, $referrer_group, $encryption, $compression); $cache->delete($page_key); } } } } } /** * Purge varnish servers */ if ($this->_config->get_boolean('varnish.enabled')) { $varnish =& w3_instance('W3_Varnish'); foreach ($uris as $uri) { $varnish->purge($uri); } } } return true; } return false; }
<?php if (is_singular()) { ?> <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?> " href="<?php echo get_comments_link(); ?> " /> <link rel="self" type="application/atom+xml" href="<?php echo get_post_comments_feed_link('', 'atom'); ?> " /> <id><?php echo get_post_comments_feed_link('', 'atom'); ?> </id> <?php } elseif (is_search()) { ?> <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?> " href="<?php echo get_option('home') . '?s=' . attribute_escape(get_search_query()); ?> " /> <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>
/** * Attempts to guess the correct URL from the current URL (that produced a 404) or * the current query variables. * * @since 2.3.0 * @uses $wpdb * * @param string $current_url Optional. The URL that has 404'd. * @return bool|string The correct URL if one is found. False on failure. */ function redirect_guess_404_permalink( $current_url = '' ) { global $wpdb, $wp_rewrite; if ( ! empty( $current_url ) ) $parsed_url = @parse_url( $current_url ); // Attempt to redirect bare category slugs if the permalink structure starts // with the %category% tag. if ( isset( $parsed_url['path'] ) && preg_match( '#^[^%]+%category%#', $wp_rewrite->permalink_structure ) && $cat = get_category_by_path( $parsed_url['path'] ) ) { if ( ! is_wp_error( $cat ) ) return get_term_link( $cat ); } if ( get_query_var('name') ) { $where = $wpdb->prepare("post_name LIKE %s", like_escape( get_query_var('name') ) . '%'); // if any of post_type, year, monthnum, or day are set, use them to refine the query if ( get_query_var('post_type') ) $where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type')); else $where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')"; if ( get_query_var('year') ) $where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year')); if ( get_query_var('monthnum') ) $where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum')); if ( get_query_var('day') ) $where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day')); $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'"); if ( ! $post_id ) return false; if ( get_query_var( 'feed' ) ) return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) ); elseif ( get_query_var( 'page' ) ) return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); else return get_permalink( $post_id ); } return false; }
<title><?php echo get_option('blogname'); ?> - <?php echo sprintf(__("Comments on %s"), the_title('','',false)); ?></title> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> <style type="text/css" media="screen"> @import url( <?php bloginfo('stylesheet_url'); ?> ); body { margin: 3px; } </style> </head> <body id="commentspopup"> <h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?>"><?php echo get_option('blogname'); ?></a></h1> <h2 id="comments"><?php _e("Comments"); ?></h2> <p><a href="<?php echo get_post_comments_feed_link($post->ID); ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p> <?php if ('open' == $post->ping_status) { ?> <p><?php _e("The <abbr title=\"Universal Resource Locator\">URL</abbr> to TrackBack this entry is:"); ?> <em><?php trackback_url() ?></em></p> <?php } ?> <?php // this line is WordPress' motor, do not delete it. $commenter = wp_get_current_commenter(); extract($commenter); $comments = get_approved_comments($id); $commentstatus = get_post($id); if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie echo(get_the_password_form()); } else { ?>
public function getAttachment() { global $wp_query; $title = string_len(trim(wp_title('', false)), 90); $pid = $wp_query->post->ID; $ppid = $wp_query->post->post_parent; $pathway = array(); // rss $pathway['first'] = array($title . ' comments feeds', array('href' => get_post_comments_feed_link($pid), 'type' => 'application/rss+xml', 'title' => __($title . ' | Subscribe to this comments feed', WPI_META), 'hreflang' => get_hreflang(), 'rel' => self::RSS_REL, 'class' => 'rtxt rss16', 'rev' => 'feed:rss2')); // home $pathway['home'] = $this->getFrontpage(); // parent $att = array(); $att['href'] = get_permalink($ppid); $att['title'] = 'Parent | ' . get_the_title($ppid); $att['class'] = 'parent-link dc-subject'; $att['hreflang'] = get_hreflang(); $pathway['parent'] = array(get_the_title($ppid), $att); // attachments $att = array(); $att['href'] = get_permalink($pid); $att['title'] = __('Attachment | permalink', WPI_META); $pathway['attachment'] = array('Attachment', $att); // attachments-pid $att = array(); $att['href'] = get_permalink() . '#content-top'; $att['title'] = $title . ' | Skip to content'; $att['hreflang'] = get_hreflang(); $att['class'] = 'last-items ' . self::DN_ARROW; if (($pageno = wpi_get_post_current_paged()) != false) { $pathway['post'] = array($title, $att); $title = 'on page ' . $pageno; $att = array(); $att['href'] = wpi_paged_url($pageno); $att['title'] = $title; $att['rev'] = 'site:relative'; } $pathway['last'] = array($title, $att); return $pathway; }
/** * Validate <entry> child elements. */ function test_entry_elements() { $this->go_to('/?feed=atom'); $feed = $this->do_atom(); $xml = xml_to_array($feed); // Get all the <entry> child elements of the <feed> element. $entries = xml_find($xml, 'feed', 'entry'); // Verify we are displaying the correct number of posts. $this->assertCount($this->post_count, $entries); // We Really only need to test X number of entries unless the content is different $entries = array_slice($entries, 1); // Check each of the desired entries against the known post data. foreach ($entries as $key => $entry) { // Get post for comparison $id = xml_find($entries[$key]['child'], 'id'); preg_match('/\\?p=(\\d+)/', $id[0]['content'], $matches); $post = get_post($matches[1]); // Author $author = xml_find($entries[$key]['child'], 'author', 'name'); $user = new WP_User($post->post_author); $this->assertEquals($user->display_name, $author[0]['content']); // Title $title = xml_find($entries[$key]['child'], 'title'); $this->assertEquals($post->post_title, $title[0]['content']); // Link rel="alternate" $link_alts = xml_find($entries[$key]['child'], 'link'); foreach ($link_alts as $link_alt) { if ('alternate' == $link_alt['attributes']['rel']) { $this->assertEquals(get_permalink($post), $link_alt['attributes']['href']); } } // Id $guid = xml_find($entries[$key]['child'], 'id'); $this->assertEquals($post->guid, $id[0]['content']); // Updated $updated = xml_find($entries[$key]['child'], 'updated'); $this->assertEquals(strtotime($post->post_modified_gmt), strtotime($updated[0]['content'])); // Published $published = xml_find($entries[$key]['child'], 'published'); $this->assertEquals(strtotime($post->post_date_gmt), strtotime($published[0]['content'])); // Category foreach (get_the_category($post->ID) as $term) { $terms[] = $term->name; } $categories = xml_find($entries[$key]['child'], 'category'); foreach ($categories as $category) { $this->assertTrue(in_array($category['attributes']['term'], $terms)); } unset($terms); // Content if (!$this->excerpt_only) { $content = xml_find($entries[$key]['child'], 'content'); $this->assertEquals(trim(apply_filters('the_content', $post->post_content)), trim($content[0]['content'])); } // Link rel="replies" $link_replies = xml_find($entries[$key]['child'], 'link'); foreach ($link_replies as $link_reply) { if ('replies' == $link_reply['attributes']['rel'] && 'application/atom+xml' == $link_reply['attributes']['type']) { $this->assertEquals(get_post_comments_feed_link($post->ID, 'atom'), $link_reply['attributes']['href']); } } } }
/** * @ticket UT32 */ function test_item_elements() { $this->go_to('/?feed=rss2'); $feed = $this->do_rss2(); $xml = xml_to_array($feed); // Get all the <item> child elements of the <channel> element $items = xml_find($xml, 'rss', 'channel', 'item'); // Verify we are displaying the correct number of posts. $this->assertCount($this->post_count, $items); // We Really only need to test X number of items unless the content is different $items = array_slice($items, 1); // Check each of the desired entries against the known post data foreach ($items as $key => $item) { // Get post for comparison $guid = xml_find($items[$key]['child'], 'guid'); preg_match('/\\?p=(\\d+)/', $guid[0]['content'], $matches); $post = get_post($matches[1]); // Title $title = xml_find($items[$key]['child'], 'title'); $this->assertEquals($post->post_title, $title[0]['content']); // Link $link = xml_find($items[$key]['child'], 'link'); $this->assertEquals(get_permalink($post), $link[0]['content']); // Comment link $comments_link = xml_find($items[$key]['child'], 'comments'); $this->assertEquals(get_permalink($post) . '#respond', $comments_link[0]['content']); // Pub date $pubdate = xml_find($items[$key]['child'], 'pubDate'); $this->assertEquals(strtotime($post->post_date_gmt), strtotime($pubdate[0]['content'])); // Author $creator = xml_find($items[$key]['child'], 'dc:creator'); $user = new WP_User($post->post_author); $this->assertEquals($user->display_name, $creator[0]['content']); // Categories (perhaps multiple) $categories = xml_find($items[$key]['child'], 'category'); $cats = array(); foreach (get_the_category($post->ID) as $term) { $cats[] = $term->name; } $tags = get_the_tags($post->ID); if ($tags) { foreach (get_the_tags($post->ID) as $term) { $cats[] = $term->name; } } $cats = array_filter($cats); // Should be the same number of categories $this->assertEquals(count($cats), count($categories)); // ..with the same names foreach ($cats as $id => $cat) { $this->assertEquals($cat, $categories[$id]['content']); } // GUID $guid = xml_find($items[$key]['child'], 'guid'); $this->assertEquals('false', $guid[0]['attributes']['isPermaLink']); $this->assertEquals($post->guid, $guid[0]['content']); // Description / Excerpt if (!empty($post->post_excerpt)) { $description = xml_find($items[$key]['child'], 'description'); $this->assertEquals(trim($post->post_excerpt), trim($description[0]['content'])); } // Post content if (!$this->excerpt_only) { $content = xml_find($items[$key]['child'], 'content:encoded'); $this->assertEquals(trim(apply_filters('the_content', $post->post_content)), trim($content[0]['content'])); } // Comment rss $comment_rss = xml_find($items[$key]['child'], 'wfw:commentRss'); $this->assertEquals(html_entity_decode(get_post_comments_feed_link($post->ID)), $comment_rss[0]['content']); } }
/** post_comments_feed_link() - Output the comment feed link for a post. * * Prints out the comment feed link for a post. Link text is placed in the * anchor. If no link text is specified, default text is used. If no post ID * is specified, the current post is used. * * @package WordPress * @subpackage Feed * @since 2.5 * * @param string Descriptive text * @param int Optional post ID. Default to current post. * @return string Link to the comment feed for the current post */ function post_comments_feed_link($link_text = '', $post_id = '', $feed = '') { $url = get_post_comments_feed_link($post_id, $feed); if (empty($link_text)) { $link_text = __('Comments Feed'); } echo "<a href='{$url}'>{$link_text}</a>"; }
/** * Attempts to guess the correct URL based on query vars * * @since 2.3.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @return false|string The correct URL if one is found. False on failure. */ function redirect_guess_404_permalink() { global $wpdb; if (get_query_var('name')) { $where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like(get_query_var('name')) . '%'); // if any of post_type, year, monthnum, or day are set, use them to refine the query if (get_query_var('post_type')) { $where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type')); } else { $where .= " AND post_type IN ('" . implode("', '", get_post_types(array('public' => true))) . "')"; } if (get_query_var('year')) { $where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year')); } if (get_query_var('monthnum')) { $where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum')); } if (get_query_var('day')) { $where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day')); } $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE {$where} AND post_status = 'publish'"); if (!$post_id) { return false; } if (get_query_var('feed')) { return get_post_comments_feed_link($post_id, get_query_var('feed')); } elseif (get_query_var('page') && 1 < get_query_var('page')) { return trailingslashit(get_permalink($post_id)) . user_trailingslashit(get_query_var('page'), 'single_paged'); } else { return get_permalink($post_id); } } return false; }
function test_main_comments_feed() { $post_id = self::factory()->post->create(array('post_title' => 'hello-world')); self::factory()->comment->create_post_comments($post_id, 2); // check the url as generated by get_post_comments_feed_link() $this->go_to(get_post_comments_feed_link($post_id)); $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed'); // check the long form $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); foreach ($types as $type) { $this->go_to("/comments/feed/{$type}"); $this->assertQueryTrue('is_feed', 'is_comment_feed'); } // check the short form $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); foreach ($types as $type) { $this->go_to("/comments/{$type}"); $this->assertQueryTrue('is_feed', 'is_comment_feed'); } }
if (empty($post->post_password) || $_COOKIE['wp-postpass_' . COOKIEHASH] == $post->post_password) { $comments = $wp_query->comments; $comment_count = count($comments); $comment_count == 1 ? $comment_title = __('One Response', 'carrington-blog') : ($comment_title = sprintf(__('%d Responses', 'carrington-blog'), $comment_count)); } ?> <div class="rule-major"><hr /></div> <h2 class="h1 comments-title"><?php echo $comment_title; ?> </h2> <p><?php printf(__('Stay in touch with the conversation, subscribe to the <a class="feed" rel="alternate" href="%s"><acronym title="Really Simple Syndication">RSS</acronym> feed for comments on this post</a>.', 'carrington-blog'), get_post_comments_feed_link($post->ID, '')); ?> </p> <?php if ($comments) { $comment_count = 0; $ping_count = 0; foreach ($comments as $comment) { if (get_comment_type() == 'comment') { $comment_count++; } else { $ping_count++; } } if ($comment_count) {
<?php the_content('<p class="serif">' . __('Read the rest of this entry »', 'xpress') . '</p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>' . __('Pages:', 'xpress') . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> <div class="navigation"> <div class="alignleft"><?php previous_image_link() ?></div> <div class="alignright"><?php next_image_link() ?></div> </div> <br class="clear" /> <p class="postmetadata alt"> <small> <?php printf(__('This entry was posted on %1$s at %2$s and is filed under %3$s.', 'xpress'), get_the_time(__('l, F jS, Y', 'xpress')), get_the_time(), get_the_category_list(', ')); ?> <?php the_taxonomies(); ?> <?php printf(__("You can follow any responses to this entry through the <a href='%s'>RSS 2.0</a> feed.", "xpress"), get_post_comments_feed_link()); ?> <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) { // Both Comments and Pings are open ?> <?php printf(__('You can <a href="#respond">leave a response</a>, or <a href="%s" rel="trackback">trackback</a> from your own site.', 'xpress'), trackback_url(false)); ?> <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) { // Only Pings are Open ?> <?php printf(__('Responses are currently closed, but you can <a href="%s" rel="trackback">trackback</a> from your own site.', 'xpress'), trackback_url(false)); ?> <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) { // Comments are open, Pings are not ?> <?php _e('You can skip to the end and leave a response. Pinging is currently not allowed.', 'xpress'); ?> <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) { // Neither Comments, nor Pings are open ?>
/** * Display the comment feed link for a post. * * Prints out the comment feed link for a post. Link text is placed in the * anchor. If no link text is specified, default text is used. If no post ID is * specified, the current post is used. * * @package WordPress * @subpackage Feed * @since 2.5.0 * * @param string $link_text Descriptive text. * @param int $post_id Optional post ID. Default to current post. * @param string $feed Optional. Feed format. * @return string Link to the comment feed for the current post. */ function post_comments_feed_link($link_text = '', $post_id = '', $feed = '') { $url = get_post_comments_feed_link($post_id, $feed); if (empty($link_text)) { $link_text = __('Comments Feed'); } echo apply_filters('post_comments_feed_link_html', "<a href='{$url}'>{$link_text}</a>", $post_id, $feed); }
<div class="navigation"> <div class="alignleft"><?php previous_image_link(); ?> </div> <div class="alignright"><?php next_image_link(); ?> </div> <div class="clear"></div> </div> <p class="postmetadata alt"> <small> <?php printf(__('This entry was posted on %s and is filed under %s. You can follow any responses to this entry through %s.', 'fusion'), get_the_time(get_option('date_format') . ', ' . get_option('time_format')), get_the_category_list(', '), '<a href="' . get_post_comments_feed_link($post->ID) . '" title="RSS 2.0">RSS 2.0</a>'); ?> <?php if ('open' == $post->comment_status && 'open' == $post->ping_status) { // Both Comments and Pings are open printf(__('You can <a href="#respond">leave a response</a>, or <a href="%s" rel="trackback">trackback</a> from your own site.', 'fusion'), trackback_url('', false)); } elseif (!('open' == $post->comment_status) && 'open' == $post->ping_status) { // Only Pings are Open printf(__('Responses are currently closed, but you can <a href="%s" rel="trackback">trackback</a> from your own site.', 'fusion'), trackback_url('', false)); } elseif ('open' == $post->comment_status && !('open' == $post->ping_status)) { // Comments are open, Pings are not _e('You can skip to the end and leave a response. Pinging is currently not allowed.', 'fusion'); } elseif (!('open' == $post->comment_status) && !('open' == $post->ping_status)) { // Neither Comments, nor Pings are open _e('Both comments and pings are currently closed.', 'fusion');
/** * Return link to the post RSS feed. * * @since 1.5 * @deprecated 2.2 * @deprecated Use get_post_comments_feed_link() * @see get_post_comments_feed_link() * * @return string */ function comments_rss() { _deprecated_function(__FUNCTION__, '2.2', 'get_post_comments_feed_link()'); return get_post_comments_feed_link(); }
/** * 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"; } }
/** * Techozoic Social Media Icons Function * * Echos the social media icon links and images as set in options. * * * @param bool function called from home page or single page * * @access public * @since 1.8.8 */ function tech_social_icons($home = true) { global $tech, $post; $short_link = home_url() . "/?p=" . $post->ID; $home_icons = of_get_option('home_social_icons', array('delicious' => '1', 'digg' => '1', 'rss' => '1')); $single_icons = of_get_option('single_social_icons', array('delicious' => '1', 'digg' => '1', 'rss' => '1')); $image = get_template_directory_uri() . "/images/icons"; $link = get_permalink(); $title = $post->post_title; $email_title = preg_replace('/&/i', 'and', $title); $url_title = urlencode($post->post_title); $excerpt = urlencode(wp_trim_excerpt($post->post_excerpt)); $excerpt_mail = wp_trim_excerpt($post->post_excerpt); $excerpt_mail = preg_replace("/&#?[a-z0-9]{2,8};/i", "", $excerpt_mail); $home_title = urlencode(get_bloginfo('name')); $social_links = array("delicious" => "<a href=\"http://delicious.com/post?url={$link}&title={$url_title}\" title=\"" . __('del.icio.us this!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/delicious_16.png\" alt=\"" . __('del.icio.us this!', 'techozoic') . "\" /></a>", "digg" => "<a href=\"http://digg.com/submit?phase=2&url={$link}&title={$url_title} \" title=\"" . __('Digg this!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/digg_16.png\" alt=\"" . __('Digg this!', 'techozoic') . "\"/></a>", "email" => "<a href=\"mailto:?subject={$email_title}&body={$excerpt_mail} {$link}\" title=\"" . __('Share this by email.', 'techozoic') . "\"><img src=\"{$image}/email_16.png\" alt=\"" . __('Share this by email.', 'techozoic') . "\"/></a>", "facebook" => "<a href=\"http://www.facebook.com/share.php?u={$link}&t={$url_title}\" title=\"" . __('Share on Facebook!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/facebook_16.png\" alt=\"" . __('Share on Facebook!', 'techozoic') . "\"/></a>", "linkedin" => "<a href =\"http://www.linkedin.com/shareArticle?mini=true&url={$link}&title={$url_title}&summary={$excerpt}&source={$home_title}\" title=\"" . __('Share on LinkedIn!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/linkedin_16.png\" alt=\"" . __('Share on LinkedIn!', 'techozoic') . "\" /></a>", "myspace" => "<a href=\"http://www.myspace.com/Modules/PostTo/Pages/?u={$link}&t={$url_title}\" title=\"" . __('Share on Myspace!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/myspace_16.png\" alt=\"" . __('Share on Myspace!', 'techozoic') . "\"/></a>", "newsvine" => "<a href=\"http://www.newsvine.com/_tools/seed&save?u={$link}\" title=\"" . __('Share on NewsVine!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/newsvine_16.png\" alt=\"" . __('Share on NewsVine!', 'techozoic') . "\"/></a>", "stumbleupon" => "<a href=\"http://www.stumbleupon.com/submit?url={$link}&title={$url_title}\" title=\"" . __('Stumble Upon this!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/stumbleupon_16.png\" alt=\"" . __('Stumble Upon this!', 'techozoic') . "\"/></a>", "twitter" => "<a href=\"http://twitter.com/home?status=Reading%20{$url_title}%20on%20{$short_link}\" title=\"" . __('Tweet this!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/twitter_16.png\" alt=\"" . __('Tweet this!', 'techozoic') . "\"/></a>", "reddit" => "<a href=\"http://reddit.com/submit?url={$link}&title={$url_title}\" title=\"" . __('Share on Reddit!', 'techozoic') . "\" target=\"_blank\"><img src=\"{$image}/reddit_16.png\" alt=\"" . __('Share on Reddit!', 'techozoic') . "\" /></a>", "rss" => "<a href=\"" . get_post_comments_feed_link() . "\" title=\"" . __('Subscribe to Feed', 'techozoic') . "\"><img src=\"{$image}/rss_16.png\" alt=\"" . __('RSS 2.0', 'techozoic') . "\"/></a>", "google" => "<g:plusone size=\"small\" annotation=\"none\" expandto=\"right\" href=\"{$link}\"></g:plusone>"); if ($home == true) { if (is_array($home_icons)) { foreach ($home_icons as $key => $value) { if ($value == "1") { echo $social_links[$key] . " "; } } } } else { if (is_array($single_icons)) { foreach ($single_icons as $key => $value) { if ($value == "1") { echo $social_links[$key] . " "; } } } } }
?> <content:encoded><![CDATA[<?php the_excerpt_rss(); ?> ]]></content:encoded> <?php } ?> <?php } ?> <wfw:commentRss><?php echo esc_url(get_post_comments_feed_link(null, 'rss2')); ?> </wfw:commentRss> <slash:comments><?php echo get_comments_number(); ?> </slash:comments> <?php rss_enclosure(); ?> <?php do_action('rss2_item'); ?> </item>
the_content(); ?> ]]></content:encoded> <?php } else { ?> <content:encoded><![CDATA[<?php the_excerpt_rss(); ?> ]]></content:encoded> <?php } } ?> <wfw:commentRss><?php echo get_post_comments_feed_link(); ?> </wfw:commentRss> <slash:comments><?php echo get_comments_number(); ?> </slash:comments> <?php rss_enclosure(); ?> <?php do_action('rss2_item'); ?> </item> <?php }
/** * Display the comment feed link for a post. * * Prints out the comment feed link for a post. Link text is placed in the * anchor. If no link text is specified, default text is used. If no post ID is * specified, the current post is used. * * @since 2.5.0 * * @param string $link_text Descriptive text. * @param int $post_id Optional post ID. Default to current post. * @param string $feed Optional. Feed format. */ function post_comments_feed_link($link_text = '', $post_id = '', $feed = '') { $url = esc_url(get_post_comments_feed_link($post_id, $feed)); if (empty($link_text)) { $link_text = __('Comments Feed'); } /** * Filter the post comment feed link anchor tag. * * @since 2.8.0 * * @param string $link The complete anchor tag for the comment feed link. * @param int $post_id Post ID. * @param string $feed The feed type, or an empty string for the default feed type. */ echo apply_filters('post_comments_feed_link_html', "<a href='{$url}'>{$link_text}</a>", $post_id, $feed); }
/** * 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"; } }