• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_get_server_protocol函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_get_server_protocol函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_server_protocol函数的具体用法?PHP wp_get_server_protocol怎么用?PHP wp_get_server_protocol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_get_server_protocol函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wp_maintenance

/**
 * Die with a maintenance message when conditions are met.
 *
 * Checks for a file in the WordPress root directory named ".maintenance".
 * This file will contain the variable $upgrading, set to the time the file
 * was created. If the file was created less than 10 minutes ago, WordPress
 * enters maintenance mode and displays a message.
 *
 * The default message can be replaced by using a drop-in (maintenance.php in
 * the wp-content directory).
 *
 * @since 3.0.0
 * @access private
 *
 * @global int $upgrading the unix timestamp marking when upgrading WordPress began.
 */
function wp_maintenance()
{
    if (!file_exists(ABSPATH . '.maintenance') || wp_installing()) {
        return;
    }
    global $upgrading;
    include ABSPATH . '.maintenance';
    // If the $upgrading timestamp is older than 10 minutes, don't die.
    if (time() - $upgrading >= 600) {
        return;
    }
    if (file_exists(WP_CONTENT_DIR . '/maintenance.php')) {
        require_once WP_CONTENT_DIR . '/maintenance.php';
        die;
    }
    wp_load_translations_early();
    $protocol = wp_get_server_protocol();
    header("{$protocol} 503 Service Unavailable", true, 503);
    header('Content-Type: text/html; charset=utf-8');
    header('Retry-After: 600');
    ?>
	<!DOCTYPE html>
	<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    if (is_rtl()) {
        echo ' dir="rtl"';
    }
    ?>
>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title><?php 
    _e('Maintenance');
    ?>
</title>

	</head>
	<body>
		<h1><?php 
    _e('Briefly unavailable for scheduled maintenance. Check back in a minute.');
    ?>
</h1>
	</body>
	</html>
<?php 
    die;
}
开发者ID:hughnet,项目名称:WordPress,代码行数:62,代码来源:load.php


示例2: status_header

/**
 * Set HTTP status header.
 *
 * @since 2.0.0
 * @since 4.4.0 Added the `$description` parameter.
 *
 * @see get_status_header_desc()
 *
 * @param int    $code        HTTP status code.
 * @param string $description Optional. A custom description for the HTTP status.
 */
function status_header($code, $description = '')
{
    if (!$description) {
        $description = get_status_header_desc($code);
    }
    if (empty($description)) {
        return;
    }
    $protocol = wp_get_server_protocol();
    $status_header = "{$protocol} {$code} {$description}";
    if (function_exists('apply_filters')) {
        /**
         * Filter an HTTP status header.
         *
         * @since 2.2.0
         *
         * @param string $status_header HTTP status header.
         * @param int    $code          HTTP status code.
         * @param string $description   Description for the status code.
         * @param string $protocol      Server protocol.
         */
        $status_header = apply_filters('status_header', $status_header, $code, $description, $protocol);
    }
    @header($status_header, true, $code);
}
开发者ID:nissuk,项目名称:WordPress,代码行数:36,代码来源:functions.php


示例3: wp_maintenance

/**
 * Die with a maintenance message when conditions are met.
 *
 * Checks for a file in the WordPress root directory named ".maintenance".
 * This file will contain the variable $upgrading, set to the time the file
 * was created. If the file was created less than 10 minutes ago, WordPress
 * enters maintenance mode and displays a message.
 *
 * The default message can be replaced by using a drop-in (maintenance.php in
 * the wp-content directory).
 *
 * @since 3.0.0
 * @access private
 *
 * @global int $upgrading the unix timestamp marking when upgrading WordPress began.
 */
function wp_maintenance()
{
    if (!file_exists(ABSPATH . '.maintenance') || wp_installing()) {
        return;
    }
    global $upgrading;
    include ABSPATH . '.maintenance';
    // If the $upgrading timestamp is older than 10 minutes, don't die.
    if (time() - $upgrading >= 600) {
        return;
    }
    /**
     * Bypass the maintenance mode check
     *
     * This filter should *NOT* be used by plugins. It is designed for non-web
     * runtimes. If this filter returns true, maintenance mode will not be  
     * active which can cause problems during updates for web site views.
     *
     * @since 4.6.0
     *
     * @param bool True to bypass maintenance
     */
    if (apply_filters('bypass_maintenance_mode', false)) {
        return;
    }
    if (file_exists(WP_CONTENT_DIR . '/maintenance.php')) {
        require_once WP_CONTENT_DIR . '/maintenance.php';
        die;
    }
    wp_load_translations_early();
    $protocol = wp_get_server_protocol();
    header("{$protocol} 503 Service Unavailable", true, 503);
    header('Content-Type: text/html; charset=utf-8');
    header('Retry-After: 600');
    ?>
	<!DOCTYPE html>
	<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    if (is_rtl()) {
        echo ' dir="rtl"';
    }
    ?>
>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title><?php 
    _e('Maintenance');
    ?>
</title>

	</head>
	<body>
		<h1><?php 
    _e('Briefly unavailable for scheduled maintenance. Check back in a minute.');
    ?>
</h1>
	</body>
	</html>
<?php 
    die;
}
开发者ID:BoldGrid,项目名称:WordPress,代码行数:76,代码来源:load.php


