本文整理汇总了PHP中get_default_feed函数的典型用法代码示例。如果您正苦于以下问题:PHP get_default_feed函数的具体用法?PHP get_default_feed怎么用?PHP get_default_feed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default_feed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_unattached_link
public function test_unattached_link()
{
$attachment_id = self::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(array('feed' => get_default_feed(), 'attachment_id' => $attachment_id), home_url('/'));
$this->assertEquals($expected, $link);
}
示例2: head_cleanup
/**
* Clean up wp_head()
*
* Remove unnecessary <link>'s
* Remove inline CSS and JS from WP emoji support
* Remove inline CSS used by Recent Comments widget
* Remove inline CSS used by posts with galleries
* Remove self-closing tag and change ''s to "'s on rel_canonical()
*
* You can enable/disable this feature in functions.php (or lib/setup.php if you're using Sage):
* add_theme_support('soil-clean-up');
*/
function head_cleanup()
{
// Originally from http://wpengineer.com/1438/wordpress-header/
remove_action('wp_head', 'feed_links_extra', 3);
add_action('wp_head', 'ob_start', 1, 0);
add_action('wp_head', function () {
$pattern = '/.*' . preg_quote(esc_url(get_feed_link('comments_' . get_default_feed())), '/') . '.*[\\r\\n]+/';
echo preg_replace($pattern, '', ob_get_clean());
}, 3, 0);
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'wp_oembed_add_host_js');
remove_action('wp_head', 'rest_output_link_wp_head', 10, 0);
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
add_filter('use_default_gallery_style', '__return_false');
global $wp_widget_factory;
if (isset($wp_widget_factory->widgets['WP_Widget_Recent_Comments'])) {
remove_action('wp_head', [$wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style']);
}
if (!class_exists('WPSEO_Frontend')) {
remove_action('wp_head', 'rel_canonical');
add_action('wp_head', __NAMESPACE__ . '\\rel_canonical');
}
}
示例3: __construct
/**
* Class constructor.
*
* @since 150218 Refactoring cache clear/purge routines.
*/
public function __construct()
{
$this->plugin = plugin();
$this->home_url = home_url('/');
$this->default_feed = get_default_feed();
$this->seo_friendly_permalinks = (bool) get_option('permalink_structure');
$this->feed_types = array_unique(array($this->default_feed, 'rdf', 'rss', 'rss2', 'atom'));
}
示例4: __construct
/**
* Class constructor.
*
* @since 150422 Rewrite.
*/
public function __construct()
{
parent::__construct();
$this->home_url = rtrim(home_url(), '/');
$this->default_feed = get_default_feed();
// Default feed type.
$this->seo_friendly_permalinks = (bool) get_option('permalink_structure');
$this->feed_types = array_unique([$this->default_feed, 'rdf', 'rss', 'rss2', 'atom']);
}
示例5: thesis_feed_url
function thesis_feed_url($display = false)
{
global $thesis;
$feed_url = $thesis['feed']['url'] ? $thesis['feed']['url'] : get_bloginfo(get_default_feed() . '_url');
if ($display) {
echo $feed_url;
} else {
return $feed_url;
}
}
示例6: thesis_feed_url
function thesis_feed_url($display = false)
{
global $thesis_site;
$feed_url = $thesis_site->head['feed']['url'] ? $thesis_site->head['feed']['url'] : get_bloginfo(get_default_feed() . '_url');
$feed_url = apply_filters('thesis_feed_url', $feed_url);
if ($display) {
echo $feed_url;
} else {
return $feed_url;
}
}
示例7: smittenkitchen_content_feed
function smittenkitchen_content_feed($feed_type = null)
{
if (!$feed_type) {
$feed_type = get_default_feed();
}
global $more;
$more_restore = $more;
$more = 0;
$content = apply_filters('the_content', get_the_content());
$more = $more_restore;
$content = str_replace(']]>', ']]& gt;', $content);
return $content;
}
示例8: view
/**
* Page cache tab
*
* @return void
*/
function view()
{
global $wp_rewrite;
$feeds = $wp_rewrite->feeds;
$feed_key = array_search('feed', $feeds);
if ($feed_key !== false) {
unset($feeds[$feed_key]);
}
$default_feed = get_default_feed();
$pgcache_enabled = $this->_config->get_boolean('pgcache.enabled');
$permalink_structure = get_option('permalink_structure');
$varnish_enabled = $this->_config->get_boolean('varnish.enabled');
$cdn_mirror_purge_enabled = Cdn_Util::is_engine_fsd($this->_config->get_string('cdn.engine')) && $this->_config->get_boolean('cdn.enabled');
include W3TC_INC_DIR . '/options/pgcache.php';
}
示例9: view
/**
* Page cache tab
*
* @return void
*/
function view()
{
global $wp_rewrite;
$feeds = $wp_rewrite->feeds;
$feed_key = array_search('feed', $feeds);
if ($feed_key !== false) {
unset($feeds[$feed_key]);
}
$default_feed = get_default_feed();
$pgcache_enabled = $this->_config->get_boolean('pgcache.enabled');
$permalink_structure = get_option('permalink_structure');
$varnish_enabled = $this->_config->get_boolean('varnish.enabled');
$cdn_mirror_purge_enabled = w3_is_cdn_mirror($this->_config->get_string('cdn.engine')) && $this->_config->get_string('cdn.engine') != 'mirror' && $this->_config->get_boolean('cdncache.enabled') && w3tc_edge_mode() && w3_is_pro($this->_config) || w3_is_enterprise();
$disable_check_domain = w3_is_multisite() && w3_force_master();
include W3TC_INC_DIR . '/options/pgcache.php';
}
示例10: feed_links
/**
* Display the links to the general feeds.
*
* @since 2.8.0
*
* @param array $args Optional arguments.
*/
function feed_links($args = array())
{
if (!current_theme_supports('automatic-feed-links')) {
return;
}
$defaults = array('separator' => _x('»', 'feed link'), 'feedtitle' => __('%1$s %2$s Feed'), 'comstitle' => __('%1$s %2$s Comments Feed'));
$args = wp_parse_args($args, $defaults);
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf($args['feedtitle'], get_bloginfo('name'), $args['separator'])) . '" href="' . esc_url(get_feed_link()) . "\" />\n";
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf($args['comstitle'], get_bloginfo('name'), $args['separator'])) . '" href="' . esc_url(get_feed_link('comments_' . get_default_feed())) . "\" />\n";
}
示例11: do_feed
/**
* Load the feed template from the use of an action hook.
*
* If the feed action does not have a hook, then the function will die with a
* message telling the visitor that the feed is not valid.
*
* It is better to only have one hook for each feed.
*
* @since 2.1.0
*
* @global WP_Query $wp_query Used to tell if the use a comment feed.
*/
function do_feed()
{
global $wp_query;
// Determine if we are looking at the main comment feed
$is_main_comments_feed = $wp_query->is_comment_feed() && !$wp_query->is_singular();
/*
* Check the queried object for the existence of posts if it is not a feed for an archive,
* search result, or main comments. By checking for the absense of posts we can prevent rendering the feed
* templates at invalid endpoints. e.g.) /wp-content/plugins/feed/
*/
if (!$wp_query->have_posts() && !($wp_query->is_archive() || $wp_query->is_search() || $is_main_comments_feed)) {
wp_die(__('ERROR: This is not a valid feed.'), '', array('response' => 404));
}
$feed = get_query_var('feed');
// Remove the pad, if present.
$feed = preg_replace('/^_+/', '', $feed);
if ($feed == '' || $feed == 'feed') {
$feed = get_default_feed();
}
if (!has_action("do_feed_{$feed}")) {
wp_die(__('ERROR: This is not a valid feed template.'), '', array('response' => 404));
}
/**
* Fires once the given feed is loaded.
*
* The dynamic portion of the hook name, `$feed`, refers to the feed template name.
* Possible values include: 'rdf', 'rss', 'rss2', and 'atom'.
*
* @since 2.1.0
* @since 4.4.0 The `$feed` parameter was added.
*
* @param bool $is_comment_feed Whether the feed is a comment feed.
* @param string $feed The feed name.
*/
do_action("do_feed_{$feed}", $wp_query->is_comment_feed, $feed);
}
示例12: redirect_canonical
//.........这里部分代码省略.........
} else {
// Taxonomy is accessable via a "pretty-URL"
$redirect['path'] = $tax_url['path'];
}
}
} elseif (is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false) {
$category = get_term_by('slug', get_query_var('category_name'), 'category');
$post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids'));
if (!$category || is_wp_error($category) || !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms)) {
$redirect_url = get_permalink($wp_query->get_queried_object_id());
}
}
// paging and feeds
if (get_query_var('paged') || is_feed() || get_query_var('cpage')) {
if (!$redirect_url) {
$redirect_url = $requested_url;
}
$paged_redirect = @parse_url($redirect_url);
while (preg_match('#/page/?[0-9]+?(/+)?$#', $paged_redirect['path']) || preg_match('#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path']) || preg_match('#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'])) {
// Strip off paging and feed
$paged_redirect['path'] = preg_replace('#/page/?[0-9]+?(/+)?$#', '/', $paged_redirect['path']);
// strip off any existing paging
$paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $paged_redirect['path']);
// strip off feed endings
$paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']);
// strip off any existing comment paging
}
$addl_path = '';
if (is_feed()) {
$addl_path = !empty($addl_path) ? trailingslashit($addl_path) : '';
if (get_query_var('withcomments')) {
$addl_path .= 'comments/';
}
$addl_path .= user_trailingslashit('feed/' . (get_default_feed() == get_query_var('feed') || 'feed' == get_query_var('feed') ? '' : get_query_var('feed')), 'feed');
$redirect['query'] = remove_query_arg('feed', $redirect['query']);
}
if (get_query_var('paged') > 0) {
$paged = get_query_var('paged');
$redirect['query'] = remove_query_arg('paged', $redirect['query']);
if (!is_feed()) {
if ($paged > 1 && !is_single()) {
$addl_path = (!empty($addl_path) ? trailingslashit($addl_path) : '') . user_trailingslashit("page/{$paged}", 'paged');
} elseif (!is_single()) {
$addl_path = !empty($addl_path) ? trailingslashit($addl_path) : '';
}
} elseif ($paged > 1) {
$redirect['query'] = add_query_arg('paged', $paged, $redirect['query']);
}
}
if (get_option('page_comments') && ('newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 || 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1)) {
$addl_path = (!empty($addl_path) ? trailingslashit($addl_path) : '') . user_trailingslashit('comment-page-' . get_query_var('cpage'), 'commentpaged');
$redirect['query'] = remove_query_arg('cpage', $redirect['query']);
}
$paged_redirect['path'] = user_trailingslashit(preg_replace('|/index.php/?$|', '/', $paged_redirect['path']));
// strip off trailing /index.php/
if (!empty($addl_path) && $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false) {
$paged_redirect['path'] = trailingslashit($paged_redirect['path']) . 'index.php/';
}
if (!empty($addl_path)) {
$paged_redirect['path'] = trailingslashit($paged_redirect['path']) . $addl_path;
}
$redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path'];
$redirect['path'] = $paged_redirect['path'];
}
}
// tack on any additional query vars
示例13: parse_search
/**
* Parses a Facetious query string such as '/keyword/hello+world/foo/bar/' and returns its
* corresponding query variables
*
* @param $query string A Facetious query string
* @return array An associative array of query variables
* @author John Blackbourn
**/
function parse_search($query)
{
$return = array();
$parts = explode('/', $query);
# Strip accidental empty parts (such as '/foo//bar/'):
$parts = array_filter($parts);
$parts = array_values($parts);
# If we've got a trailing '/feed/' we need to push the default feed name onto the end
if ('feed' == end($parts)) {
array_push($parts, get_default_feed());
}
# If we've got an odd number of parts then the first part is the keyword search so we prepend the 's' part.
if (count($parts) % 2) {
array_unshift($parts, 's');
}
# Loop over every even-indexed part and populate our query variable array
for ($i = 0; $i < count($parts); $i = $i + 2) {
$key = $this->get_search_var($parts[$i]);
$val = $this->decode($parts[$i + 1]);
$return[$key] = $val;
}
return $return;
}
示例14: get_search_comments_feed_link
function get_search_comments_feed_link($search_query = '', $feed = '')
{
if (empty($search_query)) {
$search = attribute_escape(get_search_query());
} else {
$search = attribute_escape(stripslashes($search_query));
}
if (empty($feed)) {
$feed = get_default_feed();
}
$link = get_option('home') . "?s={$search}&feed=comments-{$feed}";
$link = apply_filters('search_feed_link', $link);
return $link;
}
示例15: send_headers
/**
* Sends additional HTTP headers for caching, content type, etc.
*
* Sets the Content-Type header. Sets the 'error' status (if passed) and optionally exits.
* If showing a feed, it will also send Last-Modified, ETag, and 304 status if needed.
*
* @since 2.0.0
* @since 4.4.0 `X-Pingback` header is added conditionally after posts have been queried in handle_404().
* @access public
*/
public function send_headers()
{
$headers = array();
$status = null;
$exit_required = false;
if (is_user_logged_in()) {
$headers = array_merge($headers, wp_get_nocache_headers());
}
if (!empty($this->query_vars['error'])) {
$status = (int) $this->query_vars['error'];
if (404 === $status) {
if (!is_user_logged_in()) {
$headers = array_merge($headers, wp_get_nocache_headers());
}
$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
} elseif (in_array($status, array(403, 500, 502, 503))) {
$exit_required = true;
}
} elseif (empty($this->query_vars['feed'])) {
$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
} else {
// Set the correct content type for feeds
$type = $this->query_vars['feed'];
if ('feed' == $this->query_vars['feed']) {
$type = get_default_feed();
}
$headers['Content-Type'] = feed_content_type($type) . '; charset=' . get_option('blog_charset');
// We're showing a feed, so WP is indeed the only thing that last changed
if (!empty($this->query_vars['withcomments']) || false !== strpos($this->query_vars['feed'], 'comments-') || empty($this->query_vars['withoutcomments']) && (!empty($this->query_vars['p']) || !empty($this->query_vars['name']) || !empty($this->query_vars['page_id']) || !empty($this->query_vars['pagename']) || !empty($this->query_vars['attachment']) || !empty($this->query_vars['attachment_id']))) {
$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0) . ' GMT';
} else {
$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
}
$wp_etag = '"' . md5($wp_last_modified) . '"';
$headers['Last-Modified'] = $wp_last_modified;
$headers['ETag'] = $wp_etag;
// Support for Conditional GET
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$client_etag = wp_unslash($_SERVER['HTTP_IF_NONE_MATCH']);
} else {
$client_etag = false;
}
$client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
// If string is empty, return 0. If not, attempt to parse into a timestamp
$client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
// Make a timestamp for our most recent modification...
$wp_modified_timestamp = strtotime($wp_last_modified);
if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
$status = 304;
$exit_required = true;
}
}
/**
* Filter the HTTP headers before they're sent to the browser.
*
* @since 2.8.0
*
* @param array $headers The list of headers to be sent.
* @param WP $this Current WordPress environment instance.
*/
$headers = apply_filters('wp_headers', $headers, $this);
if (!empty($status)) {
status_header($status);
}
// If Last-Modified is set to false, it should not be sent (no-cache situation).
if (isset($headers['Last-Modified']) && false === $headers['Last-Modified']) {
unset($headers['Last-Modified']);
// In PHP 5.3+, make sure we are not sending a Last-Modified header.
if (function_exists('header_remove')) {
@header_remove('Last-Modified');
} else {
// In PHP 5.2, send an empty Last-Modified header, but only as a
// last resort to override a header already sent. #WP23021
foreach (headers_list() as $header) {
if (0 === stripos($header, 'Last-Modified')) {
$headers['Last-Modified'] = '';
break;
}
}
}
}
foreach ((array) $headers as $name => $field_value) {
@header("{$name}: {$field_value}");
}
if ($exit_required) {
exit;
}
/**
* Fires once the requested HTTP headers for caching, content type, etc. have been sent.
*
//.........这里部分代码省略.........