本文整理汇总了PHP中Dispatcher::config_state_note方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::config_state_note方法的具体用法?PHP Dispatcher::config_state_note怎么用?PHP Dispatcher::config_state_note使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::config_state_note方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: w3tc_default_save_and_flush
/**
* save&flush all action
*
* @return void
*/
public function w3tc_default_save_and_flush()
{
$redirect_data = $this->_w3tc_save_options_process();
$f = Dispatcher::component('CacheFlush');
$f->flush_all();
$state_note = Dispatcher::config_state_note();
$state_note->set('common.show_note.flush_statics_needed', false);
$state_note->set('common.show_note.flush_posts_needed', false);
$state_note->set('common.show_note.plugins_updated', false);
$state_note->set('minify.show_note.need_flush', false);
$state_note->set('objectcache.show_note.flush_needed', false);
Util_Admin::redirect_with_custom_messages2($redirect_data);
}
示例2: pre_update_option_active_plugins
/**
* Active plugins pre update option filter
*
* @param string $new_value
* @return string
*/
function pre_update_option_active_plugins($new_value)
{
$old_value = (array) get_option('active_plugins');
if ($new_value !== $old_value && in_array(W3TC_FILE, (array) $new_value) && in_array(W3TC_FILE, (array) $old_value)) {
$state_note = Dispatcher::config_state_note();
$state_note->set('common.show_note.plugins_updated', true);
}
return $new_value;
}
示例3: w3tc_notes
/**
*
*
* @param Config $config
* @return string
*/
function w3tc_notes($notes)
{
$c = Dispatcher::config();
$state = Dispatcher::config_state();
$state_master = Dispatcher::config_state_master();
$state_note = Dispatcher::config_state_note();
/**
* Check wp-content permissions
*/
if (!W3TC_WIN && !$state_master->get_boolean('common.hide_note_wp_content_permissions')) {
$wp_content_mode = Util_File::get_file_permissions(WP_CONTENT_DIR);
if ($wp_content_mode > 0755) {
$notes['generic_wp_content_writeable'] = sprintf(__('<strong>%s</strong> is write-able. When finished installing the plugin, change the permissions back to the default: <strong>chmod 755 %s</strong>. Permissions are currently %s. %s', 'w3-total-cache'), WP_CONTENT_DIR, WP_CONTENT_DIR, base_convert(Util_File::get_file_permissions(WP_CONTENT_DIR), 10, 8), Util_Ui::button_hide_note2(array('w3tc_default_config_state_master' => 'y', 'key' => 'common.hide_note_wp_content_permissions', 'value' => 'true')));
}
}
/**
* Check Zlib extension
*/
if (!$state_master->get_boolean('common.hide_note_no_zlib') && !function_exists('gzencode')) {
$notes['no_zlib'] = sprintf(__('Unfortunately the PHP installation is incomplete, the <strong>zlib module is missing</strong>. This is a core PHP module. Notify the server administrator. %s', 'w3-total-cache'), Util_Ui::button_hide_note2(array('w3tc_default_config_state_master' => 'y', 'key' => 'common.hide_note_no_zlib', 'value' => 'true')));
}
/**
* Check if Zlib output compression is enabled
*/
if (!$state_master->get_boolean('common.hide_note_zlib_output_compression') && Util_Environment::is_zlib_enabled()) {
$notes['zlib_output_compression'] = sprintf(__('Either the PHP configuration, web server configuration or a script in the WordPress installation has <strong>zlib.output_compression</strong> enabled.<br />Please locate and disable this setting to ensure proper HTTP compression behavior. %s', 'w3-total-cache'), Util_Ui::button_hide_note2(array('w3tc_default_config_state_master' => 'y', 'key' => 'common.hide_note_zlib_output_compression', 'value' => 'true')));
}
if ($state_master->get_boolean('common.show_note.nginx_restart_required')) {
$cf = Dispatcher::component('CacheFlush');
$notes['nginx_restart_required'] = sprintf(__('nginx.conf rules have been updated. Please restart nginx server to provide a consistent user experience. %s', 'w3-total-cache'), Util_Ui::button_hide_note2(array('w3tc_default_config_state_master' => 'y', 'key' => 'common.show_note.nginx_restart_required', 'value' => 'false')));
}
/**
* Preview mode
*/
if ($c->is_preview()) {
$notes['preview_mode'] = sprintf(__('Preview mode is active: Changed settings will not take effect until preview mode is %s or %s.', 'w3-total-cache'), Util_Ui::button_link(__('deploy', 'w3-total-cache'), Util_Ui::url(array('w3tc_config_preview_deploy' => 'y'))), Util_Ui::button_link(__('disable', 'w3-total-cache'), Util_Ui::url(array('w3tc_config_preview_disable' => 'y')))) . '<br /><span class="description">' . sprintf(__('To preview any changed settings (without deploying): %s', 'w3-total-cache'), Util_Ui::preview_link()) . '</span>';
}
/**
* Show notification after plugin activate/deactivate
*/
if ($state_note->get('common.show_note.plugins_updated') && !is_network_admin()) {
$texts = array();
if ($c->get_boolean('pgcache.enabled')) {
$texts[] = Util_Ui::button_link(__('empty the page cache', 'w3-total-cache'), Util_Ui::url(array('w3tc_flush_posts' => 'y')));
}
if ($c->get_boolean('minify.enabled')) {
$texts[] = sprintf(__('check the %s to maintain the desired user experience', 'w3-total-cache'), Util_Ui::button_link(__('minify settings', 'w3-total-cache'), Util_Ui::url(array('w3tc_default_config_state_note' => 'y', 'key' => 'common.show_note.plugins_updated', 'value' => 'false'))));
}
if (count($texts)) {
$notes['some_plugins_activated'] = sprintf(__('One or more plugins have been activated or deactivated, please %s. %s', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $texts), Util_Ui::button_hide_note2(array('w3tc_default_config_state_note' => 'y', 'key' => 'common.show_note.plugins_updated', 'value' => 'false')));
}
}
/**
* Show notification when flush_statics needed
*/
if ($c->get_boolean('browsercache.enabled') && $state_note->get('common.show_note.flush_statics_needed') && !is_network_admin() && !$c->is_preview()) {
$notes['flush_statics_needed'] = sprintf(__('The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience. %s', 'w3-total-cache'), Util_Ui::button_link('Empty the static files cache', Util_Ui::url(array('w3tc_flush_statics' => 'y'))), Util_Ui::button_hide_note2(array('w3tc_default_config_state_note' => 'y', 'key' => 'common.show_note.flush_statics_needed', 'value' => 'false')));
}
/**
* Show notification when flush_posts needed
*/
if ($state_note->get('common.show_note.flush_posts_needed') && !is_network_admin() && !$c->is_preview() && !isset($notes['flush_statics_needed'])) {
$cf = Dispatcher::component('CacheFlush');
if ($cf->flushable_posts()) {
$notes['flush_posts_needed'] = sprintf(__('The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience. %s', 'w3-total-cache'), Util_Ui::button_link('Empty the page cache', Util_Ui::url(array('w3tc_flush_posts' => 'y'))), Util_Ui::button_hide_note2(array('w3tc_default_config_state_note' => 'y', 'key' => 'common.show_note.flush_posts_needed', 'value' => 'false')));
}
}
return $notes;
}
示例4: 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 Config $current_config
* @param Config $new_config
* @return bool
* @throws Exception
*/
public static function config_save($current_config, $new_config)
{
$master_config = $new_config->is_master() ? $new_config : Dispatcher::config_master();
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 Config();
$browsercache_dependencies = array();
if ($new_config->get_boolean('browsercache.enabled')) {
$browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.rewrite', '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'));
}
$old_bc_dependencies_values = array();
$new_bc_dependencies_values = array();
foreach ($browsercache_dependencies as $key) {
$old_bc_dependencies_values[] = $old_config->get($key);
$new_bc_dependencies_values[] = $new_config->get($key);
}
if (serialize($old_bc_dependencies_values) != serialize($new_bc_dependencies_values)) {
$state_note = Dispatcher::config_state_note();
$state_note->set('common.show_note.flush_statics_needed', true);
}
}
/**
* Show need empty page cache notification
*/
$cache_flush = Dispatcher::component('CacheFlush');
if ($cache_flush->flushable_posts()) {
$pgcache_dependencies = array_merge($browsercache_dependencies, array('pgcache.debug', 'pgcache.cache.query', 'pgcache.cache.home', 'pgcache.cache.feed', 'pgcache.cache.nginx_handle_xml', 'pgcache.cache.ssl', 'pgcache.cache.404', 'pgcache.cache.headers', 'pgcache.compatibility', 'pgcache.remove_charset', 'pgcache.accept.uri', 'pgcache.accept.files', 'pgcache.accept.qs', 'pgcache.late_init', 'pgcache.mirrors.enabled', 'pgcache.reject.front_page', 'pgcache.reject.logged', 'pgcache.reject.logged_roles', 'pgcache.reject.uri', 'pgcache.reject.ua', 'pgcache.reject.cookie', 'pgcache.reject.request_head', 'dbcache.enabled', 'objectcache.enabled', 'minify.enabled', 'mobile.enabled', 'referrer.enabled'));
if ($new_config->get_boolean('pgcache.mirrors.enabled')) {
$pgcache_dependencies = array_merge($pgcache_dependencies, array('pgcache.mirrors.home_urls'));
}
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 = Dispatcher::component('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)) {
$state_note = Dispatcher::config_state_note();
$state_note->set('common.show_note.flush_posts_needed', 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'))))) {
//.........这里部分代码省略.........