本文整理汇总了PHP中Dispatcher::config_state_master方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::config_state_master方法的具体用法?PHP Dispatcher::config_state_master怎么用?PHP Dispatcher::config_state_master使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::config_state_master方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_head
/**
* Print JS required by the support nag.
*/
function admin_head()
{
$state = Dispatcher::config_state_master();
// support us
$support_reminder = $state->get_integer('common.support_us_invitations') < 3 && $state->get_integer('common.install') < time() - W3TC_SUPPORT_US_TIMEOUT && $state->get_integer('common.next_support_us_invitation') < time() && $this->_config->get_string('common.support') == '' && !$this->_config->get_boolean('common.tweeted');
if ($support_reminder) {
$state->set('common.next_support_us_invitation', time() + W3TC_SUPPORT_US_TIMEOUT);
$state->set('common.support_us_invitations', $state->get_integer('common.support_us_invitations') + 1);
$state->save();
do_action('w3tc_message_action_generic_support_us');
}
// edge mode
$edge_reminder = !$support_reminder && !Util_Environment::is_w3tc_edge($this->_config) && $state->get_integer('common.edge_invitations') < 3 && $state->get_integer('common.install') < time() - W3TC_EDGE_TIMEOUT && $state->get_integer('common.next_edge_invitation') < time();
if ($edge_reminder) {
if ($state->get_integer('common.edge_invitations') > 1) {
$next = time() + 30 * 24 * 60 * 60;
} else {
$next = time() + W3TC_EDGE_TIMEOUT;
}
$state->set('common.next_edge_invitation', $next);
$state->set('common.edge_invitations', $state->get_integer('common.edge_invitations') + 1);
$state->save();
do_action('w3tc_message_action_generic_edge');
}
}
示例2: w3tc_default_config_state_master
function w3tc_default_config_state_master()
{
$key = Util_Request::get_string('key');
$value = Util_Request::get_string('value');
$config_state = Dispatcher::config_state_master();
$config_state->set($key, $value);
$config_state->save();
Util_Admin::redirect(array(), true);
}
示例3: w3tc_config_reset
/**
* Reset config action
*
* @return void
*/
function w3tc_config_reset()
{
$config = new Config();
$config->set_defaults();
Util_Admin::config_save($this->_config, $config);
$config_state = Dispatcher::config_state();
$config_state->reset();
$config_state->save();
$config_state = Dispatcher::config_state_master();
$config_state->reset();
$config_state->save();
Util_Admin::redirect(array('w3tc_note' => 'config_reset'), true);
}
示例4: check_ip_versions
/**
* Check if last check has expired. If so update CloudFlare ips
*/
function check_ip_versions()
{
$state = Dispatcher::config_state_master();
if ($state->get_integer('extension.cloudflare.next_ips_check') < time()) {
// update asap to avoid multiple processes entering the check
$state->set('extension.cloudflare.next_ips_check', time() + 7 * 24 * 60 * 60);
$data = array();
try {
$data = $this->api->get_ip_ranges();
} catch (\Exception $ex) {
}
if (isset($data['ip4'])) {
$state->set('extension.cloudflare.ips.ip4', $data['ip4']);
}
if (isset($data['ip6'])) {
$state->set('extension.cloudflare.ips.ip6', $data['ip6']);
}
$state->save();
}
}
示例5: w3tc_errors
function w3tc_errors($errors)
{
$c = Dispatcher::config();
$state = Dispatcher::config_state_master();
/**
* Minify error occured
*/
if ($state->get_boolean('minify.show_note_minify_error')) {
$errors['minify_error_creating'] = sprintf(__('Recently an error occurred while creating the CSS / JS minify cache: %s. %s', 'w3-total-cache'), $state->get_string('minify.error.last'), Util_Ui::button_hide_note2(array('w3tc_default_config_state_master' => 'y', 'key' => 'minify.show_note_minify_error', 'value' => 'false')));
}
if ($c->get_string('minify.engine') == 'memcached') {
$memcached_servers = $c->get_array('minify.memcached.servers');
if (!Util_Installed::is_memcache_available($memcached_servers)) {
if (!isset($errors['memcache_not_responding.details'])) {
$errors['memcache_not_responding.details'] = array();
}
$errors['memcache_not_responding.details'][] = sprintf(__('Minify: %s.', 'w3-total-cache'), implode(', ', $memcached_servers));
}
}
return $errors;
}
示例6: _handle_error
/**
* Handle minify error
*
* @param string $error
* @return void
*/
function _handle_error($error)
{
$notification = $this->_config->get_string('minify.error.notification');
if ($notification) {
$file = Util_Request::get_string('file');
$state = Dispatcher::config_state_master();
if ($file) {
$state->set('minify.error.file', $file);
}
if (stristr($notification, 'admin') !== false) {
$state->set('minify.error.last', $error);
$state->set('minify.show_note_minify_error', true);
}
if (stristr($notification, 'email') !== false) {
$last = $state->get_integer('minify.error.notification.last');
/**
* Prevent email flood: send email every 5 min
*/
if (time() - $last > 300) {
$state->set('minify.error.notification.last', time());
$this->_send_notification();
}
}
$state->save();
}
}
示例7: 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;
}
示例8: after_rules_modified
/**
* Called when rules are modified, sets notification
*/
public static function after_rules_modified()
{
if (Util_Environment::is_nginx()) {
$state = Dispatcher::config_state_master();
$state->set('common.show_note.nginx_restart_required', true);
$state->save();
}
}