本文整理汇总了PHP中Util_Environment::is_wpmu方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::is_wpmu方法的具体用法?PHP Util_Environment::is_wpmu怎么用?PHP Util_Environment::is_wpmu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util_Environment
的用法示例。
在下文中一共展示了Util_Environment::is_wpmu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs plugin
*/
function run()
{
add_filter('cron_schedules', array($this, 'cron_schedules'));
if ($this->_config->get_string('dbcache.engine') == 'file') {
add_action('w3_dbcache_cleanup', array($this, 'cleanup'));
}
add_action('publish_phone', array($this, 'on_change'), 0);
add_action('wp_trash_post', array($this, 'on_post_change'), 0);
add_action('save_post', array($this, 'on_post_change'), 0);
add_action('clean_post_cache', array($this, 'on_post_change'), 0, 2);
add_action('comment_post', array($this, 'on_comment_change'), 0);
add_action('edit_comment', array($this, 'on_comment_change'), 0);
add_action('delete_comment', array($this, 'on_comment_change'), 0);
add_action('wp_set_comment_status', array($this, 'on_comment_status'), 0, 2);
add_action('trackback_post', array($this, 'on_comment_change'), 0);
add_action('pingback_post', array($this, 'on_comment_change'), 0);
add_action('switch_theme', array($this, 'on_change'), 0);
add_action('edit_user_profile_update', array($this, 'on_change'), 0);
if (Util_Environment::is_wpmu()) {
add_action('delete_blog', array($this, 'on_change'), 0);
}
add_action('delete_post', array($this, 'on_post_change'), 0);
add_filter('w3tc_admin_bar_menu', array($this, 'w3tc_admin_bar_menu'));
// usage statistics handling
add_filter('w3tc_usage_statistics_metrics', array($this, 'w3tc_usage_statistics_metrics'));
}
示例2: fix_in_wpadmin
/**
* Fixes environment
*
* @param Config $config
* @throws Util_Environment_Exceptions
*/
function fix_in_wpadmin($config, $force_all_checks = false)
{
$exs = new Util_Environment_Exceptions();
$fix_on_event = false;
if (Util_Environment::is_wpmu() && Util_Environment::blog_id() != 0) {
if (get_transient('w3tc_config_changes') != ($md5_string = $config->get_md5())) {
$fix_on_event = true;
set_transient('w3tc_config_changes', $md5_string, 3600);
}
}
// call plugin-related handlers
foreach ($this->get_handlers($config) as $h) {
try {
$h->fix_on_wpadmin_request($config, $force_all_checks);
if ($fix_on_event) {
$this->fix_on_event($config, 'admin_request');
}
} catch (Util_Environment_Exceptions $ex) {
$exs->push($ex);
}
}
try {
do_action('w3tc_environment_fix_on_wpadmin_request', $config, $force_all_checks);
} catch (Util_Environment_Exceptions $ex) {
$exs->push($ex);
}
if (count($exs->exceptions()) > 0) {
throw $exs;
}
}
示例3: view
/**
* General tab
*
* @return void
*/
function view()
{
global $current_user;
$config_master = $this->_config_master;
/**
*
*
* @var $modules W3_ModuleStatus
*/
$modules = Dispatcher::component('ModuleStatus');
$pgcache_enabled = $modules->is_enabled('pgcache');
$dbcache_enabled = $modules->is_enabled('dbcache');
$objectcache_enabled = $modules->is_enabled('objectcache');
$browsercache_enabled = $modules->is_enabled('browsercache');
$minify_enabled = $modules->is_enabled('minify');
$cdn_enabled = $modules->is_enabled('cdn');
$varnish_enabled = $modules->is_enabled('varnish');
$enabled = $modules->plugin_is_enabled();
$enabled_checkbox = $modules->all_modules_enabled();
$check_rules = Util_Rule::can_check_rules();
$disc_enhanced_enabled = !(!$check_rules || !$this->is_master() && Util_Environment::is_wpmu() && $config_master->get_string('pgcache.engine') != 'file_generic');
$can_empty_file = $modules->can_empty_file();
$can_empty_varnish = $modules->can_empty_varnish();
$cdn_mirror_purge = Cdn_Util::can_purge_all($modules->get_module_engine('cdn'));
$file_nfs = $this->_config->get_boolean('pgcache.file.nfs') || $this->_config->get_boolean('minify.file.nfs');
$file_locking = $this->_config->get_boolean('dbcache.file.locking') || $this->_config->get_boolean('objectcache.file.locking') || $this->_config->get_boolean('pgcache.file.locking') || $this->_config->get_boolean('minify.file.locking');
$licensing_visible = (!Util_Environment::is_wpmu() || is_network_admin()) && !ini_get('w3tc.license_key') && get_transient('w3tc_license_status') != 'host_valid';
$custom_areas = apply_filters("w3tc_settings_general_anchors", array());
include W3TC_INC_DIR . '/options/general.php';
}
示例4: generate
function generate($base_capability)
{
$pages = $this->generate_menu_array();
add_menu_page(__('Performance', 'w3-total-cache'), __('Performance', 'w3-total-cache'), apply_filters('w3tc_capability_menu_w3tc_dashboard', $base_capability), 'w3tc_dashboard', '', 'div');
$submenu_pages = array();
$is_master = is_network_admin() || !Util_Environment::is_wpmu();
$remaining_visible = !$this->_config->get_boolean('common.force_master');
foreach ($pages as $slug => $titles) {
if ($is_master || $titles['visible_always'] || $remaining_visible) {
$submenu_pages[] = add_submenu_page('w3tc_dashboard', $titles['page_title'] . ' | W3 Total Cache', $titles['menu_text'], apply_filters('w3tc_capability_menu_' . $slug, $base_capability), $slug, array($this, 'options'));
}
}
return $submenu_pages;
}
示例5: flush_posts_on_actions
static function flush_posts_on_actions()
{
static $attached = false;
if ($attached) {
return;
}
$attached = true;
$o = new Util_AttachToActions();
add_action('clean_post_cache', array($o, 'on_post_change'), 0, 2);
add_action('publish_post', array($o, 'on_post_change'), 0, 2);
add_action('switch_theme', array($o, 'on_change'), 0);
add_action('wp_update_nav_menu', array($o, 'on_change'), 0);
add_action('edit_user_profile_update', array($o, 'on_change'), 0);
if (Util_Environment::is_wpmu()) {
add_action('delete_blog', array($o, 'on_change'), 0);
}
add_action('edited_term', array($o, 'on_change'), 0);
}
示例6: activate
/**
* Activate plugin action
*
* @param bool $network_wide
* @return void
*/
public static function activate($network_wide)
{
// decline non-network activation at WPMU
if (Util_Environment::is_wpmu()) {
if ($network_wide) {
// we are in network activation
} else {
if ($_GET['action'] == 'error_scrape' && strpos($_SERVER['REQUEST_URI'], '/network/') !== false) {
// workaround for error_scrape page called after error
// really we are in network activation and going to throw some error
} else {
echo 'Please <a href="' . network_admin_url('plugins.php') . '">network activate</a> W3 Total Cache when using WordPress Multisite.';
die;
}
}
}
try {
$e = Dispatcher::component('Root_Environment');
$config = Dispatcher::config();
$e->fix_on_event($config, 'activate');
Generic_AdminLinks::link_update($config);
// try to save config file if needed, optional thing so exceptions
// hidden
if (!file_exists(Config::util_config_filename(0, false))) {
try {
// create folders
$e->fix_in_wpadmin($config);
} catch (\Exception $ex) {
}
try {
Util_Admin::config_save(Dispatcher::config(), $config);
} catch (\Exception $ex) {
}
}
} catch (\Exception $e) {
Util_Activation::error_on_exception($e);
}
}
示例7: rules_core_generate_nginx
/**
* Generates rules
*
* @param Config $config
* @return string
*/
function rules_core_generate_nginx($config)
{
$cache_dir = Util_Rule::filename_to_uri(W3TC_CACHE_MINIFY_DIR);
$first_regex_var = '$1';
// for subdir - need to count subdir in url
if (Util_Environment::is_wpmu() && !Util_Environment::is_wpmu_subdomain()) {
// take into accont case when whole subdir wpmu is installed in subdir
$home_uri = network_home_url('', 'relative');
if (substr($cache_dir, 0, strlen($home_uri)) == $home_uri) {
$cache_dir = $home_uri . '([a-z0-9]+/)?' . substr($cache_dir, strlen($home_uri));
} else {
$cache_dir = '(/[a-z0-9]+)?' . $cache_dir;
}
$first_regex_var = '$2';
}
$minify_uri = rtrim(network_site_url('', 'relative'), '/') . '/';
$engine = $config->get_string('minify.engine');
$browsercache = $config->get_boolean('browsercache.enabled');
$compression = $browsercache && $config->get_boolean('browsercache.cssjs.compression') && !defined('W3TC_PAGECACHE_OUTPUT_COMPRESSION_OFF');
$rules = '';
$rules .= W3TC_MARKER_BEGIN_MINIFY_CORE . "\n";
if ($engine == 'file') {
$rules .= "set \$w3tc_enc \"\";\n";
if ($compression) {
$rules .= "if (\$http_accept_encoding ~ gzip) {\n";
$rules .= " set \$w3tc_enc .gzip;\n";
$rules .= "}\n";
}
$rules .= "if (-f \$request_filename\$w3tc_enc) {\n";
$rules .= " rewrite (.*) \$1\$w3tc_enc break;\n";
$rules .= "}\n";
}
$rules .= "rewrite ^{$cache_dir}/ {$minify_uri}index.php last;\n";
$rules .= W3TC_MARKER_END_MINIFY_CORE . "\n";
return $rules;
}
示例8: admin_init
/**
* Setup notices actions
*/
function admin_init()
{
$capability = apply_filters('w3tc_capability_admin_notices', 'manage_options');
if (current_user_can($capability)) {
if (is_admin() && Util_Admin::is_w3tc_admin_page()) {
/**
* Only admin can see W3TC notices and errors
*/
if (!Util_Environment::is_wpmu()) {
add_action('admin_notices', array($this, 'admin_notices'), 1, 1);
}
add_action('network_admin_notices', array($this, 'admin_notices'), 1, 1);
}
}
}
示例9: is_network_admin
<?php
namespace W3TC;
if (!defined('W3TC')) {
die;
}
$config = Dispatcher::config();
$page = Util_Admin::get_current_page();
$licensing_visible = (!Util_Environment::is_wpmu() || is_network_admin()) && !ini_get('w3tc.license_key') && get_transient('w3tc_license_status') != 'host_valid';
?>
<?php
do_action('w3tc-dashboard-head');
?>
<div class="wrap" id="w3tc">
<h2 class="logo"><?php
_e('W3 Total Cache <span>by W3 EDGE <sup>®</sup></span>', 'w3-total-cache');
?>
</h2>
<?php
if (!Util_Environment::is_w3tc_pro($config)) {
?>
<?php
include W3TC_INC_OPTIONS_DIR . '/edd/buy.php';
}
?>
<?php
switch ($page) {
case 'w3tc_general':
$anchors = array(array('id' => 'general', 'text' => __('General', 'w3-total-cache')), array('id' => 'page_cache', 'text' => __('Page Cache', 'w3-total-cache')), array('id' => 'minify', 'text' => 'Minify'), array('id' => 'system_opcache', 'text' => __('Opcode Cache', 'w3-total-cache')), array('id' => 'database_cache', 'text' => __('Database Cache', 'w3-total-cache')), array('id' => 'object_cache', 'text' => __('Object Cache', 'w3-total-cache')));
示例10: w3tc_errors
function w3tc_errors($errors)
{
$c = Dispatcher::config();
$state = Dispatcher::config_state();
$cdn_engine = $c->get_string('cdn.engine');
if (Cdn_Util::is_engine_push($cdn_engine)) {
/**
* Show notification if upload queue is not empty
*/
try {
if (!($error = get_transient('w3tc_cdn_error')) && !$this->_is_queue_empty()) {
$errors['cdn_unsuccessful_queue'] = sprintf(__('The %s has unresolved errors. Empty the queue to restore normal operation.', 'w3-total-cache'), Util_Ui::button_popup(__('unsuccessful transfer queue', 'w3-total-cache'), 'cdn_queue'));
} elseif ($error) {
$errors['cdn_generic'] = $error;
}
} catch (\Exception $ex) {
$errors[] = $ex->getMessage();
set_transient('w3tc_cdn_error', $ex->getMessage(), 30);
}
/**
* Check upload settings
*/
$upload_info = Util_Http::upload_info();
if (!$upload_info) {
$upload_path = get_option('upload_path');
$upload_path = trim($upload_path);
if (empty($upload_path)) {
$upload_path = WP_CONTENT_DIR . '/uploads';
$errors['cdn_uploads_folder_empty'] = sprintf(__('The uploads directory is not available. Default WordPress directories will be created: <strong>%s</strong>.', 'w3-total-cache'), $upload_path);
}
if (!Util_Environment::is_wpmu()) {
$errors['cdn_uploads_folder_not_found'] = sprintf(__('The uploads path found in the database (%s) is inconsistent with the actual path. Please manually adjust the upload path either in miscellaneous settings or if not using a custom path %s automatically to resolve the issue.', 'w3-total-cache'), $upload_path, Util_Ui::button_link(__('update the path', 'w3-total-cache'), Util_Ui::url(array('w3tc_config_update_upload_path' => 'y'))));
}
}
}
/**
* Check CDN settings
*/
$error = '';
switch (true) {
case $cdn_engine == 'ftp' && !count($c->get_array('cdn.ftp.domain')):
$errors['cdn_ftp_empty'] = __('A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working:
The <strong>"Replace default hostname with"</strong>
field cannot be empty. Enter <acronym
title="Content Delivery Network">CDN</acronym>
provider hostname <a href="?page=w3tc_cdn#configuration">here</a>.
<em>(This is the hostname used in order to view objects
in a browser.)</em>', 'w3-total-cache');
break;
case $cdn_engine == 's3' && ($c->get_string('cdn.s3.key') == '' || $c->get_string('cdn.s3.secret') == '' || $c->get_string('cdn.s3.bucket') == ''):
$error = __('The <strong>"Access key", "Secret key" and "Bucket"</strong> fields cannot be empty.', 'w3-total-cache');
break;
case $cdn_engine == 'cf' && ($c->get_string('cdn.cf.key') == '' || $c->get_string('cdn.cf.secret') == '' || $c->get_string('cdn.cf.bucket') == '' || $c->get_string('cdn.cf.id') == '' && !count($c->get_array('cdn.cf.cname'))):
$error = __('The <strong>"Access key", "Secret key", "Bucket" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache');
break;
case $cdn_engine == 'cf2' && ($c->get_string('cdn.cf2.key') == '' || $c->get_string('cdn.cf2.secret') == '' || $c->get_string('cdn.cf2.id') == '' && !count($c->get_array('cdn.cf2.cname'))):
$error = __('The <strong>"Access key", "Secret key" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache');
break;
case $cdn_engine == 'rscf' && ($c->get_string('cdn.rscf.user') == '' || $c->get_string('cdn.rscf.key') == '' || $c->get_string('cdn.rscf.container') == ''):
$error = __('The <strong>"Username", "API key", "Container" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache');
break;
case $cdn_engine == 'azure' && ($c->get_string('cdn.azure.user') == '' || $c->get_string('cdn.azure.key') == '' || $c->get_string('cdn.azure.container') == ''):
$error = __('The <strong>"Account name", "Account key" and "Container"</strong> fields cannot be empty.', 'w3-total-cache');
break;
case $cdn_engine == 'mirror' && !count($c->get_array('cdn.mirror.domain')):
$error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache');
break;
case $cdn_engine == 'netdna':
$fields = array();
if ($c->get_string('cdn.netdna.authorization_key') == '') {
$fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"';
}
if (!count($c->get_array('cdn.netdna.domain'))) {
$fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"';
}
if ($fields) {
$error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields));
}
if ($c->get_string('cdn.netdna.authorization_key') != '' && sizeof(explode('+', $c->get_string('cdn.netdna.authorization_key'))) != 3) {
$error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache');
} elseif ($c->get_integer('cdn.netdna.zone_id', 0) <= 0) {
$error .= __('You need to select / create a pull zone.', 'w3-total-cache');
}
break;
case $cdn_engine == 'maxcdn':
$fields = array();
if ($c->get_string('cdn.maxcdn.authorization_key') == '') {
$fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"';
}
if (!count($c->get_array('cdn.maxcdn.domain'))) {
$fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"';
}
if ($fields) {
$error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields));
}
if ($c->get_string('cdn.maxcdn.authorization_key') != '' && sizeof(explode('+', $c->get_string('cdn.maxcdn.authorization_key'))) != 3) {
$error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache');
} elseif ($c->get_integer('cdn.maxcdn.zone_id', 0) <= 0) {
$error .= __('You need to select / create a pull zone.', 'w3-total-cache');
}
//.........这里部分代码省略.........
示例11: _e
<?php
_e('This enables inclusion of <acronym title="Real User Monitoring">RUM</acronym> when using Page Cache together with Browser Cache gzip or when using Page Cache with Disc: Enhanced', 'w3-total-cache');
?>
</span>
</p>
</td>
</tr>
<tr>
<th>
<label for="newrelic_use_php_function"><?php
_e('Use <acronym title=\\"Hypertext Preprocessor\\">PHP</acronym> function to set application name:', 'w3-total-cache');
?>
</label></th>
<td>
<?php
if (Util_Environment::is_wpmu()) {
?>
<input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" checked="checked" disabled="disabled" />
<p><span class="description">
<?php
_e('This is required when using New Relic on a network install to set the proper names for sites.', 'w3-total-cache');
?>
</span></p>
<?php
} else {
?>
<input name="extension__newrelic__use_php_function" type="hidden" value="0" />
<input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" <?php
checked($config->get_boolean(array('newrelic', 'use_php_function')));
?>
/>
示例12: rules_no404wp_generate_apache
/**
* Generate rules related to prevent for media 404 error by WP
*
* @param Config $config
* @return string
*/
private function rules_no404wp_generate_apache($config)
{
$a = $this->get_mime_types();
$cssjs_types = $a['cssjs'];
$html_types = $a['html'];
$other_types = $a['other'];
$extensions = array_merge(array_keys($cssjs_types), array_keys($html_types), array_keys($other_types));
$permalink_structure = get_option('permalink_structure');
$permalink_structure_ext = ltrim(strrchr($permalink_structure, '.'), '.');
if ($permalink_structure_ext != '') {
foreach ($extensions as $index => $extension) {
if (strstr($extension, $permalink_structure_ext) !== false) {
$extensions[$index] = preg_replace('~\\|?' . Util_Environment::preg_quote($permalink_structure_ext) . '\\|?~', '', $extension);
}
}
}
$exceptions = $config->get_array('browsercache.no404wp.exceptions');
$wp_uri = network_home_url('', 'relative');
$wp_uri = rtrim($wp_uri, '/');
$rules = '';
$rules .= W3TC_MARKER_BEGIN_BROWSERCACHE_NO404WP . "\n";
$rules .= "<IfModule mod_rewrite.c>\n";
$rules .= " RewriteEngine On\n";
// in subdir - rewrite theme files and similar to upper folder if file exists
if (Util_Environment::is_wpmu() && !Util_Environment::is_wpmu_subdomain()) {
$rules .= " RewriteCond %{REQUEST_FILENAME} !-f\n";
$rules .= " RewriteCond %{REQUEST_FILENAME} !-d\n";
$rules .= " RewriteCond %{REQUEST_URI} ^{$wp_uri}/([_0-9a-zA-Z-]+/)(.*\\.)(" . implode('|', $extensions) . ")\$ [NC]\n";
$document_root = Util_Rule::apache_docroot_variable();
$rules .= ' RewriteCond "' . $document_root . $wp_uri . '/%2%3" -f' . "\n";
$rules .= " RewriteRule .* {$wp_uri}/%2%3 [L]\n\n";
}
$rules .= " RewriteCond %{REQUEST_FILENAME} !-f\n";
$rules .= " RewriteCond %{REQUEST_FILENAME} !-d\n";
$imploded = implode('|', $exceptions);
if (!empty($imploded)) {
$rules .= " RewriteCond %{REQUEST_URI} !(" . $imploded . ")\n";
}
$rules .= " RewriteCond %{REQUEST_URI} \\.(" . implode('|', $extensions) . ")\$ [NC]\n";
$rules .= " RewriteRule .* - [L]\n";
$rules .= "</IfModule>\n";
$rules .= W3TC_MARKER_END_BROWSERCACHE_NO404WP . "\n";
return $rules;
}
示例13: set_appname
public function set_appname()
{
static $appname_set;
if (!$appname_set && ($this->_config->get_boolean(array('newrelic', 'use_php_function')) || Util_Environment::is_wpmu())) {
$appname_set = true;
$service = Dispatcher::component('Extension_NewRelic_Service');
$appname = $service->get_effective_appname();
$enable_xmit = $this->_config->get_boolean(array('newrelic', 'enable_xmit'));
\NewRelicWrapper::set_appname($appname, '', $enable_xmit);
}
}
示例14: _e
</label>
<br /><span class="description"><?php
_e('Try this option if your hosting environment uses a network based file system for a possible performance improvement.', 'w3-total-cache');
?>
</span>
</th>
</tr>
<?php
Util_Ui::config_item(array('key' => 'common.track_usage', 'control' => 'checkbox', 'checkbox_label' => __('Anonymously track usage to improve product quality', 'w3-total-cache'), 'style' => '2'));
?>
<?php
do_action('w3tc_settings_general_boxarea_miscellaneous_content');
?>
<?php
if (is_network_admin() || !Util_Environment::is_wpmu()) {
?>
<tr id="edge_mode">
<th colspan="2">
<?php
if (!Util_Environment::is_w3tc_edge($this->_config)) {
echo '<a href="' . Util_Ui::url(array('w3tc_edge_mode_enable' => 'y')) . '"><strong>' . __('Enable Edge mode', 'w3-total-cache') . '</strong></a>';
} else {
echo '<a href="' . Util_Ui::url(array('w3tc_edge_mode_disable' => 'y')) . '"><strong>' . __('Disable Edge mode', 'w3-total-cache') . '</strong></a>';
}
?>
<br /><span class="description"><?php
_e('Enable this to try out new functionality under development. Might cause issues on some sites.', 'w3-total-cache');
?>
</span>
</th>
示例15: on_change_profile
/**
* Flush cache when user profile is updated
*
* @param int $user_id
*/
function on_change_profile($user_id)
{
static $flushed = false;
if (!$flushed) {
if (Util_Environment::is_wpmu()) {
$blogs = get_blogs_of_user($user_id, true);
if ($blogs) {
global $w3_multisite_blogs;
$w3_multisite_blogs = $blogs;
}
}
$flush = Dispatcher::component('CacheFlush');
$flush->objectcache_flush();
$flushed = true;
}
}