/** * Triggers on a change event and adds the relevant URL's to the ban list * * Function inspired by Varnish HTTP Purge * https://github.com/Ipstenu/varnish-http-purge/blob/master/plugin/varnish-http-purge.php#L277 * * @param [type] $postId [description] * @return [type] [description] */ protected function handleChange($postId) { // If this is a valid post we want to purge the post, the home page and any associated tags & cats // If not, purge everything on the site. $validPostStatus = array("publish", "trash"); $thisPostStatus = get_post_status($postId); // If this is a revision, stop. if (get_permalink($postId) !== true && !in_array($thisPostStatus, $validPostStatus)) { return; } else { // array to collect all our URLs $listofurls = array(); // Category purge based on Donnacha's work in WP Super Cache $categories = get_the_category($postId); if ($categories) { foreach ($categories as $cat) { $this->invalidateUrl(get_category_link($cat->term_id)); } } // Tag purge based on Donnacha's work in WP Super Cache $tags = get_the_tags($postId); if ($tags) { foreach ($tags as $tag) { $this->invalidateUrl(get_tag_link($tag->term_id)); } } // Author URL $this->invalidateUrl(get_author_posts_url(get_post_field('post_author', $postId))); $this->invalidateUrl(get_author_feed_link(get_post_field('post_author', $postId))); // Archives and their feeds $archiveurls = array(); if (get_post_type_archive_link(get_post_type($postId)) == true) { $this->invalidateUrl(get_post_type_archive_link(get_post_type($postId))); $this->invalidateUrl(get_post_type_archive_feed_link(get_post_type($postId))); } // Post URL $this->invalidateUrl(get_permalink($postId)); // Feeds $this->invalidateUrl(get_bloginfo_rss('rdf_url')); $this->invalidateUrl(get_bloginfo_rss('rss_url')); $this->invalidateUrl(get_bloginfo_rss('rss2_url')); $this->invalidateUrl(get_bloginfo_rss('atom_url')); $this->invalidateUrl(get_bloginfo_rss('comments_rss2_url')); $this->invalidateUrl(get_post_comments_feed_link($postId)); // Home Page and (if used) posts page $this->invalidateUrl(home_url('/')); if (get_option('show_on_front') == 'page') { $this->invalidateUrl(get_permalink(get_option('page_for_posts'))); } } // Filter to add or remove urls to the array of purged urls // @param array $purgeUrls the urls (paths) to be purged // @param int $postId the id of the new/edited post // $this->invalidateUrls = apply_filters( 'vhp_purge_urls', $this->invalidateUrls, $postId ); }
/** * Properties RSS Feed. * * @access public * @return void */ function ph_properties_rss_feed() { // Property RSS if (is_post_type_archive('property') || is_singular('property')) { $feed = get_post_type_archive_feed_link('property'); echo '<link rel="alternate" type="application/rss+xml" title="' . __('Latest Properties', 'propertyhive') . '" href="' . esc_attr($feed) . '" />'; } }
function wp_head() { $feed = get_post_type_archive_feed_link(WPT_Production::post_type_name); $html = array(); $html[] = '<link rel="alternate" type="application/rss+xml" title="' . __('New productions', 'wp_theatre') . '" href="' . $feed . '" />'; $html[] = '<link rel="alternate" type="application/rss+xml" title="' . __('Upcoming productions', 'wp_theatre') . '" href="' . site_url('/upcoming_productions') . '" />'; $html[] = '<link rel="alternate" type="application/rss+xml" title="' . __('Upcoming events', 'wp_theatre') . '" href="' . site_url('/upcoming_events') . '" />'; echo implode("\n", $html) . "\n"; }
function cptrf_init() { $args = array('public' => true, 'has_archive' => true, '_builtin' => false); foreach (get_post_types($args) as $id => $vale) { $feed = get_post_type_archive_feed_link($vale); $obj = get_post_type_object($vale); $name = $obj->labels->name; $feedname = __('Feed'); echo '<link rel="alternate" type="application/rss+xml" title="' . get_bloginfo("name") . ' » ' . $name . ' ' . $feedname . '" href="' . $feed . '" />'; } }
/** * Add feed and links in HEAD of the document */ public function wp_head() { if (is_anspress()) { $q_feed = get_post_type_archive_feed_link('question'); $a_feed = get_post_type_archive_feed_link('answer'); echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr__('Question feed', 'ap') . '" href="' . esc_url($q_feed) . '" />'; echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr__('Answers feed', 'ap') . '" href="' . esc_url($a_feed) . '" />'; } if (is_question() && get_query_var('ap_page') != 'base') { echo '<link rel="canonical" href="' . esc_url(get_permalink(get_question_id())) . '">'; echo '<link rel="shortlink" href="' . esc_url(wp_get_shortlink(get_question_id())) . '" />'; } }
/** * Purge Post * Flush the post * * @since 1.0 * @param array $postId the ID of the post to be purged * @access public */ public function purgePost($postId) { // If this is a valid post we want to purge the post, // the home page and any associated tags and categories $validPostStatus = array("publish", "trash"); $thisPostStatus = get_post_status($postId); // array to collect all our URLs $listofurls = array(); if (get_permalink($postId) == true && in_array($thisPostStatus, $validPostStatus)) { // If this is a post with a permalink AND it's published or trashed, // we're going to add a ton of things to flush. // Category purge based on Donnacha's work in WP Super Cache $categories = get_the_category($postId); if ($categories) { foreach ($categories as $cat) { array_push($listofurls, get_category_link($cat->term_id)); } } // Tag purge based on Donnacha's work in WP Super Cache $tags = get_the_tags($postId); if ($tags) { foreach ($tags as $tag) { array_push($listofurls, get_tag_link($tag->term_id)); } } // Author URL array_push($listofurls, get_author_posts_url(get_post_field('post_author', $postId)), get_author_feed_link(get_post_field('post_author', $postId))); // Archives and their feeds $archiveurls = array(); if (get_post_type_archive_link(get_post_type($postId)) == true) { array_push($listofurls, get_post_type_archive_link(get_post_type($postId)), get_post_type_archive_feed_link(get_post_type($postId))); } // Post URL array_push($listofurls, get_permalink($postId)); // Also clean URL for trashed post. if ($thisPostStatus == "trash") { $trashpost = get_permalink($postId); $trashpost = str_replace("__trashed", "", $trashpost); array_push($listofurls, $trashpost, $trashpost . 'feed/'); } // Add in AMP permalink if Automattic's AMP is installed if (function_exists('amp_get_permalink')) { array_push($listofurls, amp_get_permalink($postId)); } // Regular AMP url for posts array_push($listofurls, get_permalink($postId) . 'amp/'); // Feeds array_push($listofurls, get_bloginfo_rss('rdf_url'), get_bloginfo_rss('rss_url'), get_bloginfo_rss('rss2_url'), get_bloginfo_rss('atom_url'), get_bloginfo_rss('comments_rss2_url'), get_post_comments_feed_link($postId)); // Home Page and (if used) posts page array_push($listofurls, $this->the_home_url() . '/'); if (get_option('show_on_front') == 'page') { // Ensure we have a page_for_posts setting to avoid empty URL if (get_option('page_for_posts')) { array_push($listofurls, get_permalink(get_option('page_for_posts'))); } } } else { // We're not sure how we got here, but bail instead of processing anything else. return; } // Now flush all the URLs we've collected provided the array isn't empty if (!empty($listofurls)) { foreach ($listofurls as $url) { array_push($this->purgeUrls, $url); } } // Filter to add or remove urls to the array of purged urls // @param array $purgeUrls the urls (paths) to be purged // @param int $postId the id of the new/edited post $this->purgeUrls = apply_filters('vhp_purge_urls', $this->purgeUrls, $postId); }
<?php /** * Standard ultimate posts widget template * * @version 2.0.0 */ ?> <?php if (in_array('news', $upw_query->query_vars['post_type'])) { ?> <div class="rss-icn"> <a href="<?php echo get_post_type_archive_feed_link('news'); ?> "><i class="fa fa-rss-square"></i> <?php _e('RSS feed', 'bvs-noticias'); ?> </a> </div> <?php } ?> <?php if ($instance['before_posts']) { ?> <div class="upw-before"> <?php echo wpautop($instance['before_posts']);
/** * NOTE: Actions are points in the execution of a page or process * lifecycle that WordPress fires. * * Actions: http://codex.wordpress.org/Plugin_API#Actions * Reference: http://codex.wordpress.org/Plugin_API/Action_Reference * * @since 1.0.0 */ public function action_method_name() { $domain = $this->plugin_slug; $siteName = get_bloginfo("name"); $args = array('public' => true, 'has_archive' => true, '_builtin' => false); $list_post_types_raw = get_post_types($args); $list_post_types = array_values($list_post_types_raw); if (is_post_type_archive()) { unset($list_post_types[get_post_type()]); } $list_post_types = apply_filters($domain . '-list', $list_post_types); foreach ($list_post_types as $id => $vale) { $feed = get_post_type_archive_feed_link($vale); $obj = get_post_type_object($vale); $name = $obj->labels->name; $feedname = sprintf(__('%1$s » %2$s Feed', $domain), $siteName, $name); printf(__('<link rel="%1$s" type="%2$s" title="%3$s" href="%4$s" />', $domain), "alternate", "application/rss+xml", $feedname, $feed); } }
/** * Products RSS Feed. * * @access public * @return void */ function wc_products_rss_feed() { // Product RSS if (is_post_type_archive('product') || is_singular('product')) { $feed = get_post_type_archive_feed_link('product'); echo '<link rel="alternate" type="application/rss+xml" title="' . __('New products', 'woocommerce') . '" href="' . esc_attr($feed) . '" />'; } elseif (is_tax('product_cat')) { $term = get_term_by('slug', esc_attr(get_query_var('product_cat')), 'product_cat'); $feed = add_query_arg('product_cat', $term->slug, get_post_type_archive_feed_link('product')); echo '<link rel="alternate" type="application/rss+xml" title="' . sprintf(__('New products added to %s', 'woocommerce'), urlencode($term->name)) . '" href="' . esc_attr($feed) . '" />'; } elseif (is_tax('product_tag')) { $term = get_term_by('slug', esc_attr(get_query_var('product_tag')), 'product_tag'); $feed = add_query_arg('product_tag', $term->slug, get_post_type_archive_feed_link('product')); echo '<link rel="alternate" type="application/rss+xml" title="' . sprintf(__('New products tagged %s', 'woocommerce'), urlencode($term->name)) . '" href="' . esc_attr($feed) . '" />'; } }
function powerpressadmin_edit_itunes_general($FeedSettings, $General, $FeedAttribs = array()) { // Set default settings (if not set) if (!empty($FeedSettings)) { if (!isset($FeedSettings['itunes_url'])) { $FeedSettings['itunes_url'] = ''; } } if (!isset($General['itunes_url'])) { $General['itunes_url'] = ''; } else { if (!isset($FeedSettings['itunes_url'])) { // Should almost never happen $FeedSettings['itunes_url'] = $General['itunes_url']; } } $feed_slug = $FeedAttribs['feed_slug']; $cat_ID = $FeedAttribs['category_id']; if ($feed_slug == 'podcast' && $FeedAttribs['type'] == 'general') { if (empty($FeedSettings['itunes_url']) && !empty($General['itunes_url'])) { $FeedSettings['itunes_url'] = $General['itunes_url']; } } ?> <h3><?php echo __('iTunes Listing Information', 'powerpress'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><?php echo __('iTunes Subscription URL', 'powerpress'); ?> </th> <td> <input type="text" style="width: 80%;" name="Feed[itunes_url]" value="<?php echo esc_attr($FeedSettings['itunes_url']); ?> " maxlength="250" /> <p><?php echo sprintf(__('e.g. %s', 'powerpress'), 'http://itunes.apple.com/podcast/title-of-podcast/id<strong>000000000</strong>'); ?> </p> <p><?php echo sprintf(__('Click the following link to %s.', 'powerpress'), '<a href="https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/publishPodcast" target="_blank">' . __('Publish a Podcast on iTunes', 'powerpress') . '</a>'); ?> <?php echo __('iTunes will email your Subscription URL to the <em>iTunes Email</em> entered below when your podcast is accepted into the iTunes Directory.', 'powerpress'); ?> </p> <p> <?php echo __('Recommended feed to submit to iTunes: ', 'powerpress'); switch ($FeedAttribs['type']) { case 'ttid': case 'category': echo get_category_feed_link($cat_ID); break; case 'channel': echo get_feed_link($feed_slug); break; case 'post_type': $url = get_post_type_archive_feed_link($FeedAttribs['post_type'], $feed_slug); echo $url; break; case 'general': default: echo get_feed_link('podcast'); } ?> </p> </td> </tr> </table> <?php }
function powerpressadmin_edit_feed_settings($FeedSettings, $General, $FeedAttribs = array()) { $SupportUploads = powerpressadmin_support_uploads(); if (!isset($FeedSettings['posts_per_rss'])) { $FeedSettings['posts_per_rss'] = ''; } if (!isset($FeedSettings['rss2_image'])) { $FeedSettings['rss2_image'] = ''; } if (!isset($FeedSettings['copyright'])) { $FeedSettings['copyright'] = ''; } if (!isset($FeedSettings['title'])) { $FeedSettings['title'] = ''; } if (!isset($FeedSettings['rss_language'])) { $FeedSettings['rss_language'] = ''; } $feed_link = ''; switch ($FeedAttribs['type']) { case 'category': $feed_link = get_category_feed_link($FeedAttribs['category_id']); break; case 'ttid': $feed_link = get_term_feed_link($FeedAttribs['term_taxonomy_id'], $FeedAttribs['taxonomy_type'], 'rss2'); break; case 'post_type': $feed_link = get_post_type_archive_feed_link($FeedAttribs['post_type'], $FeedAttribs['feed_slug']); break; case 'channel': $feed_link = get_feed_link($FeedAttribs['feed_slug']); break; default: $feed_link = get_feed_link('podcast'); break; } $cat_ID = $FeedAttribs['category_id']; if ($FeedAttribs['type'] == 'channel' && !empty($FeedAttribs['type'])) { ?> <h3><?php echo __('Feed Information', 'powerpress'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"> <?php echo __('Feed URL', 'powerpress'); ?> </th> <td> <p style="margin-top: 0;" class="description"><a href="<?php echo $feed_link; ?> " target="_blank"><?php echo $feed_link; ?> </a> | <a href="http://www.feedvalidator.org/check.cgi?url=<?php echo urlencode(str_replace('&', '&', $feed_link)); ?> " target="_blank"><?php echo __('validate', 'powerpress'); ?> </a></p> <?php if (!empty($FeedSettings['premium'])) { echo __('WARNING: This feed is password protected, it cannot be accessed by public services such as feedvalidator.org or the iTunes podcast directory.', 'powerpress'); } ?> </td> </tr> </table> <?php } ?> <h3><?php echo __('Feed Settings', 'powerpress'); ?> </h3> <?php if ($FeedAttribs['type'] == 'general') { ?> <p class="description"><?php echo __('Feed settings below only apply to the podcast only feed:', 'powerpress'); ?> <?php echo get_feed_link('podcast'); ?> </p> <?php } ?> <table class="form-table"> <tr valign="top"> <th scope="row"> <?php echo __('Feed Title (Show Title)', 'powerpress'); ?> </th> <td> <input type="text" name="Feed[title]" style="width: 60%;" value="<?php echo esc_attr($FeedSettings['title']); ?> " maxlength="250" /> <?php if ($cat_ID) { ?> (<?php echo __('leave blank to use default category title', 'powerpress'); ?> ) <?php } else { ?> (<?php echo __('leave blank to use blog title', 'powerpress'); ?> ) <?php } if ($FeedAttribs['type'] == 'ttid') { } else { if ($cat_ID) { $category = get_category_to_edit($cat_ID); $CategoryName = htmlspecialchars($category->name); ?> <p class="description"><?php echo __('Default Category title:', 'powerpress') . ' ' . get_bloginfo_rss('name') . ' » ' . $CategoryName; ?> </p> <?php } else { ?> <p class="description"><?php echo __('Blog title:', 'powerpress') . ' ' . get_bloginfo_rss('name'); ?> </p> <?php } } if (!empty($General['seo_itunes'])) { ?> <p> <em><?php echo __('SEO Suggestion: The show title is very important.', 'powerpress'); ?> </em> </p> <?php } ?> </td> </tr> <?php if (!empty($General['advanced_mode_2'])) { ?> <!-- start advanced features --> <tr valign="top"> <th scope="row"> <?php echo __('Feed Description', 'powerpress'); ?> </th> <td> <input type="text" name="Feed[description]" style="width: 60%;" value="<?php echo esc_attr(!empty($FeedSettings['description']) ? $FeedSettings['description'] : ''); ?> " maxlength="1000" /> <?php if ($cat_ID) { ?> (<?php echo __('leave blank to use category description', 'powerpress'); ?> ) <?php } else { ?> (<?php echo __('leave blank to use blog description', 'powerpress'); ?> ) <?php } ?> </td> </tr> <?php if ($FeedAttribs['type'] != 'general') { ?> <tr valign="top"> <th scope="row"> <?php echo __('Feed Landing Page URL', 'powerpress'); ?> <br /> </th> <td> <input type="text" name="Feed[url]" style="width: 60%;" value="<?php echo esc_attr(!empty($FeedSettings['url']) ? $FeedSettings['url'] : ''); ?> " maxlength="250" /> <?php if ($cat_ID) { ?> (<?php echo __('leave blank to use category page', 'powerpress'); ?> ) <?php } else { ?> (<?php echo __('leave blank to use home page', 'powerpress'); ?> ) <?php } if ($cat_ID) { ?> <p class="description"><?php echo __('Category page URL', 'powerpress'); ?> : <?php echo get_category_link($cat_ID); ?> </p> <?php } else { ?> <p class="description">e.g. <?php echo get_bloginfo('url'); ?> /custom-page/</p> <?php } ?> </td> </tr> <tr valign="top"> <th scope="row"> <?php echo __('FeedBurner Feed URL', 'powerpress'); ?> <br /> <span style="font-size: 85%; margin-left: 5px;"><?php echo __('Recommendation: leave blank', 'powerpress'); ?> </span> </th> <td> <input type="text" name="Feed[feed_redirect_url]" style="width: 60%;" value="<?php echo esc_attr(!empty($FeedSettings['feed_redirect_url']) ? $FeedSettings['feed_redirect_url'] : ''); ?> " maxlength="100" /> (<?php echo __('leave blank to use built-in feed', 'powerpress'); ?> ) <p style="margin-top: 0px; margin-bottomd: 0;" class="description"><?php echo powerpressadmin_notice(__('NOTE: FeedBurner is not required for podcasting.', 'powerpress')); ?> <br /> <?php echo powerpressadmin_notice(__('No support is available from blubrry if you are using Feedburner or other feed hosted services.', 'powerpress')); ?> <br /> <a href="http://create.blubrry.com/manual/syndicating-your-podcast-rss-feeds/feedburner-for-podcasting/" target="_blank"><?php echo __('Learn more about FeedBurner and Podcasitng', 'powerpress'); ?> </a> </p> <p><?php echo __('Use this option to redirect this feed to a hosted feed service such as FeedBurner.', 'powerpress'); ?> </p> <p><?php echo __('We recommend that you disable FeedBurner SmartCast when using FeedBurner with PowerPress.', 'powerpress'); ?> </p> <?php $link = $feed_link; if (strstr($link, '?')) { $link .= "&redirect=no"; } else { $link .= "?redirect=no"; } ?> <p class="description"><?php echo __('Bypass Redirect URL', 'powerpress'); ?> : <a href="<?php echo $link; ?> " target="_blank"><?php echo $link; ?> </a></p> </td> </tr> <?php } // End not general settings ?> <tr valign="top"> <th scope="row"> <?php echo __('Show the most recent', 'powerpress'); ?> </th> <td> <input type="text" name="Feed[posts_per_rss]" style="width: 50px;" value="<?php echo !empty($FeedSettings['posts_per_rss']) ? $FeedSettings['posts_per_rss'] : ''; ?> " maxlength="5" /> <?php echo __('episodes / posts per feed (leave blank to use blog default', 'powerpress'); ?> : <?php form_option('posts_per_rss'); ?> ) <?php if (empty($FeedAttribs['type'])) { ?> <p style="margin-top: 5px; margin-bottomd: 0;" class="description"><?php echo __('Note: Setting above applies only to podcast channel feeds', 'powerpress'); ?> </p> <?php } ?> <p style="margin-top: 5px; margin-bottomd: 0;" class="description"><?php echo __('WARNING: Setting this value larger than 10 may cause feed timeout errors and delay podcast directory listings from updating.', 'powerpress'); ?> </p> </td> </tr> <?php if (in_array($FeedAttribs['type'], array('channel', 'general'))) { ?> <tr valign="top"> <th scope="row"> <?php echo __('Feed Episode Maximizer', 'powerpress'); ?> <?php echo powerpressadmin_new(); ?> </th> <td> <input type="checkbox" name="Feed[maximize_feed]" value="1" <?php if (!empty($FeedSettings['maximize_feed'])) { echo 'checked'; } ?> /> <?php echo __('The latest 10 episodes in feed will remain as normal. The remaining 11+ older episodes in feed will have only the bare essential tags in order to maximize the number of episodes in the feed.', 'powerpress'); ?> <p style="margin-top: 0px; margin-bottomd: 0;" class="description"><?php echo __('NOTE: This feature may allow you to enter a larger value for the "Show the most recent" setting above. You must make sure that your feed does not exceed 512KB (1/2 MB) in size.', 'powerpress'); ?> </p> </td> </tr> <?php } ?> <tr valign="top"> <th scope="row"> <?php echo __('Feed Language', 'powerpress'); ?> </th> <td> <select name="Feed[rss_language]" class="bpp_input_med"> <?php $Languages = powerpress_languages(); echo '<option value="">' . __('Blog Default Language', 'powerpress') . '</option>'; while (list($value, $desc) = each($Languages)) { echo "\t<option value=\"{$value}\"" . ($FeedSettings['rss_language'] == $value ? ' selected' : '') . ">" . esc_attr($desc) . "</option>\n"; } ?> </select> <?php $rss_language = get_bloginfo_rss('language'); $rss_language = strtolower($rss_language); if (isset($Languages[$rss_language])) { ?> <?php echo __('Blog Default', 'powerpress'); ?> : <?php echo $Languages[$rss_language]; ?> <?php } else { echo __('Blog Default', 'powerpress'); ?> : <?php echo $rss_language; ?> <?php } ?> </td> </tr> <tr valign="top"> <th scope="row"> <?php echo __('Copyright', 'powerpress'); ?> </th> <td> <input type="text" name="Feed[copyright]" style="width: 60%;" value="<?php echo esc_attr($FeedSettings['copyright']); ?> " maxlength="250" /> </td> </tr> <tr valign="top"> <th scope="row"> <?php echo __('Caching Debug Comments', 'powerpress'); ?> </th> <td> <label><input type="checkbox" name="General[allow_feed_comments]" value="1" <?php if (!empty($General['allow_feed_comments'])) { echo 'checked'; } ?> /> <?php echo __('Allow WP Super Cache or W3 Total Cache to add HTML Comments to the bottom of your feeds', 'powerpress'); ?> </label> (<?php echo __('Recommended unchecked', 'powerpress'); ?> ) <p><?php echo __('iTunes is known to have issues with feeds that have HTML comments at the bottom.', 'powerpress'); ?> </p> <p style="margin-bottomd: 0;" class="description"><?php echo __('NOTE: This setting should only be enabled for debugging purposes.', 'powerpress'); ?> </p> </td> </tr> <!-- end advanced features --> <?php } ?> </table> <!-- Location and frequency information --> <?php if (!isset($FeedSettings['location'])) { $FeedSettings['location'] = ''; } if (!isset($FeedSettings['frequency'])) { $FeedSettings['frequency'] = ''; } if (!empty($General['advanced_mode_2'])) { ?> <!-- start advanced features --> <h3><?php echo __('Basic Show Information', 'powerpress'); ?> </h3> <div id="rawvoice_basic_options"> <table class="form-table"> <tr valign="top"> <th scope="row"><?php echo __('Location', 'powerpress'); ?> </th> <td> <input type="text" style="width: 300px;" name="Feed[location]" value="<?php echo esc_attr($FeedSettings['location']); ?> " maxlength="50" /> (<?php echo __('optional', 'powerpress'); ?> ) <p><?php echo __('e.g. Cleveland, Ohio', 'powerpress'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php echo __('Episode Frequency', 'powerpress'); ?> </th> <td> <input type="text" style="width: 300px;" name="Feed[frequency]" value="<?php echo esc_attr($FeedSettings['frequency']); ?> " maxlength="50" /> (<?php echo __('optional', 'powerpress'); ?> ) <p><?php echo __('e.g. Weekly', 'powerpress'); ?> </p> </td> </tr> </table> </div> <!-- end advanced features --> <?php } }
/** * Return a list of webcomic collections. * * ### Arguments * * - `string` **$id** - Value of the id attribute of the list element. * - `mixed` **$class** - String or array of additional classes for the list element. * - `string` **$before** - Content to display before the output. * - `string` **$after** - Content to display after the output. * - `boolean` **$hide_empty** - Whether to hide collections with no readable posts. Defaults to true. * - `boolean` **$ordered** - Use `<ol>` instead of `<ul>`. * - `string` **$collection** - Limits output to a single collection. Useful in combination with $webcomics. * - `string` **$order** - How to order collections, one of 'ASC' (default) or 'DESC'. * - `string` **$orderby** - What to sort the collections by. May be one of 'name', 'slug', 'count', or 'updated'. Defaults to collection ID. * - `string` **$callback** - Custom callback function for generating list items. Callback functions should accept three arguments: the collection configuration array, the function arguments array, and the posts array (if any). * - `string` **$feed** - Text or image URL to use for a collection feed link. * - `string` **$feed_type** - The type of feed to link to. * - `boolean` **$webcomics** - Whether to display a list of webcomic posts grouped by collection. The 'hide_empty' argument is ignored when $webcomics is true. * - `string` **$webcomic_order** - How to order webcomics, one of 'ASC' or 'DESC'. Defaults to 'ASC'. * - `string` **$webcomic_orderby** - What field to order webcomics by. Defaults to 'date'. See WP_Query for details. * - `string` **$webcomic_image** - Size of the webcomic image to use for webcomic links. * - `boolean` **$show_count** - Whether to display the total number of webcomics in a collection. * - `boolean` **$show_description** - Whether to display collection descriptions. * - `boolean` **$show_image** - Size of the collection image to use for collection links. * - `string` **$target** - The target url for collections, one of 'archive', 'first', 'last', or 'random'. Defaults to 'archive'. * - `integer` **$selected** - The ID of the selected collection or webcomic. * * @param array $args Array of arguments. See function description for detailed information. * @return string * @uses WebcomicTag::get_webcomic_collection() * @uses WebcomicTag::get_webcomic_collections() * @uses WebcomicTag::sort_webcomic_collections_name() * @uses WebcomicTag::sort_webcomic_collections_slug() * @uses WebcomicTag::sort_webcomic_collections_count() * @uses WebcomicTag::sort_webcomic_collections_updated() * @uses WebcomicTag::get_relative_webcomic_link() * @filter string webcomic_collection_list_title Filters the collection titles used by `webcomic_list_collections`. * @filter string webcomic_list_collections Filters the output of `webcomic_list_collections`. * @filter string collection_list_webcomic_title Filters the webcomic titles used by `webcomic_list_collections`. */ public static function webcomic_list_collections($args = array()) { global $post; $temp_post = $post; $r = wp_parse_args($args, array('id' => '', 'class' => '', 'before' => '', 'after' => '', 'hide_empty' => true, 'ordered' => '', 'collection' => '', 'order' => 'ASC', 'orderby' => '', 'callback' => false, 'feed' => '', 'feed_type' => 'rss2', 'webcomics' => false, 'webcomic_order' => 'ASC', 'webcomic_orderby' => 'date', 'webcomic_image' => '', 'show_count' => false, 'show_description' => false, 'show_image' => '', 'target' => 'archive', 'selected' => 0)); extract($r); $selected = $selected ? $selected : self::get_webcomic_collection(); $collections = self::get_webcomic_collections(true); if ('name' === $orderby) { usort($collections, array('WebcomicTag', 'sort_webcomic_collections_name')); } elseif ('slug' === $orderby) { usort($collections, array('WebcomicTag', 'sort_webcomic_collections_slug')); } elseif ('count' === $orderby) { usort($collections, array('WebcomicTag', 'sort_webcomic_collections_count')); } elseif ('updated' === $orderby) { usort($collections, array('WebcomicTag', 'sort_webcomic_collections_updated')); } if ('DESC' === $order) { $collections = array_reverse($collections); } $output = $items = ''; foreach ($collections as $v) { if (!$collection or $v['id'] === $collection) { $readable_count = wp_count_posts($v['id'], 'readable'); $readable_count = $readable_count->publish + $readable_count->private; if (!$hide_empty or 0 < $readable_count) { $collection_title = apply_filters('webcomic_collection_list_title', $v['name'], $v); $feed_image = filter_var($feed, FILTER_VALIDATE_URL); $feed_link = $feed ? '<a href="' . get_post_type_archive_feed_link($v['id'], $feed_type) . '" class="webcomic-collection-feed">' . ($feed_image ? '<img src="' . $feed . '" alt="' . sprintf(__('Feed for %s', 'webcomic'), get_post_type_object($v['id'])->labels->name) . '">' : $feed) . '</a>' : ''; if ($webcomics) { $the_posts = new WP_Query(array('posts_per_page' => -1, 'post_type' => $v['id'], 'order' => $webcomic_order, 'orderby' => $webcomic_orderby)); if ($the_posts->have_posts()) { if ($callback) { $items .= call_user_func($callback, $v, $r, $the_posts); } else { $items .= '<li class="webcomic-collection ' . $v['id'] . ($selected === $v['id'] ? ' current' : '') . '"><a href="' . ('archive' === $target ? get_post_type_archive_link($v['id']) : self::get_relative_webcomic_link($target, false, false, '', $v['id'])) . '" class="webcomic-collection-link"><div class="webcomic-collection-name">' . $collection_title . ($show_count ? " ({$readable_count})" : '') . '</div>' . (($show_image and $v['image']) ? '<div class="webcomic-collection-image">' . apply_filters('webcomic_collection_image', wp_get_attachment_image($v['image'], $show_image), $show_image, $v['id']) . '</div>' : '') . '</a>' . (($show_description and $v['description']) ? '<div class="webcomic-collection-description">' . apply_filters('webcomic_collection_description', wpautop($v['description']), $v['id']) . '</div>' : '') . $feed_link . '<' . ($ordered ? 'ol' : 'ul') . ' class="webcomics">'; $i = 0; while ($the_posts->have_posts()) { $the_posts->the_post(); $i++; $items .= '<li' . ($selected === get_the_ID() ? ' class="current"' : '') . '><a href="' . apply_filters('the_permalink', get_permalink()) . '">' . ($webcomic_image ? WebcomicTag::the_webcomic($webcomic_image, 'self') : apply_filters('collection_list_webcomic_title', the_title('', '', false), get_post(), $i)) . '</a></li>'; } $items .= $ordered ? '</ol></li>' : '</ul></li>'; } } } else { $items .= $callback ? call_user_func($callback, $v, $r) : '<li class="webcomic-collection ' . $v['id'] . ($selected === $v['id'] ? ' current' : '') . '"><a href="' . ('archive' === $target ? get_post_type_archive_link($v['id']) : self::get_relative_webcomic_link($target, false, false, '', $v['id'])) . '" class="webcomic-collection-link"><div class="webcomic-collection-name">' . $collection_title . ($show_count ? " ({$readable_count})" : '') . '</div>' . (($show_image and $v['image']) ? '<div class="webcomic-collection-image">' . apply_filters('webcomic_collection_image', wp_get_attachment_image($v['image'], $show_image), $show_image, $v['id']) . '</div>' : '') . '</a>' . (($show_description and $v['description']) ? '<div class="webcomic-collection-description">' . apply_filters('webcomic_collection_description', wpautop($v['description']), $v['id']) . '</div>' : '') . $feed_link . '</li>'; } } } } if ($items) { $output = $before . '<' . ($ordered ? 'ol' : 'ul') . ($id ? ' id="' . esc_attr($id) . '"' : '') . ' class="' . implode(' ', array_merge(array('webcomic-collections', $collection), (array) $class)) . '">' . $items . '</' . ($ordered ? 'ol' : 'ul') . '>' . $after; } $post = $temp_post; return apply_filters('webcomic_list_collections', $output, $r); }
/** * 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"; } }
public function purge_post($postId) { // If this is a valid post we want to purge the post, the home page and any associated tags & cats // If not, purge everything on the site. $validPostStatus = array('publish', 'trash'); $thisPostStatus = get_post_status($postId); // If this is a revision, stop. if (get_permalink($postId) !== true && !in_array($thisPostStatus, $validPostStatus)) { return; } else { // array to collect all our URLs $listofurls = array(); // Category purge based on Donnacha's work in WP Super Cache $categories = get_the_category($postId); if ($categories) { foreach ($categories as $cat) { array_push($listofurls, get_category_link($cat->term_id)); } } // Tag purge based on Donnacha's work in WP Super Cache $tags = get_the_tags($postId); if ($tags) { foreach ($tags as $tag) { array_push($listofurls, get_tag_link($tag->term_id)); } } // Author URL array_push($listofurls, get_author_posts_url(get_post_field('post_author', $postId)), get_author_feed_link(get_post_field('post_author', $postId))); // Archives and their feeds $archiveurls = array(); if (get_post_type_archive_link(get_post_type($postId)) == true) { array_push($listofurls, get_post_type_archive_link(get_post_type($postId)), get_post_type_archive_feed_link(get_post_type($postId))); } // Post URL array_push($listofurls, get_permalink($postId)); // Feeds array_push($listofurls, get_bloginfo_rss('rdf_url'), get_bloginfo_rss('rss_url'), get_bloginfo_rss('rss2_url'), get_bloginfo_rss('atom_url'), get_bloginfo_rss('comments_rss2_url'), get_post_comments_feed_link($postId)); // Home Page and (if used) posts page array_push($listofurls, home_url('/')); if (get_option('show_on_front') == 'page') { array_push($listofurls, get_permalink(get_option('page_for_posts'))); } // If Automattic's AMP is installed, add AMP permalink if (function_exists('amp_get_permalink')) { array_push($listofurls, amp_get_permalink($postId)); } // Now flush all the URLs we've collected foreach ($listofurls as $url) { array_push($this->purgeUrls, $url); } } // Filter to add or remove urls to the array of purged urls // @param array $purgeUrls the urls (paths) to be purged // @param int $postId the id of the new/edited post $this->purgeUrls = apply_filters('vcaching_purge_urls', $this->purgeUrls, $postId); $this->purge_cache(); }
function powerpresssubscribe_get_settings($ExtraData) { $GeneralSettings = get_option('powerpress_general'); $feed_slug = empty($ExtraData['feed']) ? 'podcast' : $ExtraData['feed']; $post_type = empty($ExtraData['post_type']) ? false : $ExtraData['post_type']; $category_id = empty($ExtraData['cat_id']) ? false : $ExtraData['cat_id']; $taxonomy_term_id = empty($ExtraData['taxonomy_term_id']) ? false : $ExtraData['taxonomy_term_id']; if (empty($ExtraData['subscribe_type'])) { // Make sure this value is set $ExtraData['subscribe_type'] = ''; } switch ($ExtraData['subscribe_type']) { case 'post_type': $category_id = 0; $taxonomy_term_id = 0; break; case 'category': $feed_slug = 'podcast'; $taxonomy_term_id = 0; $post_type = ''; break; case 'ttid': $feed_slug = 'podcast'; $category_id = 0; if (empty($post_type)) { $post_type = get_post_type(); } break; case 'channel': case 'general': default: $category_id = 0; $post_type = ''; $taxonomy_term_id = 0; break; } // We need to know if category podcasting is enabled, if it is then we may need to dig deeper for this info.... if (!empty($GeneralSettings['cat_casting']) && $feed_slug == 'podcast' && (empty($ExtraData['subscribe_type']) || $ExtraData['subscribe_type'] == 'category')) { if (!$category_id && is_category()) { $category_id = get_query_var('cat'); } if (!$category_id && is_single()) { $categories = wp_get_post_categories(get_the_ID()); if (count($categories) == 1) { list($null, $category_id) = each($categories); } } if ($category_id) { $Settings = get_option('powerpress_cat_feed_' . $category_id); if (!empty($Settings)) { //$Settings['title'] = $Settings['title']; if (empty($Settings['title'])) { $Settings['title'] = get_bloginfo('name') . get_wp_title_rss(); } // Get category title if (!empty($Settings['feed_redirect_url'])) { $Settings['feed_url'] = $Settings['feed_redirect_url']; } else { $Settings['feed_url'] = get_category_feed_link($category_id); } // Get category feed URL $Settings['subscribe_page_url'] = powerpresssubscribe_get_subscribe_page($Settings); $Settings['itunes_url'] = powerpresssubscribe_get_itunes_url($Settings); $Settings['image_url'] = $Settings['itunes_image']; $Settings['subscribe_feature_email'] = !empty($GeneralSettings['subscribe_feature_email']); return $Settings; } } if ($ExtraData['subscribe_type'] == 'category') { return false; } // let fall through to find better settings } // Taxonomy if ($ExtraData['subscribe_type'] == 'ttid') { if (!empty($GeneralSettings['taxonomy_podcasting'])) { // TODO! Taxonomy Podcasting subscription options } return false; } // Post Type Podcasting if ($ExtraData['subscribe_type'] == 'post_type') { if (!empty($GeneralSettings['posttype_podcasting'])) { if (empty($post_type) && !empty($ExtraData['id'])) { $post_type = get_post_type($ExtraData['id']); } switch ($post_type) { case 'page': case 'post': // SWEET, CARRY ON! break; default: $SettingsArray = get_option('powerpress_posttype_' . $post_type); $Settings = false; if (!empty($SettingsArray[$feed_slug])) { $Settings = $SettingsArray[$feed_slug]; } if (!empty($Settings)) { $Settings['title'] = $Settings['title']; if (empty($Settings['title'])) { $Settings['title'] = get_bloginfo('name') . get_wp_title_rss(); } // Get category title if (!empty($Settings['feed_redirect_url'])) { $Settings['feed_url'] = $Settings['feed_redirect_url']; } else { $Settings['feed_url'] = get_post_type_archive_feed_link($post_type, $feed_slug); } // Get category feed URL $Settings['subscribe_page_url'] = powerpresssubscribe_get_subscribe_page($Settings); $Settings['itunes_url'] = powerpresssubscribe_get_itunes_url($Settings); $Settings['image_url'] = $Settings['itunes_image']; $Settings['subscribe_feature_email'] = !empty($GeneralSettings['subscribe_feature_email']); return $Settings; } break; } } return false; } // Podcast default and channel feed settings $FeedSettings = get_option('powerpress_feed_' . $feed_slug); if (empty($FeedSettings) && $feed_slug == 'podcast') { $FeedSettings = get_option('powerpress_feed'); } // Get the main feed settings if (!empty($FeedSettings)) { $FeedSettings['title'] = $FeedSettings['title']; if (empty($FeedSettings['title'])) { $FeedSettings['title'] = get_bloginfo('name'); } // Get blog title if (!empty($FeedSettings['feed_redirect_url'])) { $FeedSettings['feed_url'] = $FeedSettings['feed_redirect_url']; } else { $FeedSettings['feed_url'] = get_feed_link($feed_slug); } // Get Podcast RSS Feed $FeedSettings['subscribe_page_url'] = powerpresssubscribe_get_subscribe_page($FeedSettings); $FeedSettings['itunes_url'] = powerpresssubscribe_get_itunes_url($FeedSettings); $FeedSettings['image_url'] = $FeedSettings['itunes_image']; $FeedSettings['subscribe_feature_email'] = !empty($GeneralSettings['subscribe_feature_email']); return $FeedSettings; } return false; }
/** * Get the post type archives associated with the post. * * @since 1.0.0. * * @param WP_Post $post The post object to search for post type information. * @return array The related post type archive URLs. */ public function locate_post_type_archive_url($post) { $related = array(); $post_type = get_post_type($post); $post_type_page = get_post_type_archive_link($post_type); $post_type_feed = get_post_type_archive_feed_link($post_type); if (false !== $post_type_page) { $related[] = $post_type_page; } if (false !== $post_type_feed) { $related[] = $post_type_feed; } if (!empty($related)) { $this->set_related_urls_by_category($related, 'post-type-archive'); } return $related; }
/** * Workaround for get_feed_link function, remove filtering. * @param string $feed * @param null|string $post_type * @return mixed */ function get_feed_link($feed = '', $post_type = null) { /** * @var $wp_rewrite WP_Rewrite */ global $wp_rewrite; if ($post_type) { return get_post_type_archive_feed_link($post_type, $feed); } $permalink = $wp_rewrite->get_feed_permastruct(); if ('' != $permalink) { if (false !== strpos($feed, 'comments_')) { $feed = str_replace('comments_', '', $feed); $permalink = $wp_rewrite->get_comment_feed_permastruct(); } if (get_default_feed() == $feed) { $feed = ''; } $permalink = str_replace('%feed%', $feed, $permalink); $permalink = preg_replace('#/+#', '/', "/{$permalink}"); $output = home_url(user_trailingslashit($permalink, 'feed')); } else { if (empty($feed)) { $feed = get_default_feed(); } if (false !== strpos($feed, 'comments_')) { $feed = str_replace('comments_', 'comments-', $feed); } $output = home_url("?feed={$feed}"); } return $output; }
/** * Adds Link tags to the head of the page, for CPTs' feeds. */ function wprss_cpt_feeds() { // Get all post types $post_types = get_post_types(array('public' => true, '_builtin' => false)); // If current page is archive page for a particular post type if (is_post_type_archive()) { // Remove post type from the post types list unset($post_types[get_post_type()]); } // Filter which post types to use // False: none // True: all // Array: particular post types // String: Single post type $post_type_feeds = apply_filters('wprss_cpt_feeds', FALSE); switch (gettype($post_type_feeds)) { // If it's a boolean ... case 'boolean': // If it is FALSE, exit function. Do nothing. Simply. if ($post_type_feeds === FALSE) { return; } // Otherwise, if TRUE, no further action is needed. break; // If it's a string ... // If it's a string ... case 'string': // If the post type does not exist, stop if (!isset($post_types[$post_type_feeds])) { return; } // Otherwise, only use this post type $single = $post_types[$post_type_feeds]; $post_types = array($single => $single); break; // If it's an array ... // If it's an array ... case 'array': $post_types = array_intersect($post_types, $post_type_feeds); break; // If any other type, stop. // If any other type, stop. default: return; } // Get only the values of the post types $post_types = array_values($post_types); // Get the site name and RSS feed URL, parsed as an array $siteName = get_bloginfo("name"); $feedURL = parse_url(get_bloginfo('rss2_url')); // Foreach post type foreach ($post_types as $i => $post_type) { // Get its RSS feed URL $feed = get_post_type_archive_feed_link($post_type); // If it doesnt have one, use the interal WP feed URL using the post_type query arg if ($feed === '' || !is_string($feed)) { // Start with the feed URL of the site $feed = $feedURL; // If there are no query args, set to an emprty string if (!isset($feed['query'])) { $feed['query'] = ''; } // If the query is not empty, we need to add an ampersand if (strlen($feed['query']) > 0) { $feed['query'] .= '&'; } // Add the post_type query arg $feed['query'] .= "post_type={$post_type}"; // Unparse the URL array into a string $feed = unparse_url($feed); } // Get the Post Type Pretty Name $obj = get_post_type_object($post_type); $name = $obj->labels->name; // Print the <link> tag $feedname = sprintf(__('%1$s » %2$s Feed', 'wprss'), $siteName, $name); printf(__('<link rel="%1$s" type="%2$s" title="%3$s" href="%4$s" />' . "\n", 'wprss'), "alternate", "application/rss+xml", $feedname, $feed); } }
function powerpress_admin_posttypefeeds() { $General = powerpress_get_settings('powerpress_general'); $post_types = powerpress_admin_get_post_types(false); ?> <h2><?php echo __('Post Type Podcasting', 'powerpress'); ?> </h2> <p> <?php echo __('Post Type Podcasting adds custom podcast settings to specific Post Type feeds.', 'powerpress'); ?> </p> <style type="text/css"> .column-url { width: 40%; } .column-name { width: 30%; } .column-feed-slug { width: 15%; } .column-post-type { width: 15%; } .column-episode-count { width: 15%; } .category-list { width: 100%; } .form-field select { width: 95%; } </style> <div id="col-container"> <div id="col-right"> <table class="widefat fixed" cellspacing="0"> <thead> <tr> <?php print_column_headers('powerpressadmin_posttypefeeds'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('powerpressadmin_posttypefeeds', false); ?> </tr> </tfoot> <tbody> <?php $count = 0; while (list($null, $post_type) = each($post_types)) { $PostTypeSettingsArray = get_option('powerpress_posttype_' . $post_type); if (!$PostTypeSettingsArray) { continue; } while (list($feed_slug, $PostTypeSettings) = each($PostTypeSettingsArray)) { $feed_title = !empty($PostTypeSettings['title']) ? $PostTypeSettings['title'] : '(blank)'; // $post_type // $feed_slug //global $wpdb; // var_dump($term_info); //$category = get_category_to_edit($cat_ID); $columns = powerpress_admin_posttypefeeds_columns(); $hidden = array(); if ($count % 2 == 0) { echo '<tr valign="middle" class="alternate">'; } else { echo '<tr valign="middle">'; } $edit_link = admin_url('admin.php?page=powerpress/powerpressadmin_posttypefeeds.php&action=powerpress-editposttypefeed&feed_slug=' . $feed_slug . '&podcast_post_type=' . $post_type); $url = get_post_type_archive_feed_link($post_type, $feed_slug); $short_url = str_replace('http://', '', $url); $short_url = str_replace('www.', '', $short_url); if (strlen($short_url) > 35) { $short_url = substr($short_url, 0, 32) . '...'; } foreach ($columns as $column_name => $column_display_name) { $class = "class=\"column-{$column_name}\""; switch ($column_name) { case 'feed-slug': echo "<td {$class}>{$feed_slug}"; echo "</td>"; break; case 'name': echo '<td ' . $class . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit "%s"', 'powerpress'), $feed_title)) . '">' . $feed_title . '</a></strong><br />'; $actions = array(); $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit', 'powerpress') . '</a>'; $actions['remove'] = "<a class='submitdelete' href='" . admin_url() . wp_nonce_url("admin.php?page=powerpress/powerpressadmin_posttypefeeds.php&action=powerpress-delete-posttype-feed&podcast_post_type={$post_type}&feed_slug={$feed_slug}", 'powerpress-delete-posttype-feed-' . $post_type . '_' . $feed_slug) . "' onclick=\"if ( confirm('" . esc_js(sprintf(__("You are about to remove podcast settings for Post Type '%s'\n 'Cancel' to stop, 'OK' to delete.", 'powerpress'), $feed_title)) . "') ) { return true;}return false;\">" . __('Remove', 'powerpress') . "</a>"; $action_count = count($actions); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $linkaction) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo '<span class="' . $action . '">' . $linkaction . $sep . '</span>'; } echo '</div>'; echo '</td>'; break; case 'url': echo "<td {$class}><a href='{$url}' title='" . esc_attr(sprintf(__('Visit %s', 'powerpress'), $feed_title)) . "' target=\"_blank\">{$short_url}</a>"; echo '<div class="row-actions">'; echo '<span class="' . $action . '"><a href="http://www.feedvalidator.org/check.cgi?url=' . urlencode(str_replace('&', '&', $url)) . '" target="_blank">' . __('Validate Feed', 'powerpress') . '</a></span>'; echo '</div>'; echo "</td>"; break; case 'episode-count': echo "<td {$class}>{$episode_total}"; echo "</td>"; break; case 'post-type': echo "<td {$class}>{$post_type}"; echo "</td>"; break; default: break; } } echo "\n </tr>\n"; $count++; } } ?> </tbody> </table> </div> <!-- col-right --> <div id="col-left"> <div class="col-wrap"> <div class="form-wrap"> <h3><?php echo __('Add Podcasting to a custom Post Type', 'powerpress'); ?> </h3> <input type="hidden" name="action" value="powerpress-addposttypefeed" /> <div class="form-field form-required"> <label for="powerpress_post_type_select"><?php echo __('Post Type', 'powerpress'); ?> </label> <select id="powerpress_post_type_select" name="podcast_post_type" style="width: 95%;"> <option value=""><?php echo __('Select Post Type', 'powerpress'); ?> </option> <?php reset($post_types); while (list($null, $post_type) = each($post_types)) { if ($post_type == 'post') { continue; } $post_type = htmlspecialchars($post_type); echo "\t<option value=\"{$post_type}\">{$post_type}</option>\n"; } ?> </select> </div> <div class="form-field form-required"> <label for="feed_title"><?php echo __('Feed Title', 'powerpress'); ?> </label> <input name="feed_title" id="feed_title" type="text" value="" size="100" /> </div> <div class="form-field"> <label for="feed_slug"><?php echo __('Feed Slug', 'powerpress'); ?> </label> <input name="feed_slug" id="feed_slug" type="text" value="" size="40" /> <p><?php echo __('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'powerpress'); ?> </p> </div> <?php wp_nonce_field('powerpress-add-posttype-feed'); ?> <p class="submit"><input type="submit" class="button" name="add_podcasting" value="<?php echo __('Add Podcasting to Post Type', 'powerpress'); ?> " /> </p> </div> </div> </div> <!-- col-left --> </div> <!-- col-container --> <?php }
/** * Get permalink, date archives and custom post type links * * @param $post */ public function setup_post_urls($post) { $post = get_post($post); $this->links[] = get_permalink($post); if ($post->post_type == 'post') { $year = get_the_time("Y", $post); $month = get_the_time("m", $post); $day = get_the_time("d", $post); $this->links[] = get_year_link($year); $this->links[] = get_month_link($year, $month); $this->links[] = get_day_link($year, $month, $day); } else { if (!in_array($post->post_type, get_post_types(array('public' => true)))) { if ($archive_link = get_post_type_archive_link($post->post_type)) { $this->links[] = $archive_link; } foreach ($this->feeds as $feed) { if ($archive_link_feed = get_post_type_archive_feed_link($post->post_type, $feed)) { $this->links[] = $archive_link_feed; } } } } }
/** * Post type archive; feed link variations. * * @since 150218 Refactoring cache clear/purge routines. * * @param \WP_Post A WordPress post class instance. * * @return array An array of all feed link variations. */ public function post_type_archive_link_variations(\WP_Post $post) { $variations = array(); // Initialize. foreach ($this->feed_types as $_feed_type) { $variations[] = get_post_type_archive_feed_link($post->post_type, $_feed_type); } unset($_feed_type); // Housekeeping. return $variations; }
/** * Helper method to generate widget output. * * @since 1.0.0 * * @param array $args Args specific to the widget area (sidebar). * @param array $instance Widget instance settings. */ function render($args, $instance) { $output = $args['before_widget']; // Allow the output to be filtered. if ($inside = apply_filters('audiotheme_widget_recent_posts_output', '', $instance, $args)) { $output .= $inside; } else { $data = array(); $data['args'] = $args; $data['after_title'] = $args['after_title']; $data['before_title'] = $args['before_title']; $data['feed_link'] = 'post' === $instance['post_type'] ? get_bloginfo('rss2_url') : get_post_type_archive_feed_link($instance['post_type']); $data['instance'] = $instance; $data['loop'] = new WP_Query($instance['loop_args']); $data['show_date'] = !empty($instance['show_date']); $data['show_excerpts'] = !empty($instance['show_excerpts']); $data['show_feed_link'] = !empty($instance['show_feed_link']) && !empty($data['feed_link']); $data['title'] = empty($instance['title']) ? '' : $instance['title']; $data = array_merge($instance, $data); ob_start(); $template = audiotheme_locate_template(array("widgets/{$args['id']}_recent-posts.php", 'widgets/recent-posts.php')); audiotheme_load_template($template, $data); $output .= ob_get_clean(); wp_reset_postdata(); } $output .= $args['after_widget']; return $output; }
/** * 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"; } }
function jm_breaking_news_feed() { $post_types = array('jm_breaking_news'); foreach ($post_types as $post_type) { $feed = get_post_type_archive_feed_link($post_type); if ($feed === '' || !is_string($feed)) { $feed = get_bloginfo('rss2_url') . "?post_type={$post_type}"; } printf(__('<link rel="%1$s" type="%2$s" href="%3$s" />'), "alternate", "application/rss+xml", $feed); } }