本文整理汇总了PHP中W3_Config::get_integer方法的典型用法代码示例。如果您正苦于以下问题:PHP W3_Config::get_integer方法的具体用法?PHP W3_Config::get_integer怎么用?PHP W3_Config::get_integer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类W3_Config
的用法示例。
在下文中一共展示了W3_Config::get_integer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fix_on_event
/**
* Fixes environment once event occurs
*
* @param W3_Config $config
* @param string $event
* @param W3_Config|null $old_config
* @throws SelfTestExceptions
**/
public function fix_on_event($config, $event, $old_config = null)
{
if ($config->get_boolean('cdn.enabled') && !w3_is_cdn_mirror($config->get_string('cdn.engine'))) {
if ($old_config != null && $config->get_integer('cdn.queue.interval') != $old_config->get_integer('cdn.queue.interval')) {
$this->unschedule_queue_process();
}
if (!wp_next_scheduled('w3_cdn_cron_queue_process')) {
wp_schedule_event(current_time('timestamp'), 'w3_cdn_cron_queue_process', 'w3_cdn_cron_queue_process');
}
} else {
$this->unschedule_queue_process();
}
if ($config->get_boolean('cdn.enabled') && $config->get_boolean('cdn.autoupload.enabled') && !w3_is_cdn_mirror($config->get_string('cdn.engine'))) {
if ($old_config != null && $config->get_integer('cdn.autoupload.interval') != $old_config->get_integer('cdn.autoupload.interval')) {
$this->unschedule_upload();
}
if (!wp_next_scheduled('w3_cdn_cron_upload')) {
wp_schedule_event(current_time('timestamp'), 'w3_cdn_cron_upload', 'w3_cdn_cron_upload');
}
} else {
$this->unschedule_upload();
}
$exs = new SelfTestExceptions();
if ($config->get_boolean('cdn.enabled')) {
try {
$this->table_create($event == 'activate');
} catch (Exception $ex) {
$exs->push($ex);
}
}
if (count($exs->exceptions()) > 0) {
throw $exs;
}
}
示例2:
/**
* PHP5-style constructor
*/
function __construct()
{
$this->_config = w3_instance('W3_Config');
$this->_debug = $this->_config->get_boolean('varnish.debug');
$this->_servers = $this->_config->get_array('varnish.servers');
$this->_timeout = $this->_config->get_integer('timelimit.varnish_purge');
}
示例3:
/**
* PHP5 Constructor
*/
function __construct()
{
require_once W3TC_LIB_W3_DIR . '/Config.php';
$this->_config =& W3_Config::instance();
$this->_debug = $this->_config->get_boolean('pgcache.debug');
$this->_lifetime = $this->_config->get_integer('pgcache.lifetime');
$this->_enhanced_mode = $this->_config->get_string('pgcache.engine') == 'file_pgcache';
}
示例4:
/**
* PHP5 constructor
*
* @param string $dbuser
* @param string $dbpassword
* @param string $dbname
* @param string $dbhost
*/
function __construct($dbuser, $dbpassword, $dbname, $dbhost)
{
require_once W3TC_LIB_W3_DIR . '/Config.php';
$this->_config =& W3_Config::instance();
$this->_lifetime = $this->_config->get_integer('dbcache.lifetime');
if ($this->_config->get_boolean('dbcache.enabled') && $this->_config->get_boolean('dbcache.debug')) {
ob_start(array(&$this, 'ob_callback'));
}
parent::__construct($dbuser, $dbpassword, $dbname, $dbhost);
}
示例5: array
/**
* Create container action
*
* @return void
*/
function action_cdn_create_container()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
w3_require_once(W3TC_LIB_W3_DIR . '/Cdn.php');
$engine = W3_Request::get_string('engine');
$config = W3_Request::get_array('config');
$config = array_merge($config, array('debug' => false));
$result = false;
$error = __('Incorrect type.', 'w3-total-cache');
$container_id = '';
switch ($engine) {
case 's3':
case 'cf':
case 'cf2':
case 'rscf':
case 'azure':
$result = true;
break;
}
if ($result) {
$w3_cdn = W3_Cdn::instance($engine, $config);
@set_time_limit($this->_config->get_integer('timelimit.cdn_container_create'));
if ($w3_cdn->create_container($container_id, $error)) {
$result = true;
$error = __('Created successfully.', 'w3-total-cache');
} else {
$result = false;
$error = sprintf(__('Error: %s', 'w3-total-cache'), $error);
}
}
$response = array('result' => $result, 'error' => $error, 'container_id' => $container_id);
echo json_encode($response);
}
示例6: array
/**
* Returns cache object
*
* @param null $blog_id
* @param string $group
* @return W3_Cache_Base
*/
function _get_cache($blog_id = null, $group = 'transient')
{
static $cache = array();
if (is_null($blog_id) && $group != 'site-transient') {
$blog_id = $this->_blog_id;
} else {
$blog_id = 0;
}
if (!isset($cache[$blog_id])) {
$engine = $this->_config->get_string('fragmentcache.engine');
switch ($engine) {
case 'memcached':
$engineConfig = array('servers' => $this->_config->get_array('fragmentcache.memcached.servers'), 'persistant' => $this->_config->get_boolean('fragmentcache.memcached.persistant'));
break;
case 'file':
$engineConfig = array('section' => 'fragment', 'locking' => $this->_config->get_boolean('fragmentcache.file.locking'), 'flush_timelimit' => $this->_config->get_integer('timelimit.cache_flush'));
break;
default:
$engineConfig = array();
}
$engineConfig['blog_id'] = $blog_id;
$engineConfig['module'] = 'fragmentcache';
$engineConfig['host'] = w3_get_host();
$engineConfig['instance_id'] = w3_get_instance_id();
w3_require_once(W3TC_LIB_W3_DIR . '/Cache.php');
$cache[$blog_id] = W3_Cache::instance($engine, $engineConfig);
}
return $cache[$blog_id];
}
示例7: sprintf
/**
* Precaches external file
*
* @param string $url
* @param string $type
* @return string
*/
function _precache_file($url, $type)
{
$lifetime = $this->_config->get_integer('minify.lifetime');
$file_path = sprintf('%s/minify_%s.%s', W3TC_CACHE_FILE_MINIFY_DIR, md5($url), $type);
$file_exists = file_exists($file_path);
if (file_exists($file_path) && @filemtime($file_path) >= time() - $lifetime) {
return $this->_get_minify_source($file_path, $url);
}
if (is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
if ($file_data = w3_url_get($url)) {
if ($fp = @fopen($file_path, 'w')) {
@fputs($fp, $file_data);
@fclose($fp);
return $this->_get_minify_source($file_path, $url);
} else {
$this->log(sprintf('Unable to open file %s for writing', $file_path));
}
} else {
$this->log(sprintf('Unable to download URL: %s', $url));
}
} else {
$this->log(sprintf('The cache directory %s does not exist', W3TC_CACHE_FILE_MINIFY_DIR));
}
return $file_exists ? $this->_get_minify_source($file_path, $url) : false;
}
示例8: array
/**
* Send E-mail notification when error occurred
*
* @return boolean
*/
function _send_notification()
{
$from_email = 'wordpress@' . w3_get_domain($_SERVER['SERVER_NAME']);
$from_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$to_name = $to_email = get_option('admin_email');
$body = @file_get_contents(W3TC_INC_DIR . '/email/minify_error_notification.php');
$headers = array(sprintf('From: "%s" <%s>', addslashes($from_name), $from_email), sprintf('Reply-To: "%s" <%s>', addslashes($to_name), $to_email), 'Content-Type: text/html; charset=UTF-8');
@set_time_limit($this->_config->get_integer('timelimit.email_send'));
$result = @wp_mail($to_email, 'W3 Total Cache Error Notification', $body, implode("\n", $headers));
return $result;
}
示例9: array
/**
* Returns minifier options
*
* @param string $engine
* @return array
*/
function get_options($engine)
{
$options = array();
switch ($engine) {
case 'js':
$options = array('preserveComments' => !$this->_config->get_boolean('minify.js.strip.comments'), 'stripCrlf' => $this->_config->get_boolean('minify.js.strip.crlf'));
break;
case 'css':
$options = array('preserveComments' => !$this->_config->get_boolean('minify.css.strip.comments'), 'stripCrlf' => $this->_config->get_boolean('minify.css.strip.crlf'));
$symlinks = $this->_config->get_array('minify.symlinks');
foreach ($symlinks as $link => $target) {
$link = str_replace('//', realpath($_SERVER['DOCUMENT_ROOT']), $link);
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
$options['symlinks'][$link] = realpath($target);
}
break;
case 'yuijs':
$options = array('line-break' => $this->_config->get_integer('minify.yuijs.options.line-break'), 'nomunge' => $this->_config->get_boolean('minify.yuijs.options.nomunge'), 'preserve-semi' => $this->_config->get_boolean('minify.yuijs.options.preserve-semi'), 'disable-optimizations' => $this->_config->get_boolean('minify.yuijs.options.disable-optimizations'));
break;
case 'yuicss':
$options = array('line-break' => $this->_config->get_integer('minify.yuicss.options.line-break'));
break;
case 'ccjs':
$options = array('compilation_level' => $this->_config->get_string('minify.ccjs.options.compilation_level'), 'formatting' => $this->_config->get_string('minify.ccjs.options.formatting'));
break;
case 'csstidy':
$options = array('remove_bslash' => $this->_config->get_boolean('minify.csstidy.options.remove_bslash'), 'compress_colors' => $this->_config->get_boolean('minify.csstidy.options.compress_colors'), 'compress_font-weight' => $this->_config->get_boolean('minify.csstidy.options.compress_font-weight'), 'lowercase_s' => $this->_config->get_boolean('minify.csstidy.options.lowercase_s'), 'optimise_shorthands' => $this->_config->get_integer('minify.csstidy.options.optimise_shorthands'), 'remove_last_;' => $this->_config->get_boolean('minify.csstidy.options.remove_last_;'), 'case_properties' => $this->_config->get_integer('minify.csstidy.options.case_properties'), 'sort_properties' => $this->_config->get_boolean('minify.csstidy.options.sort_properties'), 'sort_selectors' => $this->_config->get_boolean('minify.csstidy.options.sort_selectors'), 'merge_selectors' => $this->_config->get_integer('minify.csstidy.options.merge_selectors'), 'discard_invalid_properties' => $this->_config->get_boolean('minify.csstidy.options.discard_invalid_properties'), 'css_level' => $this->_config->get_string('minify.csstidy.options.css_level'), 'preserve_css' => $this->_config->get_boolean('minify.csstidy.options.preserve_css'), 'timestamp' => $this->_config->get_boolean('minify.csstidy.options.timestamp'), 'template' => $this->_config->get_string('minify.csstidy.options.template'));
break;
case 'html':
case 'htmlxml':
$options = array('xhtml' => true, 'stripCrlf' => $this->_config->get_boolean('minify.html.strip.crlf'), 'ignoredComments' => $this->_config->get_array('minify.html.comments.ignore'));
break;
case 'htmltidy':
case 'htmltidyxml':
$options = array('clean' => $this->_config->get_boolean('minify.htmltidy.options.clean'), 'hide-comments' => $this->_config->get_boolean('minify.htmltidy.options.hide-comments'), 'wrap' => $this->_config->get_integer('minify.htmltidy.options.wrap'));
break;
}
if ($this->_config->get_boolean('browsercache.enabled') && ($this->_config->get_boolean('browsercache.cssjs.replace') || $this->_config->get_boolean('browsercache.html.replace') || $this->_config->get_boolean('browsercache.other.replace'))) {
$w3_plugin_browsercache = w3_instance('W3_Plugin_BrowserCache');
$options = array_merge($options, array('browserCacheId' => $w3_plugin_browsercache->get_replace_id(), 'browserCacheExtensions' => $w3_plugin_browsercache->get_replace_extensions()));
}
if ($this->_config->get_boolean('cdn.enabled') && $this->_config->get_boolean('cdn.minify.enable')) {
$w3_plugin_cdn = w3_instance('W3_Plugin_CdnCommon');
$cdn = $w3_plugin_cdn->get_cdn();
$options = array_merge($options, array('prependAbsolutePathCallback' => array(&$cdn, 'get_prepend_path')));
}
return $options;
}
示例10: save_settings
/**
* @param $cf_values
* @return bool
*/
public function save_settings($cf_values)
{
@set_time_limit($this->_config->get_integer('timelimit.cloudflare_api_request'));
ksort($cf_values);
$cf_values = $this->_cleanup_settings($cf_values);
foreach ($cf_values as $key => $settings) {
if ($settings['old'] != $settings['new']) {
$response = $this->api_request($key, $settings['new']);
if (!$response || $response && $response->result != 'success') {
return false;
}
}
}
delete_transient('w3tc_cloudflare_settings');
return true;
}
示例11: sprintf
/**
* Precaches external file
*
* @param string $url
* @param string $type
* @return string
*/
function _precache_file($url, $type)
{
$lifetime = $this->_config->get_integer('minify.lifetime');
$file_path = sprintf('%s/minify_%s.%s', W3TC_CACHE_FILE_MINIFY_DIR, md5($url), $type);
$file_exists = file_exists($file_path);
if ($file_exists && @filemtime($file_path) >= time() - $lifetime) {
return $this->_get_minify_source($file_path, $url);
}
if (is_dir(W3TC_CACHE_FILE_MINIFY_DIR)) {
if (w3_download($url, $file_path) !== false) {
return $this->_get_minify_source($file_path, $url);
} else {
$this->log(sprintf('Unable to download URL: %s', $url));
}
} else {
$this->log(sprintf('The cache directory %s does not exist', W3TC_CACHE_FILE_MINIFY_DIR));
}
return $file_exists ? $this->_get_minify_source($file_path, $url) : false;
}
示例12: array
/**
* Returns cache object
*
* @return W3_Cache_Base
*/
function &_get_cache()
{
static $cache = array();
if (!isset($cache[0])) {
$engine = $this->_config->get_string('dbcache.engine');
switch ($engine) {
case 'memcached':
$engineConfig = array('servers' => $this->_config->get_array('dbcache.memcached.servers'), 'persistant' => $this->_config->get_boolean('dbcache.memcached.persistant'));
break;
case 'file':
$engineConfig = array('cache_dir' => W3TC_CACHE_FILE_DBCACHE_DIR, 'locking' => $this->_config->get_boolean('dbcache.file.locking'), 'flush_timelimit' => $this->_config->get_integer('timelimit.cache_flush'));
break;
default:
$engineConfig = array();
}
require_once W3TC_LIB_W3_DIR . '/Cache.php';
$cache[0] =& W3_Cache::instance($engine, $engineConfig);
}
return $cache[0];
}
示例13: array
/**
* Returns cache object
*
* @return W3_Cache_Base
*/
function _get_cache()
{
static $cache = array();
if (!isset($cache[0])) {
$engine = $this->_config->get_string('dbcache.engine');
switch ($engine) {
case 'memcached':
$engineConfig = array('servers' => $this->_config->get_array('dbcache.memcached.servers'), 'persistant' => $this->_config->get_boolean('dbcache.memcached.persistant'));
break;
case 'file':
$engineConfig = array('use_wp_hash', true, 'section' => 'db', 'locking' => $this->_config->get_boolean('dbcache.file.locking'), 'flush_timelimit' => $this->_config->get_integer('timelimit.cache_flush'));
break;
default:
$engineConfig = array();
}
$engineConfig['module'] = 'dbcache';
$engineConfig['host'] = w3_get_host();
$engineConfig['instance_id'] = w3_get_instance_id();
w3_require_once(W3TC_LIB_W3_DIR . '/Cache.php');
$cache[0] = W3_Cache::instance($engine, $engineConfig);
}
return $cache[0];
}
示例14: array
/**
* 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 = 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' => w3_http_date($time)));
}
if ($this->_config->get_boolean('browsercache.html.expires')) {
$headers = array_merge($headers, array('Expires' => w3_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' => W3TC_POWERED_BY));
}
}
$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));
}
/**
* Add custom headers
*/
$headers = array_merge($headers, $custom_headers);
/**
//.........这里部分代码省略.........
示例15: rules_cache_generate_nginx
/**
* Generates directives for file cache dir
*
* @param W3_Config $config
* @return string
*/
private function rules_cache_generate_nginx($config)
{
$cache_root = w3_path(W3TC_CACHE_PAGE_ENHANCED_DIR);
$cache_dir = rtrim(str_replace(w3_get_document_root(), '', $cache_root), '/');
if (w3_is_network()) {
$cache_dir = preg_replace('~/w3tc.*?/~', '/w3tc.*?/', $cache_dir, 1);
}
$browsercache = $config->get_boolean('browsercache.enabled');
$compression = $browsercache && $config->get_boolean('browsercache.html.compression');
$expires = $browsercache && $config->get_boolean('browsercache.html.expires');
$lifetime = $browsercache ? $config->get_integer('browsercache.html.lifetime') : 0;
$cache_control = $browsercache && $config->get_boolean('browsercache.html.cache.control');
$w3tc = $browsercache && $config->get_integer('browsercache.html.w3tc');
$common_rules = '';
if ($expires) {
$common_rules .= " expires modified " . $lifetime . "s;\n";
}
if ($w3tc) {
$common_rules .= " add_header X-Powered-By \"" . W3TC_POWERED_BY . "\";\n";
}
if ($compression) {
$common_rules .= " add_header Vary \"Accept-Encoding, Cookie\";\n";
} else {
$common_rules .= " add_header Vary Cookie;\n";
}
if ($cache_control) {
$cache_policy = $config->get_string('browsercache.html.cache.policy');
switch ($cache_policy) {
case 'cache':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"public\";\n";
break;
case 'cache_public_maxage':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
break;
case 'cache_validation':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"public, must-revalidate, proxy-revalidate\";\n";
break;
case 'cache_noproxy':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"private, must-revalidate\";\n";
break;
case 'cache_maxage':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
break;
case 'no_cache':
$common_rules .= " add_header Pragma \"no-cache\";\n";
$common_rules .= " add_header Cache-Control \"max-age=0, private, no-store, no-cache, must-revalidate\";\n";
break;
}
}
$rules = '';
$rules .= W3TC_MARKER_BEGIN_PGCACHE_CACHE . "\n";
$rules .= "location ~ " . $cache_dir . ".*html\$ {\n";
$rules .= $common_rules;
$rules .= "}\n";
if ($compression) {
$rules .= "location ~ " . $cache_dir . ".*gzip\$ {\n";
$rules .= " gzip off;\n";
$rules .= " types {}\n";
$rules .= " default_type text/html;\n";
$rules .= $common_rules;
$rules .= " add_header Content-Encoding gzip;\n";
$rules .= "}\n";
}
$rules .= W3TC_MARKER_END_PGCACHE_CACHE . "\n";
return $rules;
}