本文整理匯總了PHP中is_comments_popup函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_comments_popup函數的具體用法?PHP is_comments_popup怎麽用?PHP is_comments_popup使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_comments_popup函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getWpTemplate
function getWpTemplate()
{
if (defined('WP_USE_THEMES') && WP_USE_THEMES) {
$template = false;
if (is_404() && ($template = get_404_template())) {
} elseif (is_search() && ($template = get_search_template())) {
} elseif (is_tax() && ($template = get_taxonomy_template())) {
} elseif (is_front_page() && ($template = get_front_page_template())) {
} elseif (is_home() && ($template = get_home_template())) {
} elseif (is_attachment() && ($template = get_attachment_template())) {
} elseif (is_single() && ($template = get_single_template())) {
} elseif (is_page() && ($template = get_page_template())) {
} elseif (is_category() && ($template = get_category_template())) {
} elseif (is_tag() && ($template = get_tag_template())) {
} elseif (is_author() && ($template = get_author_template())) {
} elseif (is_date() && ($template = get_date_template())) {
} elseif (is_archive() && ($template = get_archive_template())) {
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
} elseif (is_paged() && ($template = get_paged_template())) {
} else {
$template = get_index_template();
}
return str_replace(ABSPATH, '', $template);
} else {
return null;
}
}
示例2: js_setup
/**
* Enqueue required javascript libraries.
*
* @action: init
**/
function js_setup()
{
if (is_single() || is_comments_popup() || is_admin()) {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery.textnode', '/' . PLUGINDIR . '/openid/files/jquery.textnode.min.js', array('jquery'), WPOPENID_PLUGIN_REVISION);
wp_enqueue_script('jquery.xpath', '/' . PLUGINDIR . '/openid/files/jquery.xpath.min.js', array('jquery'), WPOPENID_PLUGIN_REVISION);
wp_enqueue_script('openid', '/' . PLUGINDIR . '/openid/files/openid.min.js', array('jquery', 'jquery.textnode'), WPOPENID_PLUGIN_REVISION);
}
}
示例3: load_template
/**
* Copy-pasta of wp-includes/template-loader.php
*/
private function load_template()
{
do_action('template_redirect');
$template = false;
if (is_404() && ($template = get_404_template())) {
} elseif (is_search() && ($template = get_search_template())) {
} elseif (is_front_page() && ($template = get_front_page_template())) {
} elseif (is_home() && ($template = get_home_template())) {
} elseif (is_post_type_archive() && ($template = get_post_type_archive_template())) {
} elseif (is_tax() && ($template = get_taxonomy_template())) {
} elseif (is_attachment() && ($template = get_attachment_template())) {
remove_filter('the_content', 'prepend_attachment');
} elseif (is_single() && ($template = get_single_template())) {
} elseif (is_page() && ($template = get_page_template())) {
} elseif (is_category() && ($template = get_category_template())) {
} elseif (is_tag() && ($template = get_tag_template())) {
} elseif (is_author() && ($template = get_author_template())) {
} elseif (is_date() && ($template = get_date_template())) {
} elseif (is_archive() && ($template = get_archive_template())) {
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
} elseif (is_paged() && ($template = get_paged_template())) {
} else {
$template = get_index_template();
}
/**
* Filter the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
if ($template = apply_filters('template_include', $template)) {
$template_contents = file_get_contents($template);
$included_header = $included_footer = false;
if (false !== stripos($template_contents, 'get_header();')) {
do_action('get_header', null);
locate_template('header.php', true, false);
$included_header = true;
}
include $template;
if (false !== stripos($template_contents, 'get_footer();')) {
do_action('get_footer', null);
locate_template('footer.php', true, false);
$included_footer = true;
}
if ($included_header && $included_footer) {
global $wp_scripts;
$wp_scripts->done = array();
}
}
return;
}
示例4: include_type
function include_type()
{
global $gantry;
$is_wp3 = version_compare($gantry->platform->platform_version, "3.0", ">=");
$main_body_template = false;
// get the main template page loaded
$template_page = basename($gantry->retrieveTemp('template', 'page_name'));
// load main body layout of the exact match is there (shortcut)
if ('index.php' != strtolower($template_page) && ($main_body_template = $this->locate_type(array($template_page)))) {
// see if we need to load any subcases of the mainbody for the template page used
} elseif ($main_body_template = $this->get_taxonomy_page($template_page)) {
} elseif ($main_body_template = $this->get_single_page($template_page)) {
} elseif ($main_body_template = $this->get_page_page($template_page)) {
} elseif ($main_body_template = $this->get_category_page($template_page)) {
} elseif ($main_body_template = $this->get_tag_page($template_page)) {
} elseif ($main_body_template = $this->get_author_page($template_page)) {
// load based on query options (used for index.php template)
} elseif (is_404() && ($main_body_template = $this->get_404_type())) {
} elseif (is_search() && ($main_body_template = $this->get_search_type())) {
} elseif (is_tax() && ($main_body_template = $this->get_taxonomy_type())) {
} elseif ($is_wp3 && is_front_page() && ($main_body_template = $this->get_front_page_type())) {
} elseif (is_home() && ($main_body_template = $this->get_home_type())) {
} elseif (is_attachment() && ($main_body_template = $this->get_attachment_type())) {
remove_filter('the_content', 'prepend_attachment');
} elseif (is_single() && ($main_body_template = $this->get_single_type())) {
} elseif (is_page() && ($main_body_template = $this->get_page_type())) {
} elseif (is_category() && ($main_body_template = $this->get_category_type())) {
} elseif (is_tag() && ($main_body_template = $this->get_tag_type())) {
} elseif (is_author() && ($main_body_template = $this->get_author_type())) {
} elseif (is_date() && ($main_body_template = $this->get_date_type())) {
} elseif (is_archive() && ($main_body_template = $this->get_archive_type())) {
} elseif (is_comments_popup() && ($main_body_template = $this->get_comments_popup_type())) {
} elseif (is_paged() && ($main_body_template = $this->get_paged_type())) {
} else {
$main_body_template = $this->get_index_type();
}
if ($main_body_template = apply_filters('gantry_mainbody_include', $main_body_template)) {
include $main_body_template;
}
return;
}
示例5: xtreme_get_template
function xtreme_get_template()
{
global $wp;
if (defined('WP_USE_THEMES') && constant('WP_USE_THEMES')) {
if (is_404() && ($template = get_404_template())) {
return redefine_pagenow($template);
} elseif (is_search() && ($template = get_search_template())) {
return redefine_pagenow($template);
} elseif (is_tax() && ($template = get_taxonomy_template())) {
return redefine_pagenow($template);
} elseif (is_front_page() && ($template = get_front_page_template())) {
return redefine_pagenow($template);
} elseif (is_home() && ($template = get_home_template())) {
return redefine_pagenow($template);
} elseif (is_attachment() && ($template = get_attachment_template())) {
return redefine_pagenow($template);
} elseif (is_single() && ($template = get_single_template())) {
return redefine_pagenow($template);
} elseif (is_page() && ($template = get_page_template())) {
return redefine_pagenow($template);
} elseif (is_category() && ($template = get_category_template())) {
return redefine_pagenow($template);
} elseif (is_tag() && ($template = get_tag_template())) {
return redefine_pagenow($template);
} elseif (is_author() && ($template = get_author_template())) {
return redefine_pagenow($template);
} elseif (is_date() && ($template = get_date_template())) {
return redefine_pagenow($template);
} elseif (is_archive() && ($template = get_archive_template())) {
return redefine_pagenow($template);
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
return redefine_pagenow($template);
} elseif (is_paged() && ($template = get_paged_template())) {
return redefine_pagenow($template);
} else {
$template = get_index_template();
return redefine_pagenow($template);
}
}
}
示例6: check_template
function check_template()
{
if (is_404() && ($template = get_404_template())) {
$this->template = $template;
} elseif (is_search() && ($template = get_search_template())) {
$this->template = $template;
} elseif (is_tax() && ($template = get_taxonomy_template())) {
$this->template = $template;
} elseif (is_home() && ($template = get_home_template())) {
$this->template = $template;
} elseif (is_attachment() && ($template = get_attachment_template())) {
$this->template = $template;
} elseif (is_single() && ($template = get_single_template())) {
$this->template = $template;
} elseif (is_page() && ($template = get_page_template())) {
$this->template = $template;
} elseif (is_category() && ($template = get_category_template())) {
$this->template = $template;
} elseif (is_tag() && ($template = get_tag_template())) {
$this->template = $template;
} elseif (is_author() && ($template = get_author_template())) {
$this->template = $template;
} elseif (is_date() && ($template = get_date_template())) {
$this->template = $template;
} elseif (is_archive() && ($template = get_archive_template())) {
$this->template = $template;
} elseif (is_comments_popup() && ($template = get_comments_popup_template())) {
$this->template = $template;
} elseif (is_paged() && ($template = get_paged_template())) {
$this->template = $template;
} else {
$this->template = function_exists('get_index_template') ? get_index_template() : TEMPLATEPATH . "/index.php";
}
$this->template = apply_filters('template_include', $this->template);
// Hook into the footer so we can echo the active template
add_action('wp_footer', array(&$this, 'show_template'), 100);
}
示例7: is_likes_visible
/**
* Are likes visible in this context?
*
* Some of this code was taken and modified from sharing_display() to ensure
* similar logic and filters apply here, too.
*/
function is_likes_visible()
{
global $wp_current_filter;
// Used to check 'get_the_excerpt' filter
global $post;
// Used to apply 'sharing_show' filter
// Never show on feeds or previews
if (is_feed() || is_preview() || is_comments_popup()) {
$enabled = false;
// Not a feed or preview, so what is it?
} else {
if (in_the_loop()) {
// If in the loop, check if the current post is likeable
$enabled = $this->is_post_likeable();
} else {
// Otherwise, check and see if likes are enabled sitewide
$enabled = $this->is_enabled_sitewide();
}
if (post_password_required()) {
$enabled = false;
}
/** Other Checks ******************************************************/
// Do not show on excerpts
if (in_array('get_the_excerpt', (array) $wp_current_filter)) {
$enabled = false;
// Sharing Setting Overrides ****************************************
} else {
// Single post
if (is_singular('post')) {
if (!$this->is_single_post_enabled()) {
$enabled = false;
}
// Single page
} elseif (is_page()) {
if (!$this->is_single_page_enabled()) {
$enabled = false;
}
// Attachment
} elseif (is_attachment()) {
if (!$this->is_attachment_enabled()) {
$enabled = false;
}
// All other loops
} elseif (!$this->is_index_enabled()) {
$enabled = false;
}
}
}
// Check that the post is a public, published post.
if ('attachment' == $post->post_type) {
$post_status = get_post_status($post->post_parent);
} else {
$post_status = $post->post_status;
}
if ('publish' != $post_status) {
$enabled = false;
}
// Run through the sharing filters
$enabled = apply_filters('sharing_show', $enabled, $post);
return (bool) apply_filters('wpl_is_likes_visible', $enabled);
}
示例8: redirect_canonical
/**
* Redirects incoming links to the proper URL based on the site url.
*
* Search engines consider www.somedomain.com and somedomain.com to be two
* different URLs when they both go to the same location. This SEO enhancement
* prevents penality for duplicate content by redirecting all incoming links to
* one or the other.
*
* Prevents redirection for feeds, trackbacks, searches, comment popup, and
* admin URLs. Does not redirect on IIS, page/post previews, and on form data.
*
* Will also attempt to find the correct link when a user enters a URL that does
* not exist based on exact WordPress query. Will instead try to parse the URL
* or query in an attempt to figure the correct page to go to.
*
* @since 2.3.0
* @uses $wp_rewrite
* @uses $is_IIS
*
* @param string $requested_url Optional. The URL that was requested, used to
* figure if redirect is needed.
* @param bool $do_redirect Optional. Redirect to the new URL.
* @return null|false|string Null, if redirect not needed. False, if redirect
* not needed or the string of the URL
*/
function redirect_canonical($requested_url = null, $do_redirect = true)
{
global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
if (is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || isset($_POST) && count($_POST) || is_preview() || is_robots()) {
return;
}
if (!$requested_url) {
// build the URL in the address bar
$requested_url = is_ssl() ? 'https://' : 'http://';
$requested_url .= $_SERVER['HTTP_HOST'];
$requested_url .= $_SERVER['REQUEST_URI'];
}
$original = @parse_url($requested_url);
if (false === $original) {
return;
}
// Some PHP setups turn requests for / into /index.php in REQUEST_URI
// See: http://trac.wordpress.org/ticket/5017
// See: http://trac.wordpress.org/ticket/7173
// Disabled, for now:
// $original['path'] = preg_replace('|/index\.php$|', '/', $original['path']);
$redirect = $original;
$redirect_url = false;
// Notice fixing
if (!isset($redirect['path'])) {
$redirect['path'] = '';
}
if (!isset($redirect['query'])) {
$redirect['query'] = '';
}
if (is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p'))) {
$vars = $wpdb->get_results($wpdb->prepare("SELECT post_type, post_parent FROM {$wpdb->posts} WHERE ID = %d", $id));
if (isset($vars[0]) && ($vars = $vars[0])) {
if ('revision' == $vars->post_type && $vars->post_parent > 0) {
$id = $vars->post_parent;
}
if ($redirect_url = get_permalink($id)) {
$redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id', 'post_type'), $redirect['query']);
}
}
}
// These tests give us a WP-generated permalink
if (is_404()) {
// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
$id = max(get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id'));
if ($id && ($redirect_post = get_post($id))) {
$post_type_obj = get_post_type_object($redirect_post->post_type);
if ($post_type_obj->public) {
$redirect_url = get_permalink($redirect_post);
$redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id', 'post_type'), $redirect['query']);
}
}
if (!$redirect_url) {
$redirect_url = redirect_guess_404_permalink();
}
} elseif (is_object($wp_rewrite) && $wp_rewrite->using_permalinks()) {
// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
if (is_attachment() && !empty($_GET['attachment_id']) && !$redirect_url) {
if ($redirect_url = get_attachment_link(get_query_var('attachment_id'))) {
$redirect['query'] = remove_query_arg('attachment_id', $redirect['query']);
}
} elseif (is_single() && !empty($_GET['p']) && !$redirect_url) {
if ($redirect_url = get_permalink(get_query_var('p'))) {
$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
}
if (get_query_var('page')) {
$redirect_url = trailingslashit($redirect_url) . user_trailingslashit(get_query_var('page'), 'single_paged');
$redirect['query'] = remove_query_arg('page', $redirect['query']);
}
} elseif (is_single() && !empty($_GET['name']) && !$redirect_url) {
if ($redirect_url = get_permalink($wp_query->get_queried_object_id())) {
$redirect['query'] = remove_query_arg('name', $redirect['query']);
}
} elseif (is_page() && !empty($_GET['page_id']) && !$redirect_url) {
if ($redirect_url = get_permalink(get_query_var('page_id'))) {
//.........這裏部分代碼省略.........
示例9: redirect_canonical
/**
* Redirects incoming links to the proper URL based on the site url.
*
* Search engines consider www.somedomain.com and somedomain.com to be two
* different URLs when they both go to the same location. This SEO enhancement
* prevents penality for duplicate content by redirecting all incoming links to
* one or the other.
*
* Prevents redirection for feeds, trackbacks, searches, comment popup, and
* admin URLs. Does not redirect on IIS, page/post previews, and on form data.
*
* Will also attempt to find the correct link when a user enters a URL that does
* not exist based on exact WordPress query. Will instead try to parse the URL
* or query in an attempt to figure the correct page to go to.
*
* @since 2.3.0
* @uses $wp_rewrite
* @uses $is_IIS
*
* @param string $requested_url Optional. The URL that was requested, used to
* figure if redirect is needed.
* @param bool $do_redirect Optional. Redirect to the new URL.
* @return null|false|string Null, if redirect not needed. False, if redirect
* not needed or the string of the URL
*/
function redirect_canonical($requested_url=null, $do_redirect=true) {
global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
return;
if ( !$requested_url ) {
// build the URL in the address bar
$requested_url = ( !empty($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
$requested_url .= $_SERVER['HTTP_HOST'];
$requested_url .= $_SERVER['REQUEST_URI'];
}
$original = @parse_url($requested_url);
if ( false === $original )
return;
// Some PHP setups turn requests for / into /index.php in REQUEST_URI
// See: http://trac.wordpress.org/ticket/5017
// See: http://trac.wordpress.org/ticket/7173
// Disabled, for now:
// $original['path'] = preg_replace('|/index\.php$|', '/', $original['path']);
$redirect = $original;
$redirect_url = false;
// Notice fixing
if ( !isset($redirect['path']) ) $redirect['path'] = '';
if ( !isset($redirect['query']) ) $redirect['query'] = '';
if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) {
$vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
if ( isset($vars[0]) && $vars = $vars[0] ) {
if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
$id = $vars->post_parent;
if ( $redirect_url = get_permalink($id) )
$redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']);
}
}
// These tests give us a WP-generated permalink
if ( is_404() ) {
$redirect_url = redirect_guess_404_permalink();
} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
if ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
if ( $redirect_url = get_permalink(get_query_var('p')) )
$redirect['query'] = remove_query_arg('p', $redirect['query']);
if ( get_query_var( 'page' ) ) {
$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
}
} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
if ( $redirect_url = get_permalink(get_query_var('page_id')) )
$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
} elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
$m = get_query_var('m');
switch ( strlen($m) ) {
case 4: // Yearly
$redirect_url = get_year_link($m);
break;
case 6: // Monthly
$redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) );
break;
case 8: // Daily
$redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
break;
}
if ( $redirect_url )
$redirect['query'] = remove_query_arg('m', $redirect['query']);
// now moving on to non ?m=X year/month/day links
} elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
//.........這裏部分代碼省略.........
示例10: is_likes_visible
/**
* Are likes visible in this context?
*
* Some of this code was taken and modified from sharing_display() to ensure
* similar logic and filters apply here, too.
*/
function is_likes_visible()
{
global $post, $wp_current_filter;
// Used to apply 'sharing_show' filter
// Never show on feeds or previews
if (is_feed() || is_preview() || is_comments_popup()) {
$enabled = false;
// Not a feed or preview, so what is it?
} else {
if (in_the_loop()) {
// If in the loop, check if the current post is likeable
$enabled = $this->is_post_likeable();
} else {
// Otherwise, check and see if likes are enabled sitewide
$enabled = $this->is_enabled_sitewide();
}
if (post_password_required()) {
$enabled = false;
}
if (in_array('get_the_excerpt', (array) $wp_current_filter)) {
$enabled = false;
}
// Sharing Setting Overrides ****************************************
// Single post including custom post types
if (is_single()) {
if (!$this->is_single_post_enabled($post->post_type)) {
$enabled = false;
}
// Single page
} elseif (is_page() && !is_front_page()) {
if (!$this->is_single_page_enabled()) {
$enabled = false;
}
// Attachment
} elseif (is_attachment()) {
if (!$this->is_attachment_enabled()) {
$enabled = false;
}
// All other loops
} elseif (!$this->is_index_enabled()) {
$enabled = false;
}
}
if (is_object($post)) {
// Check that the post is a public, published post.
if ('attachment' == $post->post_type) {
$post_status = get_post_status($post->post_parent);
} else {
$post_status = $post->post_status;
}
if ('publish' != $post_status) {
$enabled = false;
}
}
// Run through the sharing filters
/** This filter is documented in modules/sharedaddy/sharing-service.php */
$enabled = apply_filters('sharing_show', $enabled, $post);
/**
* Filters whether the Likes should be visible or not.
* Allows overwriting the options set in Settings > Sharing.
*
* @since 2.2.0
*
* @param bool $enabled Should the Likes be visible?
*/
return (bool) apply_filters('wpl_is_likes_visible', $enabled);
}
示例11: check_canonical_url
public function check_canonical_url($requested_url = '', $do_redirect = true)
{
global $wp_query, $post, $is_IIS;
// don't redirect in same cases as WP
if (is_trackback() || is_search() || is_comments_popup() || is_admin() || is_preview() || is_robots() || $is_IIS && !iis7_supports_permalinks()) {
return;
}
// don't redirect mysite.com/?attachment_id= to mysite.com/en/?attachment_id=
if (1 == $this->options['force_lang'] && is_attachment() && isset($_GET['attachment_id'])) {
return;
}
// if the default language code is not hidden and the static front page url contains the page name
// the customizer lands here and the code below would redirect to the list of posts
if (isset($_POST['wp_customize'], $_POST['customized'])) {
return;
}
// don't redirect if we are on a static front page
if ($this->options['redirect_lang'] && isset($this->page_on_front) && is_page($this->page_on_front)) {
return;
}
if (empty($requested_url)) {
$requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
if (is_single() || is_page()) {
if (isset($post->ID) && $this->model->is_translated_post_type($post->post_type)) {
$language = $this->model->get_post_language((int) $post->ID);
}
} elseif (is_category() || is_tag() || is_tax()) {
$obj = $wp_query->get_queried_object();
if ($this->model->is_translated_taxonomy($obj->taxonomy)) {
$language = $this->model->get_term_language((int) $obj->term_id);
}
} elseif ($wp_query->is_posts_page) {
$obj = $wp_query->get_queried_object();
$language = $this->model->get_post_language((int) $obj->ID);
}
if (empty($language)) {
$language = $this->curlang;
$redirect_url = $requested_url;
} else {
// first get the canonical url evaluated by WP
$redirect_url = !($redirect_url = redirect_canonical($requested_url, false)) ? $requested_url : $redirect_url;
// then get the right language code in url
$redirect_url = $this->options['force_lang'] ? $this->links_model->switch_language_in_link($redirect_url, $language) : $this->links_model->remove_language_from_link($redirect_url);
// works only for default permalinks
}
// allow plugins to change the redirection or even cancel it by setting $redirect_url to false
$redirect_url = apply_filters('pll_check_canonical_url', $redirect_url, $language);
// the language is not correctly set so let's redirect to the correct url for this object
if ($do_redirect && $redirect_url && $requested_url != $redirect_url) {
wp_redirect($redirect_url, 301);
exit;
}
return $redirect_url;
}
示例12: if
} else if ( is_page() && get_page_template() ) {
include(get_page_template());
exit;
} else if ( is_category() && get_category_template()) {
include(get_category_template());
exit;
} else if ( is_author() && get_author_template() ) {
include(get_author_template());
exit;
} else if ( is_date() && get_date_template() ) {
include(get_date_template());
exit;
} else if ( is_archive() && get_archive_template() ) {
include(get_archive_template());
exit;
} else if ( is_comments_popup() && get_comments_popup_template() ) {
include(get_comments_popup_template());
exit;
} else if ( is_paged() && get_paged_template() ) {
include(get_paged_template());
exit;
} else if ( file_exists(TEMPLATEPATH . "/index.php") ) {
include(TEMPLATEPATH . "/index.php");
exit;
}
} else {
// Process feeds and trackbacks even if not using themes.
if ( is_feed() && empty($doing_rss) ) {
include(ABSPATH . '/wp-feed.php');
exit;
} else if ( is_trackback() && empty($doing_trackback) ) {
示例13: hybrid_body_class
/**
* Dynamic body class based on page
*
* @since 0.1
*/
function hybrid_body_class()
{
global $wp_query, $hybrid_settings;
$class = array();
if (is_front_page() || is_home()) {
$class[] = 'home';
$class[] = 'front-page';
} elseif (is_attachment()) {
global $post;
$class[] = 'attachment';
if (wp_attachment_is_image($post->ID)) {
$class[] = 'attachment-image';
}
$mime = get_post_mime_type($post->ID);
$class[] = 'attachment-' . str_replace('/', '-', $mime);
} elseif (is_single()) {
$class[] = 'single';
$class[] = 'single-' . $wp_query->post->ID;
if (function_exists('is_sticky')) {
if (is_sticky($wp_query->post->ID)) {
$class[] = 'single-sticky';
}
}
} elseif (is_page()) {
$class[] = 'page page-' . $wp_query->post->ID;
if (is_page_template()) {
$class[] = 'page-template';
$class[] = 'page-template-' . str_replace('.php', '', get_post_meta($wp_query->post->ID, '_wp_page_template', true));
}
} elseif (is_category()) {
$cat = $wp_query->get_queried_object();
$class[] = 'category';
$class[] = 'category-' . $cat->slug;
} elseif (is_tag()) {
$tags = $wp_query->get_queried_object();
$class[] = 'tag';
$class[] = 'tag-' . $tags->slug;
} elseif (is_search()) {
$class[] = 'search';
} elseif (is_404()) {
$class[] = 'error-404';
} elseif (is_year()) {
$class[] = 'year';
} elseif (is_month()) {
$class[] = 'month';
} elseif (is_day()) {
$class[] = 'day';
} elseif (is_time()) {
$class[] = 'time';
} elseif (is_author()) {
$author = $wp_query->get_queried_object();
$class[] = 'author';
$class[] = ' author-' . $author->user_nicename;
}
if (is_user_logged_in()) {
$class[] = 'logged-in';
} else {
$class[] = 'not-logged-in';
}
if (is_date()) {
$class[] = 'date';
}
if (is_archive()) {
$class[] = 'archive';
}
if (is_paged()) {
$class[] = 'paged';
}
if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) {
$class[] = 'paged';
$class[] = 'paged-' . $page;
if (is_home() || is_front_page()) {
$class[] = 'home-paged-' . $page;
} elseif (is_attachment()) {
$class[] = 'attachment-paged-' . $page;
} elseif (is_single()) {
$class[] = 'single-paged-' . $page;
} elseif (is_page()) {
$class[] = 'page-paged-' . $page;
} elseif (is_category()) {
$class[] = 'category-paged-' . $page;
} elseif (is_tag()) {
$class[] = 'tag-paged-' . $page;
} elseif (is_date()) {
$class[] = 'date-paged-' . $page;
} elseif (is_author()) {
$class[] = 'author-paged-' . $page;
} elseif (is_search()) {
$class[] = 'search-paged-' . $page;
}
}
if (is_comments_popup()) {
$class[] = 'comments-popup';
}
if ($hybrid_settings['primary_inserts_default']) {
//.........這裏部分代碼省略.........
示例14: debug_info
/**
* Print debug information regarding the current state of the page to the screen.
*
* @access public
* @static
* @param array $options
* @param bool $comment (default: false)
* @return void
*/
public static function debug_info(array $options, $comment = false)
{
global $post;
$output = array();
$output[] = $comment ? '<!--' : '<pre>';
$output[] = '######################## HaG DEBUG INFO ########################';
$output[] = sprintf('404: %b', is_404());
$output[] = sprintf('Search: %b', is_search());
$output[] = sprintf('Archive: %b', is_archive());
$output[] = sprintf('Custom Taxonomy Archive: %b', is_tax());
$output[] = sprintf('Category Archive: %b', is_category());
$output[] = sprintf('Tag Archive: %b', is_tag());
$output[] = sprintf('Author Archive: %b', is_author());
$output[] = sprintf('Date Archive: %b', is_date());
$output[] = sprintf('Year Archive: %b', is_year());
$output[] = sprintf('Month Archive: %b', is_month());
$output[] = sprintf('Day Archive: %b', is_day());
$output[] = sprintf('Custom Post-Type Archive: %b', is_post_type_archive());
$output[] = sprintf('Paged: %b', is_paged());
$output[] = sprintf('Singular Page: %b', is_singular());
$output[] = sprintf('Single Post Page: %b', is_single());
$output[] = sprintf('Attachment Post: %b', is_attachment());
$output[] = sprintf('Static Page: %b', is_page());
$output[] = sprintf('Custom Static Page: %b', is_page_template());
$output[] = sprintf('Site Front Page: %b', is_front_page());
$output[] = sprintf('Posts Home Page: %b', is_home());
$output[] = sprintf('Comments Popup Page: %b', is_comments_popup());
$output[] = '######################## QUERY ############################';
ob_start();
var_dump(get_queried_object());
$output[] = $comment ? ob_get_clean() : htmlentities(ob_get_clean());
$output[] = '######################## $POST ########################';
ob_start();
var_dump($post);
$output[] = $comment ? ob_get_clean() : htmlentities(ob_get_clean());
$output[] = '######################## $OPTIONS ########################';
ob_start();
var_dump($options);
$output[] = $comment ? ob_get_clean() : htmlentities(ob_get_clean());
$output[] = $comment ? '-->' : '</pre>';
echo implode(PHP_EOL, $output);
}
示例15: is_likes_visible
/**
* Are likes visible in this context?
*
* Some of this code was taken and modified from sharing_display() to ensure
* similar logic and filters apply here, too.
*/
function is_likes_visible()
{
require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
if (Jetpack_Sync_Settings::is_syncing()) {
return false;
}
global $post, $wp_current_filter;
// Used to apply 'sharing_show' filter
// @todo: Remove this block when 4.5 is the minimum
global $wp_version;
$comment_popup = false;
if (version_compare($wp_version, '4.5-alpha', '<=')) {
$comment_popup = is_comments_popup();
}
// End 4.5 conditional block.
// Never show on feeds or previews
if (is_feed() || is_preview() || $comment_popup) {
// @todo: Remove $comment_popup when 4.5 is minimum.
$enabled = false;
// Not a feed or preview, so what is it?
} else {
if (in_the_loop()) {
// If in the loop, check if the current post is likeable
$enabled = $this->is_post_likeable();
} else {
// Otherwise, check and see if likes are enabled sitewide
$enabled = $this->is_enabled_sitewide();
}
if (post_password_required()) {
$enabled = false;
}
if (in_array('get_the_excerpt', (array) $wp_current_filter)) {
$enabled = false;
}
// Sharing Setting Overrides ****************************************
// Single post including custom post types
if (is_single()) {
if (!$this->is_single_post_enabled($post->post_type)) {
$enabled = false;
}
// Single page
} elseif (is_page() && !is_front_page()) {
if (!$this->is_single_page_enabled()) {
$enabled = false;
}
// Attachment
} elseif (is_attachment()) {
if (!$this->is_attachment_enabled()) {
$enabled = false;
}
// All other loops
} elseif (!$this->is_index_enabled()) {
$enabled = false;
}
}
if (is_object($post)) {
// Check that the post is a public, published post.
if ('attachment' == $post->post_type) {
$post_status = get_post_status($post->post_parent);
} else {
$post_status = $post->post_status;
}
if ('publish' != $post_status) {
$enabled = false;
}
}
// Run through the sharing filters
/** This filter is documented in modules/sharedaddy/sharing-service.php */
$enabled = apply_filters('sharing_show', $enabled, $post);
/**
* Filters whether the Likes should be visible or not.
* Allows overwriting the options set in Settings > Sharing.
*
* @module likes
*
* @since 2.2.0
*
* @param bool $enabled Should the Likes be visible?
*/
return (bool) apply_filters('wpl_is_likes_visible', $enabled);
}