本文整理汇总了PHP中is_robots函数的典型用法代码示例。如果您正苦于以下问题:PHP is_robots函数的具体用法?PHP is_robots怎么用?PHP is_robots使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_robots函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_snippet
/**
* Add custom javascript within head section.
*
* @since 1.0.0
*/
public function add_snippet()
{
if (\is_admin()) {
return;
}
if (\is_feed()) {
return;
}
if (\is_robots()) {
return;
}
if (\is_trackback()) {
return;
}
$disable_recording = boolval(\get_post_meta(\get_the_id(), 'smartlook_disable_rec', true));
// Disable recording for this content type
if ($disable_recording) {
return;
}
$snippet = trim(\get_option('smartlook_snippet'));
if (empty($snippet)) {
return;
}
echo $snippet;
}
示例2: my_template_redirect
function my_template_redirect()
{
global $wp, $ocmx_post_types;
$wp->query_vars["post_type"] = "";
$ocmx_post_types = array();
$ocmx_post_types[] = "quote";
$ocmx_post_types[] = "info-box";
$ocmx_post_types[] = "portfolio";
if (in_array($wp->query_vars["post_type"], $ocmx_post_types)) {
if (is_robots()) {
do_action('do_robots');
return;
} elseif (is_feed()) {
do_feed();
return;
} elseif (is_trackback()) {
include ABSPATH . 'wp-trackback.php';
return;
} elseif ($wp->query_vars["name"]) {
include TEMPLATEPATH . "/single-" . $wp->query_vars["post_type"] . ".php";
die;
} else {
include TEMPLATEPATH . "/" . $wp->query_vars["post_type"] . ".php";
die;
}
}
}
示例3: bogo_init
function bogo_init()
{
bogo_languages();
if (!(is_admin() || is_robots() || is_feed() || is_trackback())) {
$locale = get_locale();
if (!isset($_COOKIE['lang']) || $_COOKIE['lang'] != $locale) {
setcookie('lang', $locale, 0, '/');
}
}
}
示例4: wp_footer
function wp_footer()
{
if (!is_admin() && !is_feed() && !is_robots() && !is_trackback()) {
$text = get_option('shfs_insert_footer', '');
$text = convert_smilies($text);
$text = do_shortcode($text);
if ($text != '') {
echo $text, "\n";
}
}
}
示例5: pt_footer
/**
*
*
* @desc Display blog footer. Show Publishthis logo if needed
*/
function pt_footer()
{
global $publishthis;
if (!is_admin() && !is_feed() && !is_robots() && !is_trackback()) {
try {
echo pt_curated_by(), "\n";
echo "<script type='text/javascript' src='http://curateby.publishthis.com/clients.js'></script>";
} catch (Exception $ex) {
}
}
}
示例6: stats_template_redirect
function stats_template_redirect()
{
global $wp_the_query, $current_user, $stats_footer;
if (is_feed() || is_robots() || is_trackback()) {
return;
}
$options = stats_get_options();
// Ensure this is always setup for the check below
$options['reg_users'] = empty($options['reg_users']) ? false : true;
if (!$options['reg_users'] && !empty($current_user->ID)) {
return;
}
add_action('wp_footer', 'stats_footer', 101);
add_action('wp_head', 'stats_add_shutdown_action');
$blog = Jetpack::get_option('id');
$tz = get_option('gmt_offset');
$v = 'ext';
$j = sprintf('%s:%s', JETPACK__API_VERSION, JETPACK__VERSION);
if ($wp_the_query->is_single || $wp_the_query->is_page || $wp_the_query->is_posts_page) {
// Store and reset the queried_object and queried_object_id
// Otherwise, redirect_canonical() will redirect to home_url( '/' ) for show_on_front = page sites where home_url() is not all lowercase.
// Repro:
// 1. Set home_url = http://ExamPle.com/
// 2. Set show_on_front = page
// 3. Set page_on_front = something
// 4. Visit http://example.com/
$queried_object = isset($wp_the_query->queried_object) ? $wp_the_query->queried_object : null;
$queried_object_id = isset($wp_the_query->queried_object_id) ? $wp_the_query->queried_object_id : null;
$post = $wp_the_query->get_queried_object_id();
$wp_the_query->queried_object = $queried_object;
$wp_the_query->queried_object_id = $queried_object_id;
} else {
$post = '0';
}
$http = is_ssl() ? 'https' : 'http';
$week = gmdate('YW');
$data = stats_array(compact('v', 'j', 'blog', 'post', 'tz'));
$stats_footer = <<<END
\t<script src="{$http}://stats.wordpress.com/e-{$week}.js" type="text/javascript"></script>
\t<script type="text/javascript">
\tst_go({{$data}});
\tvar load_cmc = function(){linktracker_init({$blog},{$post},2);};
\tif ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
\telse load_cmc();
\t</script>
END;
if (isset($options['hide_smile']) && $options['hide_smile']) {
$stats_footer .= "\n<style type='text/css'>img#wpstats{display:none}</style>";
}
}
示例7: is_active
/**
* Is Active?
*/
function is_active()
{
// Always allow access to robots.txt
if (is_robots()) {
return false;
}
if ((bool) get_option('password_protected_status')) {
if (!defined('DONOTCACHEPAGE')) {
define('DONOTCACHEPAGE', true);
}
return true;
}
return false;
}
示例8: add_snippet
/**
* Add custom javascript within head section.
*
* @since 1.0.0
*/
public function add_snippet()
{
if (\is_admin()) {
return;
}
if (\is_feed()) {
return;
}
if (\is_robots()) {
return;
}
if (\is_trackback()) {
return;
}
$snippet = trim(\get_option('jaco_snippet'));
if (empty($snippet)) {
return;
}
echo $snippet;
}
示例9: stats_template_redirect
function stats_template_redirect()
{
global $wp_the_query, $current_user, $stats_footer;
if (is_feed() || is_robots() || is_trackback()) {
return;
}
$options = stats_get_options();
// Ensure this is always setup for the check below
$options['reg_users'] = empty($options['reg_users']) ? false : true;
if (!$options['reg_users'] && !empty($current_user->ID)) {
return;
}
add_action('wp_footer', 'stats_footer', 101);
add_action('wp_head', 'stats_add_shutdown_action');
$blog = Jetpack::get_option('id');
$v = 'ext';
$j = sprintf('%s:%s', JETPACK__API_VERSION, JETPACK__VERSION);
if ($wp_the_query->is_single || $wp_the_query->is_page || $wp_the_query->is_posts_page) {
$post = $wp_the_query->get_queried_object_id();
} else {
$post = '0';
}
$http = is_ssl() ? 'https' : 'http';
$week = gmdate('YW');
$data = stats_array(compact('v', 'j', 'blog', 'post'));
$stats_footer = <<<END
\t<script src="{$http}://stats.wordpress.com/e-{$week}.js" type="text/javascript"></script>
\t<script type="text/javascript">
\tst_go({{$data}});
\tvar load_cmc = function(){linktracker_init({$blog},{$post},2);};
\tif ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
\telse load_cmc();
\t</script>
END;
if (isset($options['hide_smile']) && $options['hide_smile']) {
$stats_footer .= "\n<style type='text/css'>img#wpstats{display:none}</style>";
}
}
示例10: add_snippet
/**
* Add custom javascript within footer section.
*
* Note: I'm using double quotes instead of single quotes to maintain the script's original structure.
*
* @since 1.0.0
*/
public function add_snippet()
{
if (\is_admin()) {
return;
}
if (\is_feed()) {
return;
}
if (\is_robots()) {
return;
}
if (\is_trackback()) {
return;
}
echo "<script><!--//--><![CDATA[//><!—\r\n";
/**
* Filter the default netscope analytics variable.
*
* @since 1.1.0
* @param string Default variable name.
* @return string Possibly-modified variable name.
*/
$netscope_var = \apply_filters('wpnetscope_default_netscope_var', 'GEMIUS');
// netScope analytics tag
printf("var %s = '%s';", \esc_html($netscope_var), \esc_html($this->get_netscope_tag()));
// netScope account ID
$identifier = trim(\get_option('netscope_gemius_identifier'));
if (!empty($identifier)) {
printf("var pp_gemius_identifier = '%s';", \esc_html($identifier));
}
// netScope extra parameters
$extraparameters = $netscope_var;
printf("var pp_gemius_extraparameters = new Array('gA='+%s);", \esc_html($extraparameters));
echo "var pp_gemius_event = pp_gemius_event || function() {var x = window.gemius_sevents = window.gemius_sevents || []; x[x.length]=arguments;}; ( function(d,t) { var ex; try { var gt=d.createElement(t),s=d.getElementsByTagName(t)[0],l='http'+((location.protocol=='https:')?'s://secure':'://data'); gt.async='true'; gt.src=l+'.netscope.marktest.pt/netscope-gemius.js'; s.parentNode.appendChild(gt);} catch (ex){}}(document,'script'));";
echo "\r\n//--><!]]></script>";
}
示例11:
}
}
}
}
}
}
}
}
}
}
}
}
}
}
} else {
// Process feeds and trackbacks even if not using themes.
if (is_robots()) {
do_action('do_robots');
return;
} else {
if (is_feed()) {
do_feed();
return;
} else {
if (is_trackback()) {
include ABSPATH . '/wp-trackback.php';
return;
}
}
}
}
示例12: 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'))) {
//.........这里部分代码省略.........
示例13: 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']) ) {
//.........这里部分代码省略.........
示例14: stats_template_redirect
function stats_template_redirect()
{
global $current_user, $stats_footer;
if (is_feed() || is_robots() || is_trackback() || is_preview()) {
return;
}
// Should we be counting this user's views?
if (!empty($current_user->ID)) {
$count_roles = stats_get_option('count_roles');
if (!array_intersect($current_user->roles, $count_roles)) {
return;
}
}
add_action('wp_footer', 'stats_footer', 101);
add_action('wp_head', 'stats_add_shutdown_action');
$script = set_url_scheme('//stats.wp.com/e-' . gmdate('YW') . '.js');
$data = stats_build_view_data();
$data_stats_array = stats_array($data);
$stats_footer = <<<END
<script type='text/javascript' src='{$script}' async defer></script>
<script type='text/javascript'>
\t_stq = window._stq || [];
\t_stq.push([ 'view', {{$data_stats_array}} ]);
\t_stq.push([ 'clickTrackerInit', '{$data['blog']}', '{$data['post']}' ]);
</script>
END;
}
示例15: wpcf7_cleanup_upload_files
function wpcf7_cleanup_upload_files()
{
if (is_admin() || 'GET' != $_SERVER['REQUEST_METHOD'] || is_robots() || is_feed() || is_trackback()) {
return;
}
$dir = trailingslashit(wpcf7_upload_tmp_dir());
if (!is_dir($dir) || !is_readable($dir) || !wp_is_writable($dir)) {
return;
}
if ($handle = @opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file == "." || $file == ".." || $file == ".htaccess") {
continue;
}
$mtime = @filemtime($dir . $file);
if ($mtime && time() < $mtime + 60) {
// less than 60 secs old
continue;
}
wpcf7_rmdir_p(path_join($dir, $file));
}
closedir($handle);
}
}