本文整理汇总了PHP中W3_Config::set方法的典型用法代码示例。如果您正苦于以下问题:PHP W3_Config::set方法的具体用法?PHP W3_Config::set怎么用?PHP W3_Config::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类W3_Config
的用法示例。
在下文中一共展示了W3_Config::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: time
/**
* Flush browsers cache
*/
function flush_browser_cache()
{
if ($this->_config->get_boolean('browsercache.enabled')) {
$this->_config->set('browsercache.timestamp', time());
$this->_config->save();
}
}
示例2: update_ip_ranges
/**
* Check
* @throws FilesystemOperationException
* @throws FileOperationException
*/
public function update_ip_ranges()
{
w3_require_once(W3TC_INC_DIR . '/functions/http.php');
$ip4_diff = $ip6_diff = false;
$response = w3_http_get(W3TC_CLOUDFLARE_IP4_URL);
$extensions_settings = $this->_config->get_array('extensions.settings', array());
if (!is_wp_error($response)) {
$ip4_data = $response['body'];
$ip4_data = explode("\n", $ip4_data);
$ip4_data_old = w3tc_get_extension_config('cloudflare', 'ips.ip4', $this->_config, array());
if ($ip4_diff = array_diff($ip4_data, $ip4_data_old)) {
$extensions_settings['cloudflare']['ips.ip4'] = $ip4_data;
$this->_config->set('extensions.settings', $extensions_settings);
}
}
$response = w3_http_get(W3TC_CLOUDFLARE_IP6_URL);
if (!is_wp_error($response)) {
$ip6_data = $response['body'];
$ip6_data = explode("\n", $ip6_data);
$ip6_data_old = w3tc_get_extension_config('cloudflare', 'ips.ip6', $this->_config, array());
if ($ip6_diff = array_diff($ip6_data, $ip6_data_old)) {
$extensions_settings['cloudflare']['ips.ip6'] = $ip6_data;
$this->_config->set('extensions.settings', $extensions_settings);
}
}
if ($ip4_diff || $ip6_diff) {
try {
$this->_config->save();
$this->_config->refresh_cache();
} catch (Exception $ex) {
}
}
}
示例3: catch
/**
* @throws Exception
*/
function action_aws_sns_subscribe()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$topic_arn = W3_Request::get_string('cluster_messagebus_sns_topic_arn_subscribe');
/**
* @var W3_Enterprise_SnsClient $sns_client
*/
$sns_client = w3_instance('W3_Enterprise_SnsClient');
$sns_client->subscribe(plugins_url('pub/sns.php', W3TC_FILE), $topic_arn);
try {
$this->_config->set('cluster.messagebus.sns.topic_arn', $topic_arn);
$this->_config->save();
} catch (Exception $ex) {
throw new Exception('<strong>Can\'t change configuration</strong>: ' . $ex->getMessage());
}
w3_admin_redirect(array('w3tc_note' => 'sns_subscribed'));
}
示例4:
/**
* Save support us action
*
* @return void
*/
function action_config_save_support_us()
{
$support = W3_Request::get_string('support');
$tweeted = W3_Request::get_boolean('tweeted');
$this->_config->set('common.support', $support);
$this->_config->set('common.tweeted', $tweeted);
$this->_config->save();
w3_instance('W3_AdminLinks')->link_update($this->_config);
w3_admin_redirect(array('w3tc_note' => 'config_save'));
}
示例5: catch
function action_cdn_save_activate()
{
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
try {
$this->_config->set('cdn.enabled', true);
$this->_config->save();
} catch (Exception $ex) {
}
w3_redirect(w3_admin_url(sprintf('admin.php?page=w3tc_cdn#configuration')));
}
示例6: time
/**
* Handle minify error
*
* @return void
*/
function _handle_error()
{
$notification = $this->_config->get_string('minify.error.notification');
if ($notification) {
if (stristr($notification, 'admin') !== false) {
$this->_config->set('notes.minify_error', true);
}
if (stristr($notification, 'email') !== false) {
$last = $this->_config->get_integer('minify.error.notification.last');
/**
* Prevent email flood: send email every 5 min
*/
if (time() - $last > 300) {
$this->_config->set('minify.error.notification.last', time());
$this->_send_notification();
}
}
$this->_config->save();
}
}
示例7: elseif
/**
* Save support us action
*
* @return void
*/
function action_config_save_support_us()
{
$support = W3_Request::get_string('support');
$tweeted = W3_Request::get_boolean('tweeted');
$signmeup = W3_Request::get_boolean('signmeup');
$this->_config->set('common.support', $support);
$this->_config->set('common.tweeted', $tweeted);
if ($signmeup) {
if (w3_is_pro($this->_config)) {
$license = 'pro';
} elseif (w3_is_enterprise()) {
$license = 'enterprise';
} else {
$license = 'community';
}
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
wp_remote_post(W3TC_MAILLINGLIST_SIGNUP_URL, array('body' => array('email' => $email, 'license' => $license)));
}
$this->_config->save();
w3_instance('W3_AdminLinks')->link_update($this->_config);
w3_admin_redirect(array('w3tc_note' => 'config_save'));
}
示例8: explode
/**
* Create NetDNA/MaxCDN pullzone
*/
function action_cdn_create_netdna_maxcdn_pull_zone()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$type = W3_Request::get_string('type');
$name = W3_Request::get_string('name');
$label = W3_Request::get_string('label');
w3_require_once(W3TC_LIB_NETDNA_DIR . '/NetDNA.php');
$cdn_engine = $this->_config->get_string('cdn.engine');
$authorization_key = $this->_config->get_string("cdn.{$cdn_engine}.authorization_key");
$alias = $consumerkey = $consumersecret = '';
if ($authorization_key) {
$keys = explode('+', $authorization_key);
if (sizeof($keys) == 3) {
list($alias, $consumerkey, $consumersecret) = $keys;
}
}
$api = new NetDNA($alias, $consumerkey, $consumersecret);
$url = w3_get_home_url();
$zone = array();
$zone['name'] = $name;
$zone['label'] = $label;
$zone['url'] = $url;
try {
$response = $api->create_pull_zone($zone);
try {
$this->_config->set('cdn.enabled', true);
if (!$this->_config->get_array("cdn.{$cdn_engine}.domain")) {
$this->_config->set("cdn.{$cdn_engine}.domain", array("{$name}.{$alias}.netdna-cdn.com"));
}
$this->_config->save();
} catch (Exception $ex) {
}
echo json_encode(array('status' => 'success', 'message' => 'Pull Zone created.', 'temporary_url' => "{$name}.{$alias}.netdna-cdn.com", 'data' => $response));
} catch (Exception $ex) {
echo json_encode(array('status' => 'error', 'message' => $ex->getMessage()));
}
}
示例9: w3_config_save
/**
* Save config, can't decline save process. (difference from action_save)
*
* Do some actions on config keys update
* Used in several places such as:
*
* 1. common config save
* 2. import settings
*
* @param W3_Config $current_config
* @param W3_Config $new_config
* @param W3_ConfigAdmin $new_config_admin
* @return bool
* @throws Exception
*/
function w3_config_save($current_config, $new_config, $new_config_admin)
{
$master_config = $new_config->is_master() ? $new_config : new W3_Config(true);
if ($master_config->get_integer('common.instance_id', 0) == 0) {
$master_config->set('common.instance_id', mt_rand());
if (!$new_config->is_master()) {
$master_config->save();
}
}
$old_config = new W3_Config();
$browsercache_dependencies = array();
if ($new_config->get_boolean('browsercache.enabled')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.cssjs.replace', 'browsercache.html.replace', 'browsercache.other.replace'));
if ($new_config->get_boolean('browsercache.cssjs.replace')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.cssjs.compression', 'browsercache.cssjs.expires', 'browsercache.cssjs.lifetime', 'browsercache.cssjs.cache.control', 'browsercache.cssjs.cache.policy', 'browsercache.cssjs.etag', 'browsercache.cssjs.w3tc'));
}
if ($new_config->get_boolean('browsercache.html.replace')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.html.compression', 'browsercache.html.expires', 'browsercache.html.lifetime', 'browsercache.html.cache.control', 'browsercache.html.cache.policy', 'browsercache.html.etag', 'browsercache.html.w3tc'));
}
if ($new_config->get_boolean('browsercache.other.replace')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.other.compression', 'browsercache.other.expires', 'browsercache.other.lifetime', 'browsercache.other.cache.control', 'browsercache.other.cache.policy', 'browsercache.other.etag', 'browsercache.other.w3tc'));
}
}
/**
* Show need empty page cache notification
*/
if ($new_config->get_boolean('pgcache.enabled')) {
$pgcache_dependencies = array_merge($browsercache_dependencies, array('pgcache.debug', 'dbcache.enabled', 'objectcache.enabled', 'minify.enabled', 'mobile.enabled', 'referrer.enabled'));
if ($new_config->get_boolean('dbcache.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('dbcache.debug'));
}
if ($new_config->get_boolean('objectcache.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('objectcache.debug'));
}
if ($new_config->get_boolean('minify.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('minify.auto', 'minify.debug', 'minify.rewrite', 'minify.html.enable', 'minify.html.engine', 'minify.html.inline.css', 'minify.html.inline.js', 'minify.html.strip.crlf', 'minify.html.comments.ignore', 'minify.css.enable', 'minify.css.engine', 'minify.css.groups', 'minify.js.enable', 'minify.js.engine', 'minify.js.groups', 'minify.htmltidy.options.clean', 'minify.htmltidy.options.hide-comments', 'minify.htmltidy.options.wrap', 'minify.reject.logged', 'minify.reject.ua', 'minify.reject.uri'));
}
/**
* @var W3_ModuleStatus $modules
*/
$modules = w3_instance('W3_ModuleStatus');
if ($modules->is_running('cdn')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('cdn.enabled', 'cdn.debug', 'cdn.engine', 'cdn.uploads.enable', 'cdn.includes.enable', 'cdn.includes.files', 'cdn.theme.enable', 'cdn.theme.files', 'cdn.minify.enable', 'cdn.custom.enable', 'cdn.custom.files', 'cdn.ftp.domain', 'cdn.ftp.ssl', 'cdn.s3.cname', 'cdn.s3.ssl', 'cdn.cf.cname', 'cdn.cf.ssl', 'cdn.cf2.cname', 'cdn.cf2.ssl', 'cdn.rscf.cname', 'cdn.rscf.ssl', 'cdn.azure.cname', 'cdn.azure.ssl', 'cdn.mirror.domain', 'cdn.mirror.ssl', 'cdn.netdna.domain', 'cdn.netdna.ssl', 'cdn.cotendo.domain', 'cdn.cotendo.ssl', 'cdn.edgecast.domain', 'cdn.edgecast.ssl', 'cdn.att.domain', 'cdn.att.ssl', 'cdn.reject.logged_roles', 'cdn.reject.roles', 'cdn.reject.ua', 'cdn.reject.uri', 'cdn.reject.files'));
} elseif ($old_config->get_boolean('cdn.enabled') && !$new_config->get_boolean('cdn.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('cdn.enabled'));
}
if ($new_config->get_boolean('mobile.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('mobile.rgroups'));
}
if ($new_config->get_boolean('referrer.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('referrer.rgroups'));
}
if ($new_config->get_boolean('browsercache.enabled') && $new_config->get_string('pgcache.engine') == 'file_generic') {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('browsercache.html.last_modified', 'browsercache.other.last_modified'));
}
$old_pgcache_dependencies_values = array();
$new_pgcache_dependencies_values = array();
foreach ($pgcache_dependencies as $pgcache_dependency) {
$old_pgcache_dependencies_values[] = $old_config->get($pgcache_dependency);
$new_pgcache_dependencies_values[] = $new_config->get($pgcache_dependency);
}
if (serialize($old_pgcache_dependencies_values) != serialize($new_pgcache_dependencies_values)) {
$new_config->set('notes.need_empty_pgcache', true);
}
}
/**
* Show need empty minify notification
*/
if ($current_config->get_boolean('minify.enabled') && $new_config->get_boolean('minify.enabled') && ($new_config->get_boolean('minify.css.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.css.groups'))) || $new_config->get_boolean('minify.js.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.js.groups'))))) {
$minify_dependencies = array_merge($browsercache_dependencies, array('minify.auto', 'minify.debug', 'minify.options', 'minify.symlinks', 'minify.css.enable', 'minify.js.enable'));
if ($new_config->get_boolean('minify.css.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.css.groups')))) {
$minify_dependencies = array_merge($minify_dependencies, array('minify.css.engine', 'minify.css.combine', 'minify.css.strip.comments', 'minify.css.strip.crlf', 'minify.css.imports', 'minify.css.groups', 'minify.yuicss.path.java', 'minify.yuicss.path.jar', 'minify.yuicss.options.line-break', 'minify.csstidy.options.remove_bslash', 'minify.csstidy.options.compress_colors', 'minify.csstidy.options.compress_font-weight', 'minify.csstidy.options.lowercase_s', 'minify.csstidy.options.optimise_shorthands', 'minify.csstidy.options.remove_last_;', 'minify.csstidy.options.case_properties', 'minify.csstidy.options.sort_properties', 'minify.csstidy.options.sort_selectors', 'minify.csstidy.options.merge_selectors', 'minify.csstidy.options.discard_invalid_properties', 'minify.csstidy.options.css_level', 'minify.csstidy.options.preserve_css', 'minify.csstidy.options.timestamp', 'minify.csstidy.options.template'));
}
if ($new_config->get_boolean('minify.js.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.js.groups')))) {
$minify_dependencies = array_merge($minify_dependencies, array('minify.js.engine', 'minify.js.combine.header', 'minify.js.combine.body', 'minify.js.combine.footer', 'minify.js.strip.comments', 'minify.js.strip.crlf', 'minify.js.groups', 'minify.yuijs.path.java', 'minify.yuijs.path.jar', 'minify.yuijs.options.line-break', 'minify.yuijs.options.nomunge', 'minify.yuijs.options.preserve-semi', 'minify.yuijs.options.disable-optimizations', 'minify.ccjs.path.java', 'minify.ccjs.path.jar', 'minify.ccjs.options.compilation_level', 'minify.ccjs.options.formatting'));
}
/**
* @var W3_ModuleStatus $modules
*/
$modules = w3_instance('W3_ModuleStatus');
if ($modules->is_running('cdn')) {
$minify_dependencies = array_merge($minify_dependencies, array('cdn.engine', 'cdn.enabled'));
} elseif ($old_config->get_boolean('cdn.enabled') && !$new_config->get_boolean('cdn.enabled')) {
$minify_dependencies = array_merge($minify_dependencies, array('cdn.enabled'));
}
//.........这里部分代码省略.........
示例10: foreach
/**
* Reads config from request
*
* @param W3_Config|W3_ConfigAdmin $config
*/
function read_request($config)
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$request = W3_Request::get_request();
foreach ($request as $request_key => $request_value) {
if (is_array($request_value)) {
array_map('stripslashes_deep', $request_value);
} else {
$request_value = stripslashes($request_value);
}
if (strpos($request_key, 'memcached_servers')) {
$request_value = explode(',', $request_value);
}
$config->set($request_key, $request_value);
}
}
示例11: w3tc_deactivate_extension
/**
* @param $extension
* @param W3_Config $config
* @param bool $dont_save_config
* @return bool
*/
function w3tc_deactivate_extension($extension, $config, $dont_save_config = false)
{
$extensions = $config->get_array('extensions.active');
if (array_key_exists($extension, $extensions)) {
unset($extensions[$extension]);
ksort($extensions, SORT_STRING);
$config->set('extensions.active', $extensions);
try {
if (!$dont_save_config) {
$config->save();
}
do_action("w3tc_deactivate_extension-{$extension}");
return true;
} catch (Exception $ex) {
}
}
return false;
}
示例12: array
/**
* Save config action
*
* Do some actions on config keys update
* Used in several places such as:
*
* 1. common config save
* 2. import settings
* 3. enable/disable preview mode
*
* @param W3_Config $old_config
* @param W3_Config $new_config
* @param boolean $preview
* @return void
*/
function config_save(&$old_config, &$new_config, $preview = null)
{
$browsercache_dependencies = array();
if ($new_config->get_boolean('browsercache.enabled')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.cssjs.replace', 'browsercache.html.replace', 'browsercache.other.replace'));
if ($new_config->get_boolean('browsercache.cssjs.replace')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.cssjs.compression', 'browsercache.cssjs.expires', 'browsercache.cssjs.lifetime', 'browsercache.cssjs.cache.control', 'browsercache.cssjs.cache.policy', 'browsercache.cssjs.etag', 'browsercache.cssjs.w3tc'));
}
if ($new_config->get_boolean('browsercache.html.replace')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.html.compression', 'browsercache.html.expires', 'browsercache.html.lifetime', 'browsercache.html.cache.control', 'browsercache.html.cache.policy', 'browsercache.html.etag', 'browsercache.html.w3tc'));
}
if ($new_config->get_boolean('browsercache.other.replace')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.other.compression', 'browsercache.other.expires', 'browsercache.other.lifetime', 'browsercache.other.cache.control', 'browsercache.other.cache.policy', 'browsercache.other.etag', 'browsercache.other.w3tc'));
}
}
/**
* Show need empty page cache notification
*/
if ($new_config->get_boolean('pgcache.enabled')) {
$pgcache_dependencies = array_merge($browsercache_dependencies, array('pgcache.debug', 'dbcache.enabled', 'objectcache.enabled', 'minify.enabled', 'cdn.enabled', 'mobile.enabled', 'referrer.enabled'));
if ($new_config->get_boolean('dbcache.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('dbcache.debug'));
}
if ($new_config->get_boolean('objectcache.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('objectcache.debug'));
}
if ($new_config->get_boolean('minify.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('minify.auto', 'minify.debug', 'minify.rewrite', 'minify.html.enable', 'minify.html.engine', 'minify.html.inline.css', 'minify.html.inline.js', 'minify.html.strip.crlf', 'minify.html.comments.ignore', 'minify.css.enable', 'minify.css.groups', 'minify.js.enable', 'minify.js.groups', 'minify.htmltidy.options.clean', 'minify.htmltidy.options.hide-comments', 'minify.htmltidy.options.wrap', 'minify.reject.logged', 'minify.reject.ua', 'minify.reject.uri'));
}
if ($new_config->get_boolean('cdn.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('cdn.debug', 'cdn.engine', 'cdn.uploads.enable', 'cdn.includes.enable', 'cdn.includes.files', 'cdn.theme.enable', 'cdn.theme.files', 'cdn.minify.enable', 'cdn.custom.enable', 'cdn.custom.files', 'cdn.mirror.domain', 'cdn.mirror.ssl', 'cdn.netdna.domain', 'cdn.netdna.ssl', 'cdn.cotendo.domain', 'cdn.cotendo.ssl', 'cdn.ftp.domain', 'cdn.ftp.ssl', 'cdn.s3.cname', 'cdn.s3.ssl', 'cdn.cf.cname', 'cdn.cf.ssl', 'cdn.cf2.cname', 'cdn.cf2.ssl', 'cdn.rscf.cname', 'cdn.rscf.ssl', 'cdn.azure.cname', 'cdn.azure.ssl', 'cdn.reject.admins', 'cdn.reject.ua', 'cdn.reject.uri', 'cdn.reject.files'));
}
if ($new_config->get_boolean('mobile.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('mobile.rgroups'));
}
if ($new_config->get_boolean('referrer.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('referrer.rgroups'));
}
$old_pgcache_dependencies_values = array();
$new_pgcache_dependencies_values = array();
foreach ($pgcache_dependencies as $pgcache_dependency) {
$old_pgcache_dependencies_values[] = $old_config->get($pgcache_dependency);
$new_pgcache_dependencies_values[] = $new_config->get($pgcache_dependency);
}
if (serialize($old_pgcache_dependencies_values) != serialize($new_pgcache_dependencies_values)) {
$new_config->set('notes.need_empty_pgcache', true);
}
}
/**
* Show need empty minify notification
*/
if ($new_config->get_boolean('minify.enabled') && ($new_config->get_boolean('minify.css.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.css.groups'))) || $new_config->get_boolean('minify.js.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.js.groups'))))) {
$minify_dependencies = array_merge($browsercache_dependencies, array('minify.auto', 'minify.debug', 'minify.options', 'minify.symlinks', 'minify.css.enable', 'minify.js.enable'));
if ($new_config->get_boolean('minify.css.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.css.groups')))) {
$minify_dependencies = array_merge($minify_dependencies, array('minify.css.engine', 'minify.css.combine', 'minify.css.strip.comments', 'minify.css.strip.crlf', 'minify.css.imports', 'minify.css.groups', 'minify.yuicss.path.java', 'minify.yuicss.path.jar', 'minify.yuicss.options.line-break', 'minify.csstidy.options.remove_bslash', 'minify.csstidy.options.compress_colors', 'minify.csstidy.options.compress_font-weight', 'minify.csstidy.options.lowercase_s', 'minify.csstidy.options.optimise_shorthands', 'minify.csstidy.options.remove_last_;', 'minify.csstidy.options.case_properties', 'minify.csstidy.options.sort_properties', 'minify.csstidy.options.sort_selectors', 'minify.csstidy.options.merge_selectors', 'minify.csstidy.options.discard_invalid_properties', 'minify.csstidy.options.css_level', 'minify.csstidy.options.preserve_css', 'minify.csstidy.options.timestamp', 'minify.csstidy.options.template'));
}
if ($new_config->get_boolean('minify.js.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.js.groups')))) {
$minify_dependencies = array_merge($minify_dependencies, array('minify.js.engine', 'minify.js.combine.header', 'minify.js.combine.body', 'minify.js.combine.footer', 'minify.js.strip.comments', 'minify.js.strip.crlf', 'minify.js.groups', 'minify.yuijs.path.java', 'minify.yuijs.path.jar', 'minify.yuijs.options.line-break', 'minify.yuijs.options.nomunge', 'minify.yuijs.options.preserve-semi', 'minify.yuijs.options.disable-optimizations', 'minify.ccjs.path.java', 'minify.ccjs.path.jar', 'minify.ccjs.options.compilation_level', 'minify.ccjs.options.formatting'));
}
$old_minify_dependencies_values = array();
$new_minify_dependencies_values = array();
foreach ($minify_dependencies as $minify_dependency) {
$old_minify_dependencies_values[] = $old_config->get($minify_dependency);
$new_minify_dependencies_values[] = $new_config->get($minify_dependency);
}
if (serialize($old_minify_dependencies_values) != serialize($new_minify_dependencies_values)) {
$new_config->set('notes.need_empty_minify', true);
}
}
if ($new_config->get_boolean('cdn.enabled') && !w3_is_cdn_mirror($new_config->get_string('cdn.engine'))) {
/**
* Show notification when CDN enabled
*/
if (!$old_config->get_boolean('cdn.enabled')) {
$new_config->set('notes.cdn_upload', true);
}
/**
* Show notification when Browser Cache settings changes
*/
$cdn_dependencies = array('browsercache.enabled');
if ($new_config->get_boolean('cdn.enabled')) {
$cdn_dependencies = array('browsercache.cssjs.compression', 'browsercache.cssjs.expires', 'browsercache.cssjs.lifetime', 'browsercache.cssjs.cache.control', 'browsercache.cssjs.cache.policy', 'browsercache.cssjs.etag', 'browsercache.cssjs.w3tc', 'browsercache.html.compression', 'browsercache.html.expires', 'browsercache.html.lifetime', 'browsercache.html.cache.control', 'browsercache.html.cache.policy', 'browsercache.html.etag', 'browsercache.html.w3tc', 'browsercache.other.compression', 'browsercache.other.expires', 'browsercache.other.lifetime', 'browsercache.other.cache.control', 'browsercache.other.cache.policy', 'browsercache.other.etag', 'browsercache.other.w3tc');
}
$old_cdn_dependencies_values = array();
$new_cdn_dependencies_values = array();
//.........这里部分代码省略.........
示例13: remove_old_files
/**
* Remove .old files if changing settings.
*
* @param W3_Config $new_config
* @param W3_Config $old_config
* @param W3_ConfigAdmin $config_admin
* @return W3_Config
*/
public function remove_old_files($new_config, $old_config, $config_admin = null)
{
if (!$new_config->get_boolean('pgcache.cache.home') && $old_config->get_boolean('pgcache.cache.home') || $new_config->get_boolean('pgcache.reject.front_page') && !$old_config->get_boolean('pgcache.reject.front_page') || !$new_config->get_boolean('pgcache.cache.feed') && $old_config->get_boolean('pgcache.cache.feed') || !$new_config->get_boolean('pgcache.cache.query') && $old_config->get_boolean('pgcache.cache.query') || !$new_config->get_boolean('pgcache.cache.ssl') && $old_config->get_boolean('pgcache.cache.ssl')) {
$new_config->set('notes.need_empty_pgcache', true);
}
return $new_config;
}
示例14: fopen
/**
* @synopsis [--check] [--default-settings] [--preserve-cdn]
* @subcommand total-cache
*
*/
function w3tc($args, $assoc_args)
{
if (!file_exists(WP_CONTENT_DIR . "/plugins/w3-total-cache/")) {
WP_CLI::warning("W3 Total Cache plugin is not installed into plugins/w3-total-cache/. Skipping.");
exit;
}
if (!is_plugin_active("w3-total-cache/w3-total-cache.php")) {
WP_CLI::warning("W3 Total Cache plugin is not enabled. Skipping.");
exit;
}
$w3tc_version = get_plugin_data(WP_CONTENT_DIR . "/plugins/w3-total-cache/w3-total-cache.php");
$w3tc_version = $w3tc_version['Version'];
$w3tc_master = $w3tc_version >= "0.9.2.6" ? WP_CONTENT_DIR . "/w3tc-config/master.php" : WP_CONTENT_DIR . "/w3-total-cache-config.php";
if (!file_exists($w3tc_master)) {
WP_CLI::warning("W3 Total Cache config file can not be found. Skipping.");
exit;
}
if (isset($assoc_args['check'])) {
$file = fopen($w3tc_master, "r");
while (!feof($file)) {
$line = fgets($file);
if (preg_match('/pgcache\\.enabled\' => true/', $line)) {
$pgcache = true;
continue;
}
if (preg_match('/pgcache\\.engine\' => \'file\'/', $line)) {
$pgcache_method = "disk: basic";
continue;
}
if (preg_match('/pgcache\\.engine\' => \'file_generic\'/', $line)) {
$pgcache_method = "disk: enhanced";
continue;
}
if (preg_match('/pgcache\\.engine\' => \'apc\'/', $line)) {
$pgcache_method = "opcode: apc";
continue;
}
if (preg_match('/minify\\.enabled\' => true/', $line)) {
$minify = true;
continue;
}
if (preg_match('/dbcache\\.enabled\' => true/', $line)) {
$dbcache = true;
continue;
}
if (preg_match('/objectcache\\.enabled\' => true/', $line)) {
$objectcache = true;
continue;
}
if (preg_match('/objectcache\\.engine\' => \'file\'/', $line)) {
$objectcache_method = "disk";
continue;
}
if (preg_match('/objectcache\\.engine\' => \'apc\'/', $line)) {
$objectcache_method = "apc";
continue;
}
if (preg_match('/fragmentcache\\.enabled\' => true/', $line)) {
$fragmentcache = true;
continue;
}
if (preg_match('/fragmentcache\\.engine\' => \'file\'/', $line)) {
$fragmentcache_method = "disk";
continue;
}
if (preg_match('/fragmentcache\\.engine\' => \'apc\'/', $line)) {
$fragmentcache_method = "apc";
continue;
}
if (preg_match('/browsercache\\.enabled\' => true/', $line)) {
$browsercache = true;
continue;
}
if (preg_match('/cdn\\.enabled\' => true/', $line)) {
$cdn = true;
continue;
}
}
fclose($file);
echo "[1;34mW3 Total Cache " . $w3tc_version . " (" . (file_exists("/var/run/apache2.pid") || file_exists("/run/apache2/apache2.pid") ? "apache+nginx" : "nginx+php5-fpm") . ")[0m\n";
echo "\n[34mPage Cache:[0m " . (isset($pgcache) ? "enabled (" . $pgcache_method . ")" : "-");
echo "\n[34mMinify:[0m " . (isset($minify) ? "enabled" : "-");
echo "\n[34mDatabase Cache:[0m " . (isset($dbcache) ? "enabled" : "-");
echo "\n[34mObject Cache:[0m " . (isset($objectcache) ? "enabled (" . $objectcache_method . ")" : "-");
echo "\n[34mFragment Cache:[0m " . (isset($fragmentcache) ? "enabled (" . $fragmentcache_method . ")" : "-");
echo "\n[34mBrowser Cache:[0m " . (isset($browsercache) ? "enabled" : "-");
echo "\n[34mCDN:[0m " . (isset($cdn) ? "enabled" : "-") . "\n";
} else {
if (isset($assoc_args['default-settings'])) {
$siteurl = preg_replace("/https?:\\/\\/(www.)?/", "", home_url());
if (strlen($siteurl) == 0 || !is_dir("/var/www/" . $siteurl)) {
WP_CLI::error("Unable to find site root. Skipping.");
return;
}
if (!is_writable("/var/www/" . $siteurl)) {
//.........这里部分代码省略.........
示例15: update_ip_ranges
/**
* Check
* @throws FilesystemOperationException
* @throws FileOperationException
*/
public function update_ip_ranges()
{
w3_require_once(W3TC_INC_DIR . '/functions/http.php');
$ip4_diff = $ip6_diff = false;
$config_master = new W3_Config(true);
$response = w3_http_get(W3TC_CLOUDFLARE_IP4_URL);
if (!is_wp_error($response)) {
$ip4_data = $response['body'];
$ip4_data = explode("\n", $ip4_data);
$ip4_data_old = $this->_config->get_array('cloudflare.ips.ip4');
if ($ip4_diff = array_diff($ip4_data, $ip4_data_old)) {
$config_master->set('cloudflare.ips.ip4', $ip4_data);
}
}
$response = w3_http_get(W3TC_CLOUDFLARE_IP6_URL);
if (!is_wp_error($response)) {
$ip6_data = $response['body'];
$ip6_data = explode("\n", $ip6_data);
$ip6_data_old = $this->_config->get_array('cloudflare.ips.ip6');
if ($ip6_diff = array_diff($ip6_data, $ip6_data_old)) {
$config_master->set('cloudflare.ips.ip6', $ip6_data);
}
}
if ($ip4_diff || $ip6_diff) {
$config_master->save();
}
}