示例4: wp_maintenance

/**
 * Die with a maintenance message when conditions are met.
 *
 * Checks for a file in the WordPress root directory named ".maintenance".
 * This file will contain the variable $upgrading, set to the time the file
 * was created. If the file was created less than 10 minutes ago, WordPress
 * enters maintenance mode and displays a message.
 *
 * The default message can be replaced by using a drop-in (maintenance.php in
 * the wp-content directory).
 *
 * @since 3.0.0
 * @access private
 *
 * @global int $upgrading the unix timestamp marking when upgrading WordPress began.
 */
function wp_maintenance()
{
    if (!file_exists(ABSPATH . '.maintenance') || wp_installing()) {
        return;
    }
    global $upgrading;
    include ABSPATH . '.maintenance';
    // If the $upgrading timestamp is older than 10 minutes, don't die.
    if (time() - $upgrading >= 600) {
        return;
    }
    /**
     * Filters whether to enable maintenance mode.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web runtimes. If this filter returns true, maintenance mode will be
     * active and the request will end. If false, the request will be allowed to
     * continue processing even if maintenance mode should be active.
     *
     * @since 4.6.0
     *
     * @param bool $enable_checks Whether to enable maintenance mode. Default true.
     * @param int  $upgrading     The timestamp set in the .maintenance file.
     */
    if (!apply_filters('enable_maintenance_mode', true, $upgrading)) {
        return;
    }
    if (file_exists(WP_CONTENT_DIR . '/maintenance.php')) {
        require_once WP_CONTENT_DIR . '/maintenance.php';
        die;
    }
    wp_load_translations_early();
    $protocol = wp_get_server_protocol();
    header("{$protocol} 503 Service Unavailable", true, 503);
    header('Content-Type: text/html; charset=utf-8');
    header('Retry-After: 600');
    ?>
	<!DOCTYPE html>
	<html xmlns="http://www.w3.org/1999/xhtml"<?php 
    if (is_rtl()) {
        echo ' dir="rtl"';
    }
    ?>
>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title><?php 
    _e('Maintenance');
    ?>
</title>

	</head>
	<body>
		<h1><?php 
    _e('Briefly unavailable for scheduled maintenance. Check back in a minute.');
    ?>
</h1>
	</body>
	</html>
<?php 
    die;
}
开发者ID:johnpbloch,项目名称:wordpress,代码行数:78,代码来源:load.php


示例5: status_header

function status_header($code, $description = '')
{
    if (!$description) {
        $description = get_status_header_desc($code);
    }
    if (empty($description)) {
        return;
    }
    $protocol = wp_get_server_protocol();
    $status_header = "{$protocol} {$code} {$description}";
    if (function_exists('apply_filters')) {
        $status_header = apply_filters('status_header', $status_header, $code, $description, $protocol);
    }
    @header($status_header, true, $code);
}
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:15,代码来源:functions.php


