本文整理汇总了PHP中w3_is_network函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_is_network函数的具体用法?PHP w3_is_network怎么用?PHP w3_is_network使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_is_network函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
add_action('w3tc_dashboard_setup', array(&$this, 'wp_dashboard_setup'));
add_action('w3tc_network_dashboard_setup', array(&$this, 'wp_dashboard_setup'));
// Configure authorize and have_zone
$this->_setup($this->_config);
/**
* Retry setup with main blog
*/
if (w3_is_network() && is_network_admin() && !$this->authorized) {
$this->_config = new W3_Config(false, 1);
$this->_setup($this->_config);
}
if (w3_is_network()) {
$conig_admin = w3_instance('W3_ConfigAdmin');
$this->_sealed = $conig_admin->get_boolean('cdn.configuration_sealed');
}
if ($this->have_zone && $this->authorized && isset($_GET['page']) && strpos($_GET['page'], 'w3tc_dashboard') !== false) {
w3_require_once(W3TC_LIB_NETDNA_DIR . '/NetDNA.php');
w3_require_once(W3TC_LIB_NETDNA_DIR . '/NetDNAPresentation.php');
$authorization_key = $this->_config->get_string('cdn.maxcdn.authorization_key');
$alias = $consumerkey = $consumersecret = '';
$keys = explode('+', $authorization_key);
if (sizeof($keys) == 3) {
list($alias, $consumerkey, $consumersecret) = $keys;
}
$this->api = new NetDNA($alias, $consumerkey, $consumersecret);
add_action('admin_head', array(&$this, 'admin_head'));
}
}
示例2: activate
/**
* Activate plugin action
*
* @return void
*/
function activate($network_wide)
{
w3_require_once(W3TC_INC_DIR . '/functions/activation.php');
if (w3_is_network()) {
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;
}
}
}
/**
* Create cache folder and extension files
*/
try {
w3_activation_create_required_files();
if (!$this->_config->own_config_exists()) {
$this->_config->save();
}
// save admin config
$admin_config = w3_instance('W3_ConfigAdmin');
if (!$admin_config->own_config_exists()) {
$admin_config->save();
}
} catch (Exception $e) {
w3_activation_error_on_exception($e);
}
delete_option('w3tc_request_data');
add_option('w3tc_request_data', '', null, 'no');
}
示例3: get_wordpress_appname
/**
* @param W3_Config $config
* @param W3_Config $config_master
* @param bool $do_merge if to merge with network main site
* @return string
*/
public static function get_wordpress_appname($config, $config_master, $do_merge = true)
{
if (w3_is_network()) {
if ($config_master->get_boolean('newrelic.use_network_wide_id')) {
$appname = $config_master->get_string('newrelic.appname');
} else {
$merge = $config->get_boolean('newrelic.merge_with_network');
$merge_name = '';
if ($do_merge && $merge && w3_get_blog_id() != 0) {
$merge_name = ';' . $config_master->get_string('newrelic.appname');
}
if (w3_get_blog_id() != 0 && !$config->get_boolean('common.force_master')) {
$appname = $config->get_string('newrelic.appname', '');
if (empty($appname)) {
$prefix = $config->get_string('newrelic.appname_prefix');
$appname = $prefix . trim(w3_get_home_domain() . w3_get_site_path(), '/');
}
} else {
if (w3_get_blog_id() != 0) {
$prefix = $config->get_string('newrelic.appname_prefix');
$appname = $prefix . trim(w3_get_home_domain() . w3_get_site_path(), '/');
} else {
$appname = $config->get_string('newrelic.appname');
}
}
$appname = $appname . $merge_name;
}
} else {
$appname = $config->get_string('newrelic.appname');
}
return $appname;
}
示例4: view
/**
* Minify tab
*
* @return void
*/
function view()
{
$minify_enabled = $this->_config->get_boolean('minify.enabled');
$minify_rewrite_disabled = w3_is_network() && !$this->is_master() && !$this->_config_master->get_boolean('minify.rewrite');
$themes = w3_get_themes();
$templates = array();
$current_theme = w3tc_get_current_theme_name();
$current_theme_key = '';
foreach ($themes as $theme_key => $theme_name) {
if ($theme_name == $current_theme) {
$current_theme_key = $theme_key;
}
$templates[$theme_key] = w3_get_theme_templates($theme_name);
}
$css_imports_values = array('' => 'None', 'bubble' => 'Bubble', 'process' => 'Process');
$auto = $this->_config->get_boolean('minify.auto');
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$js_theme = W3_Request::get_string('js_theme', $current_theme_key);
$js_groups = $this->_config->get_array('minify.js.groups');
$css_theme = W3_Request::get_string('css_theme', $current_theme_key);
$css_groups = $this->_config->get_array('minify.css.groups');
$js_engine = $this->_config->get_string('minify.js.engine');
$css_engine = $this->_config->get_string('minify.css.engine');
$html_engine = $this->_config->get_string('minify.html.engine');
$css_imports = $this->_config->get_string('minify.css.imports');
// Required for Update Media Query String button
$browsercache_enabled = $this->_config->get_boolean('browsercache.enabled');
$browsercache_update_media_qs = $this->_config->get_boolean('browsercache.cssjs.replace');
include W3TC_INC_DIR . '/options/minify.php';
}
示例5: view
/**
* General tab
*
* @return void
*/
function view()
{
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
global $current_user;
$config_master = $this->_config_master;
/**
* @var $modules W3_ModuleStatus
*/
$modules = w3_instance('W3_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');
$fragmentcache_enabled = $modules->is_enabled('fragmentcache');
$enabled = $modules->plugin_is_enabled();
$enabled_checkbox = $modules->all_modules_enabled();
$check_rules = w3_can_check_rules();
$check_apc = function_exists('apc_store');
$check_eaccelerator = function_exists('eaccelerator_put');
$check_xcache = function_exists('xcache_set');
$check_wincache = function_exists('wincache_ucache_set');
$check_curl = function_exists('curl_init');
$check_memcached = class_exists('Memcache');
$check_ftp = function_exists('ftp_connect');
$check_tidy = class_exists('tidy');
$disc_enhanced_enabled = !(!$check_rules || !$this->is_master() && w3_is_network() && $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 = w3_cdn_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');
w3_require_once(W3TC_LIB_NEWRELIC_DIR . '/NewRelicWrapper.php');
$newrelic_conf_appname = NewRelicWrapper::get_wordpress_appname($this->_config, $this->_config_master, false);
$newrelic_applications = array();
$nerser = w3_instance('W3_NewRelicService');
$new_relic_installed = $nerser->module_is_enabled();
$new_relic_running = true;
if ($this->_config->get_boolean('newrelic.enabled')) {
$new_relic_configured = $this->_config->get_string('newrelic.api_key') && $this->_config->get_string('newrelic.account_id');
$newrelic_prefix = '';
if ($new_relic_configured) {
if (w3_is_network()) {
$newrelic_prefix = $this->_config->get_string('newrelic.appname_prefix');
}
try {
$newrelic_applications = $nerser->get_applications();
} catch (Exception $ex) {
}
$newrelic_application = $this->_config->get_string('newrelic.application_id');
}
}
$licensing_visible = (!w3_is_multisite() || is_network_admin()) && !ini_get('w3tc.license_key') && get_transient('w3tc_license_status') != 'host_valid';
$custom_areas = apply_filters("{$this->_page}_anchors", array());
include W3TC_INC_DIR . '/options/general.php';
}
示例6: run
function run()
{
$appname = NewRelicWrapper::get_wordpress_appname($this->_config, new W3_Config(true));
if ($this->_config->get_boolean('newrelic.use_php_function') || w3_is_network()) {
$enable_xmit = $this->_config->get_boolean('newrelic.enable_xmit');
NewRelicWrapper::set_appname($appname, '', $enable_xmit);
}
if (defined('DOING_CRON') && DOING_CRON) {
$this->background_task();
}
add_action('init', array($this, 'init'));
}
示例7: on_init
/**
* Register actions on init
*/
function on_init()
{
do_action('w3tc_register_fragment_groups');
$actions = $this->get_registered_actions();
foreach ($actions as $action => $groups) {
add_action($action, array($this, 'on_action'), 0, 0);
}
if (w3_is_network()) {
$global_actions = $this->get_registered_global_actions();
foreach ($global_actions as $action => $groups) {
add_action($action, array($this, 'on_action_global'), 0, 0);
}
}
}
示例8: activate
/**
* Activate plugin action
*
* @param bool $network_wide
* @return void
*/
function activate($network_wide)
{
w3_require_once(W3TC_INC_DIR . '/functions/activation.php');
// decline non-network activation at WPMU
if (w3_is_network()) {
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 = w3_instance('W3_AdminEnvironment');
/**
* @var W3_Config $config
*/
$config = w3_instance('W3_Config');
$e->fix_on_event($config, 'activate');
w3_instance('W3_AdminLinks')->link_update($config);
// try to save config file if needed, optional thing so exceptions
// hidden
if (!$config->own_config_exists()) {
try {
// create folders
$e->fix_in_wpadmin($config);
} catch (Exception $ex) {
}
try {
$config_admin = w3_instance('W3_ConfigAdmin');
$config->import_legacy_config();
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin.php');
w3_config_save(w3_instance('W3_Config'), $config, $config_admin);
} catch (Exception $ex) {
}
}
} catch (Exception $e) {
w3_activation_error_on_exception($e);
}
}
示例9: fix_on_wpadmin_request
public function fix_on_wpadmin_request($config, $force_all_checks)
{
$exs = new SelfTestExceptions();
$this->fix_folders($config, $exs);
/**
* @var W3_Config $config
*/
if ($config->get_boolean('config.check') || $force_all_checks) {
if ($config->get_boolean('minify.enabled') && $config->get_boolean('minify.rewrite')) {
$this->rules_core_add($config, $exs);
} else {
$this->rules_core_remove($exs);
}
if ((w3_is_apache() || w3_is_litespeed()) && w3_is_network() && !w3_is_subdomain_install()) {
if ($config->get_boolean('minify.enabled') && $config->get_boolean('minify.rewrite')) {
$this->rules_wpmu_subfolder_add($config, $exs);
} else {
$this->rules_wpmu_subfolder_remove($exs);
}
}
if ($config->get_boolean('minify.enabled') && $config->get_string('minify.engine') == 'file') {
$this->rules_cache_add($config, $exs);
} else {
$this->rules_cache_remove($exs);
}
}
// if no errors so far - check if rewrite actually works
if (count($exs->exceptions()) <= 0 || true) {
try {
if ($config->get_boolean('minify.enabled') && $config->get_string('minify.engine') == 'file' && $config->get_boolean('minify.debug')) {
$this->verify_rewrite_working();
}
} catch (Exception $ex) {
$exs->push($ex);
}
if ($config->get_boolean('minify.enabled')) {
$this->verify_engine_working($config, $exs);
}
}
if (count($exs->exceptions()) > 0) {
throw $exs;
}
}
示例10: w3_get_pgcache_rules_cache_path
/**
* Returns path of pgcache cache rules file
* Moved to separate file to not load rule.php for each disk enhanced request
*
* @return string
*/
function w3_get_pgcache_rules_cache_path()
{
switch (true) {
case w3_is_apache():
case w3_is_litespeed():
if (w3_is_network()) {
$url = w3_get_home_url();
$match = null;
if (preg_match('~http(s)?://(.+?)(/)?$~', $url, $match)) {
$home_path = $match[2];
return W3TC_CACHE_PAGE_ENHANCED_DIR . '/' . $home_path . '/.htaccess';
}
}
return W3TC_CACHE_PAGE_ENHANCED_DIR . '/.htaccess';
case w3_is_nginx():
return w3_get_nginx_rules_path();
}
return false;
}
示例11: locked
/**
* Check if plugin is locked
*
* @return boolean
*/
function locked()
{
static $locked = null;
if ($locked === null) {
if (w3_is_network() && function_exists('get_blog_list')) {
global $blog_id;
$blogs = get_blog_list();
foreach ($blogs as $blog) {
if ($blog['blog_id'] != $blog_id) {
$active_plugins = get_blog_option($blog['blog_id'], 'active_plugins');
if (in_array(W3TC_FILE, $active_plugins)) {
$locked = true;
break;
}
}
}
} else {
$locked = false;
}
}
return $locked;
}
示例12: is_sealed
/**
* Returns true if config section is sealed
* @param string $section
* @return boolean
*/
protected function is_sealed($section)
{
if ($this->is_master()) {
return false;
}
if (w3_is_network() && !$this->is_master() && w3_force_master()) {
return true;
}
// browsercache settings change rules, so not available in child settings
if ($section == 'browsercache') {
return true;
}
if ($section == 'minify' && !$this->_config_master->get_boolean('minify.enabled')) {
return true;
}
return $this->_config_admin->get_boolean($section . '.configuration_sealed');
}
示例13: set_appname
public function set_appname()
{
static $appname_set;
if (!$appname_set && ($this->_config->get_boolean('newrelic.use_php_function') || w3_is_network())) {
$appname_set = true;
$appname = NewRelicWrapper::get_wordpress_appname($this->_config, new W3_Config(true));
$enable_xmit = $this->_config->get_boolean('newrelic.enable_xmit');
NewRelicWrapper::set_appname($appname, '', $enable_xmit);
}
}
示例14: uri_to_cdn_uri
/**
* Convert local uri path to CDN type specific path
* @param $local_uri_path
* @return string
*/
function uri_to_cdn_uri($local_uri_path)
{
if (w3_is_network() && defined('DOMAIN_MAPPING') && DOMAIN_MAPPING) {
$local_uri_path = str_replace(w3_get_site_url(), '', $local_uri_path);
}
$engine = $this->_config->get_string('cdn.engine');
if (w3_is_cdn_mirror($engine)) {
if (w3_is_network() && strpos($local_uri_path, 'files') === 0) {
$upload_dir = wp_upload_dir();
return ltrim($this->abspath_to_relative_path(dirname($upload_dir['basedir'])) . '/' . $local_uri_path, '/');
}
}
$remote_path = $local_uri_path;
return ltrim($remote_path, "/");
}
示例15: try_create_wp_loader
/**
* @throws TryException
* @throws W3TCErrorException
* @return bool
*/
public function try_create_wp_loader()
{
$file_data = $this->w3tc_loader_file_data();
$filename = $file_data['filename'];
$data = $file_data['data'];
w3_require_once(W3TC_INC_DIR . '/functions/rule.php');
if (($current_data = @file_get_contents($filename)) && strstr(w3_clean_rules($current_data), w3_clean_rules($data)) !== false) {
return true;
}
$url = w3_is_network() ? network_admin_url('admin.php?page=w3tc_general') : admin_url('admin.php?page=w3tc_general');
try {
w3_require_once(W3TC_INC_DIR . '/functions/activation.php');
$result = w3_wp_write_to_file($filename, $data, $url);
} catch (Exception $ex) {
if ($ex instanceof FilesystemCredentialException) {
throw new TryException('Could not create file', array($filename), $ex->ftp_form());
} else {
throw new W3TCErrorException(sprintf('<strong>W3 Total Cache Error:</strong>Could not create file <strong>%s</strong>
with content: <pre>%s</pre><br />You need to do this manually.', $filename, esc_textarea($data)));
}
}
return true;
}