本文整理汇总了PHP中Util_Environment::is_preview_mode方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::is_preview_mode方法的具体用法?PHP Util_Environment::is_preview_mode怎么用?PHP Util_Environment::is_preview_mode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util_Environment
的用法示例。
在下文中一共展示了Util_Environment::is_preview_mode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($blog_id = null)
{
if (!is_null($blog_id)) {
$this->_blog_id = $blog_id;
$this->_is_master = $this->_blog_id == 0;
} else {
if (Util_Environment::is_using_master_config()) {
$this->_blog_id = 0;
} else {
$this->_blog_id = Util_Environment::blog_id();
}
$this->_is_master = Util_Environment::blog_id() == 0;
}
$this->_preview = Util_Environment::is_preview_mode();
$this->load();
}
示例2: ob_callback
/**
* Output buffering callback
*
* @param string $buffer
* @return string
*/
function ob_callback($buffer)
{
global $wpdb;
global $w3_late_caching_succeeded;
if ($w3_late_caching_succeeded) {
return $buffer;
}
if (Util_Content::is_database_error($buffer)) {
status_header(503);
} else {
if (Util_Content::can_print_comment($buffer)) {
/**
* Add footer comment
*/
$date = date_i18n('Y-m-d H:i:s');
$host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
if (Util_Environment::is_preview_mode()) {
$buffer .= "\r\n<!-- W3 Total Cache used in preview mode -->";
}
if ($this->_config->get_string('common.support') != '' || $this->_config->get_boolean('common.tweeted')) {
$buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", Util_Content::escape_comment($host), $date);
} else {
$strings = array();
$strings = apply_filters('w3tc_footer_comment', $strings);
$buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: https://www.w3-edge.com/products/\r\n";
if (count($strings)) {
$buffer .= "\r\n" . Util_Content::escape_comment(implode("\r\n", $strings)) . "\r\n";
}
$buffer .= sprintf("\r\n Served from: %s @ %s by W3 Total Cache -->", Util_Content::escape_comment($host), $date);
}
}
$buffer = Util_Bus::do_ob_callbacks(array('minify', 'newrelic', 'cdn', 'browsercache', 'pagecache'), $buffer);
}
return $buffer;
}
示例3: verify_file_generic_rewrite_working
/**
* Fixes environment for enabled pgcache
*
* @throws Util_Environment_Exceptions
*/
private function verify_file_generic_rewrite_working()
{
$url = get_home_url() . '/w3tc_rewrite_test' . rand();
if (!$this->test_rewrite($url)) {
$key = sprintf('w3tc_rewrite_test_result_%s', substr(md5($url), 0, 16));
$result = get_transient($key);
$home_url = get_home_url();
$tech_message = (Util_Environment::is_nginx() ? 'nginx configuration file' : '.htaccess file') . ' contains rules to rewrite url ' . $home_url . '/w3tc_rewrite_test into ' . $home_url . '/?w3tc_rewrite_test which, if handled by ' . 'plugin, return "OK" message.<br/>';
$tech_message .= 'The plugin made a request to ' . $home_url . '/w3tc_rewrite_test but received: <br />' . $result . '<br />';
$tech_message .= 'instead of "OK" response. <br />';
$error = '<strong>W3 Total Cache error:</strong> ' . 'It appears Page Cache ' . '<acronym title="Uniform Resource Locator">URL</acronym> ' . 'rewriting is not working. ';
if (Util_Environment::is_preview_mode()) {
$error .= ' This could be due to using Preview mode. <a href="' . $url . '">Click here</a> to manually verify its working. It should say OK. <br />';
}
if (Util_Environment::is_nginx()) {
$error .= 'Please verify that all configuration files are ' . 'included in the configuration file ' . '(and that you have reloaded / restarted nginx).';
} else {
$error .= 'Please verify that the server configuration ' . 'allows .htaccess';
}
$error .= '<br />Unfortunately disk enhanced page caching will ' . 'not function without custom rewrite rules. ' . 'Please ask your server administrator for assistance. ' . 'Also refer to <a href="' . admin_url('admin.php?page=w3tc_install') . '">the install page</a> for the rules for your server.';
throw new Util_Environment_Exception($error, $tech_message);
}
}
示例4: _send_headers
/**
* Sends headers
*
* @param boolean $is_404
* @param string $etag
* @param integer $time
* @param string $compression
* @param array $custom_headers
* @return boolean
*/
function _send_headers($is_404, $time, $etag, $compression, $custom_headers = array())
{
$exit = false;
$headers = is_array($custom_headers) ? $custom_headers : array();
$curr_time = time();
$bc_lifetime = $this->_config->get_integer('browsercache.html.lifetime');
$expires = (is_null($time) ? $curr_time : $time) + $bc_lifetime;
$max_age = $expires > $curr_time ? $expires - $curr_time : 0;
if ($is_404) {
/**
* Add 404 header
*/
$headers = array_merge($headers, array('Status' => 'HTTP/1.1 404 Not Found'));
} elseif (!is_null($time) && $this->_check_modified_since($time) || $this->_check_match($etag)) {
/**
* Add 304 header
*/
$headers = array_merge($headers, array('Status' => 'HTTP/1.1 304 Not Modified'));
/**
* Don't send content if it isn't modified
*/
$exit = true;
}
if ($this->_config->get_boolean('browsercache.enabled')) {
if ($this->_config->get_boolean('browsercache.html.last_modified')) {
$headers = array_merge($headers, array('Last-Modified' => Util_Content::http_date($time)));
}
if ($this->_config->get_boolean('browsercache.html.expires')) {
$headers = array_merge($headers, array('Expires' => Util_Content::http_date($expires)));
}
if ($this->_config->get_boolean('browsercache.html.cache.control')) {
switch ($this->_config->get_string('browsercache.html.cache.policy')) {
case 'cache':
$headers = array_merge($headers, array('Pragma' => 'public', 'Cache-Control' => 'public'));
break;
case 'cache_public_maxage':
$headers = array_merge($headers, array('Pragma' => 'public', 'Cache-Control' => sprintf('max-age=%d, public', $max_age)));
break;
case 'cache_validation':
$headers = array_merge($headers, array('Pragma' => 'public', 'Cache-Control' => 'public, must-revalidate, proxy-revalidate'));
break;
case 'cache_noproxy':
$headers = array_merge($headers, array('Pragma' => 'public', 'Cache-Control' => 'private, must-revalidate'));
break;
case 'cache_maxage':
$headers = array_merge($headers, array('Pragma' => 'public', 'Cache-Control' => sprintf('max-age=%d, public, must-revalidate, proxy-revalidate', $max_age)));
break;
case 'no_cache':
$headers = array_merge($headers, array('Pragma' => 'no-cache', 'Cache-Control' => 'max-age=0, private, no-store, no-cache, must-revalidate'));
break;
}
}
if ($this->_config->get_boolean('browsercache.html.etag')) {
$headers = array_merge($headers, array('ETag' => '"' . $etag . '"'));
}
if ($this->_config->get_boolean('browsercache.html.w3tc')) {
$headers = array_merge($headers, array('X-Powered-By' => Util_Environment::w3tc_header()));
}
}
$vary = '';
//compressed && UAG
if ($compression && $this->_get_mobile_group()) {
$vary = 'Accept-Encoding,User-Agent,Cookie';
$headers = array_merge($headers, array('Content-Encoding' => $compression));
//compressed
} elseif ($compression) {
$vary = 'Accept-Encoding';
$headers = array_merge($headers, array('Content-Encoding' => $compression));
//uncompressed && UAG
} elseif ($this->_get_mobile_group()) {
$vary = 'User-Agent,Cookie';
}
//Add Cookie to vary if user logged in and not previously set
if (!$this->_check_logged_in() && strpos($vary, 'Cookie') === false) {
if ($vary) {
$vary .= ',Cookie';
} else {
$vary = 'Cookie';
}
}
/**
* Add vary header
*/
if ($vary) {
$headers = array_merge($headers, array('Vary' => $vary));
}
/**
* Disable caching for preview mode
*/
if (Util_Environment::is_preview_mode()) {
//.........这里部分代码省略.........