示例6: start

 /**
  * Start page caching and hook into requests to complete it later
  *
  * @since 2.1.0
  *
  * @return void
  */
 protected function start()
 {
     // Disabled
     if ($this->max_age < 1) {
         return;
     }
     // Necessary to prevent clients using cached version after login cookies
     // set. If this is a problem, comment it out and remove all
     // Last-Modified headers.
     @header('Vary: Cookie', false);
     // Things that define a unique page.
     if (isset($_SERVER['QUERY_STRING'])) {
         parse_str($_SERVER['QUERY_STRING'], $this->query);
     }
     // Get the server protocol
     $protocol = wp_get_server_protocol();
     // Build different versions for HTTP/1.1 and HTTP/2.0
     if ('HTTP/1.0' !== $protocol) {
         $this->unique['server_protocol'] = $_SERVER['SERVER_PROTOCOL'];
     }
     // Setup keys
     $this->keys = array('host' => $_SERVER['HTTP_HOST'], 'method' => $_SERVER['REQUEST_METHOD'], 'path' => ($this->pos = strpos($_SERVER['REQUEST_URI'], '?')) ? substr($_SERVER['REQUEST_URI'], 0, $this->pos) : $_SERVER['REQUEST_URI'], 'query' => $this->query, 'extra' => $this->unique, 'ssl' => $this->is_ssl());
     // Recreate the permalink from the URL
     $scheme = true === $this->keys['ssl'] ? 'https://' : 'http://';
     $this->permalink = $scheme . $this->keys['host'] . $this->keys['path'] . (isset($this->keys['query']['p']) ? "?p=" . $this->keys['query']['p'] : '');
     $this->url_key = md5($this->permalink);
     $this->url_version = (int) wp_cache_get("{$this->url_key}_version", $this->group);
     // Setup keys and variants
     $this->do_variants();
     $this->generate_keys();
     // Get the spider_cache
     $this->cache = wp_cache_get($this->key, $this->group);
     // Are we only caching frequently-requested pages?
     if ($this->seconds < 1 || $this->times < 2) {
         $this->do = true;
         // No spider_cache item found, or ready to sample traffic again at
         // the end of the spider_cache life?
     } elseif (!is_array($this->cache) || $this->started >= $this->cache['time'] + $this->max_age - $this->seconds) {
         wp_cache_add($this->req_key, 0, $this->group);
         $this->requests = wp_cache_incr($this->req_key, 1, $this->group);
         $this->do = (bool) ($this->requests >= $this->times);
     }
     // If the document has been updated and we are the first to notice, regenerate it.
     if (true === $this->do && isset($this->cache['version']) && $this->cache['version'] < $this->url_version) {
         $this->genlock = wp_cache_add("{$this->url_key}_genlock", 1, $this->group, 10);
     }
     // Did we find a spider_cached page that hasn't expired?
     if (isset($this->cache['time']) && false === $this->genlock && $this->started < $this->cache['time'] + $this->cache['max_age']) {
         // Issue redirect if cached and enabled
         if ($this->cache['redirect_status'] && $this->cache['redirect_location'] && $this->cache_redirects) {
             $status = $this->cache['redirect_status'];
             $location = $this->cache['redirect_location'];
             // From vars.php
             $is_IIS = strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false;
             $this->do_headers($this->headers);
             if (!empty($is_IIS)) {
                 @header("Refresh: 0;url={$location}");
             } else {
                 if (php_sapi_name() !== 'cgi-fcgi') {
                     $texts = array(300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect');
                     isset($texts[$status]) ? @header("{$protocol} {$status} {$texts[$status]}") : @header("{$protocol} 302 Found");
                 }
                 @header("Location: {$location}");
             }
             exit;
         }
         // Respect ETags served with feeds.
         $three_oh_four = false;
         if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && isset($this->cache['headers']['ETag'][0]) && $_SERVER['HTTP_IF_NONE_MATCH'] == $this->cache['headers']['ETag'][0]) {
             $three_oh_four = true;
             // Respect If-Modified-Since.
         } elseif ($this->cache_control && isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
             $client_time = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
             $cache_time = isset($this->cache['headers']['Last-Modified'][0]) ? strtotime($this->cache['headers']['Last-Modified'][0]) : $this->cache['time'];
             if ($client_time >= $cache_time) {
                 $three_oh_four = true;
             }
         }
         // Use the spider_cache save time for Last-Modified so we can issue
         // "304 Not Modified" but don't clobber a cached Last-Modified header.
         if ($this->cache_control && !isset($this->cache['headers']['Last-Modified'][0])) {
             @header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->cache['time']) . ' GMT', true);
             @header('Cache-Control: max-age=' . ($this->cache['max_age'] - $this->started + $this->cache['time']) . ', must-revalidate', true);
         }
         // Add some debug info just before </head>
         if (true === $this->debug) {
             $this->add_debug_from_cache();
         }
         $this->do_headers($this->headers, $this->cache['headers']);
         // Bail if not modified
         if (true === $three_oh_four) {
             @header("HTTP/1.1 304 Not Modified", true, 304);
             die;
//.........这里部分代码省略.........
开发者ID:stuttter,项目名称:wp-spider-cache,代码行数:101,代码来源:class-output-cache.php



注:本文中的wp_get_server_protocol函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_session_token函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_schedules函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap