• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Util_Environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Util_Environment的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment类的具体用法?PHP Util_Environment怎么用?PHP Util_Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Util_Environment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: 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;
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:36,代码来源:Root_Environment.php


示例2: instance

 /**
  * Returns object instance. Called by WP engine
  *
  * @return DbCache_Wpdb
  */
 static function instance()
 {
     static $instance = null;
     if (is_null($instance)) {
         $processors = array();
         $call_default_constructor = true;
         // no caching during activation
         $is_installing = defined('WP_INSTALLING') && WP_INSTALLING;
         $config = Dispatcher::config();
         if (!$is_installing && $config->get_boolean('dbcache.enabled')) {
             $processors[] = new DbCache_WpdbInjection_QueryCaching();
         }
         if (Util_Environment::is_dbcluster()) {
             $processors[] = new Enterprise_Dbcache_WpdbInjection_Cluster();
         }
         $processors[] = new DbCache_WpdbInjection();
         $class = __CLASS__;
         $o = new $class($processors);
         $next_injection = new _CallUnderlying($o);
         foreach ($processors as $processor) {
             $processor->initialize_injection($o, $next_injection);
         }
         // initialize after processors configured
         $o->initialize();
         $instance = $o;
     }
     return $instance;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:33,代码来源:DbCache_Wpdb.php


示例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';
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:35,代码来源:Generic_Page_General.php


示例4: log_filename

 /**
  * Return full path to log file for module
  * Path used in priority
  * 1) W3TC_DEBUG_DIR
  * 2) WP_DEBUG_LOG
  * 3) W3TC_CACHE_DIR
  *
  * @param unknown $module
  * @param null    $blog_id
  * @return string
  */
 public static function log_filename($module, $blog_id = null)
 {
     if (is_null($blog_id)) {
         $blog_id = Util_Environment::blog_id();
     }
     $postfix = sprintf('%06d', $blog_id);
     if (defined('W3TC_BLOG_LEVELS')) {
         for ($n = 0; $n < W3TC_BLOG_LEVELS; $n++) {
             $postfix = substr($postfix, strlen($postfix) - 1 - $n, 1) . '/' . $postfix;
         }
     }
     $from_dir = W3TC_CACHE_DIR;
     if (defined('W3TC_DEBUG_DIR') && W3TC_DEBUG_DIR) {
         $dir_path = W3TC_DEBUG_DIR;
         if (!is_dir(W3TC_DEBUG_DIR)) {
             $from_dir = dirname(W3TC_DEBUG_DIR);
         }
     } else {
         $dir_path = Util_Environment::cache_dir('log');
     }
     $filename = $dir_path . '/' . $postfix . '/' . $module . '.log';
     if (!is_dir(dirname($filename))) {
         Util_File::mkdir_from(dirname($filename), $from_dir);
     }
     return $filename;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:37,代码来源:Util_Debug.php


示例5: w3tc_config_save

 public function w3tc_config_save($config)
 {
     // frontend activity
     $engine = $config->get_string(array('fragmentcache', 'engine'));
     $is_frontend_active = !empty($engine) && Util_Environment::is_w3tc_pro($config);
     $config->set_extension_active_frontend('fragmentcache', $is_frontend_active);
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:7,代码来源:Extension_FragmentCache_Plugin_Admin.php


示例6: get_current_blog_data

 /**
  * Returns blog_id by home url
  * If database not initialized yet - returns 0
  *
  * @return integer
  */
 public static function get_current_blog_data()
 {
     $host = Util_Environment::host();
     // subdomain
     if (Util_Environment::is_wpmu_subdomain()) {
         $blog_data = Util_WpmuBlogmap::try_get_current_blog_data($host);
         if (is_null($blog_data)) {
             $GLOBALS['w3tc_blogmap_register_new_item'] = $host;
         }
         return $blog_data;
     } else {
         // try subdir blog
         $url = $host . $_SERVER['REQUEST_URI'];
         $pos = strpos($url, '?');
         if ($pos !== false) {
             $url = substr($url, 0, $pos);
         }
         $url = rtrim($url, '/');
         $start_url = $url;
         for (;;) {
             $blog_data = Util_WpmuBlogmap::try_get_current_blog_data($url);
             if (!is_null($blog_data)) {
                 return $blog_data;
             }
             $pos = strrpos($url, '/');
             if ($pos === false) {
                 break;
             }
             $url = rtrim(substr($url, 0, $pos), '/');
         }
         $GLOBALS['w3tc_blogmap_register_new_item'] = $start_url;
         return null;
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:40,代码来源:Util_WpmuBlogmap.php


示例7: run

 function run()
 {
     add_filter('w3tc_config_default_values', array($this, 'w3tc_config_default_values'));
     add_action('w3tc_register_fragment_groups', array($this, 'register_groups'));
     $this->_config = Dispatcher::config();
     if (Util_Environment::is_w3tc_pro($this->_config)) {
         if (!is_admin()) {
             /**
              * Register the caching of content to specific hooks
              */
             foreach (array('genesis_header', 'genesis_footer', 'genesis_sidebar', 'genesis_loop', 'wp_head', 'wp_footer', 'genesis_comments', 'genesis_pings') as $hook) {
                 add_action($hook, array($this, 'cache_genesis_start'), -999999999);
                 add_action($hook, array($this, 'cache_genesis_end'), 999999999);
             }
             foreach (array('genesis_do_subnav', 'genesis_do_nav') as $filter) {
                 add_filter($filter, array($this, 'cache_genesis_filter_start'), -999999999);
                 add_filter($filter, array($this, 'cache_genesis_filter_end'), 999999999);
             }
         }
         /**
          * Since posts pages etc are cached individually need to be able to flush just those and not all fragment
          */
         add_action('clean_post_cache', array($this, 'flush_post_fragment'));
         add_action('clean_post_cache', array($this, 'flush_terms_fragment'), 0, 0);
         $this->_request_uri = $_SERVER['REQUEST_URI'];
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:27,代码来源:Extension_Genesis_Plugin.php


示例8: process

 /**
  * Do logic
  */
 function process()
 {
     /**
      * Skip some pages
      */
     switch (true) {
         case defined('DOING_AJAX'):
         case defined('DOING_CRON'):
         case defined('APP_REQUEST'):
         case defined('XMLRPC_REQUEST'):
         case defined('WP_ADMIN'):
         case defined('SHORTINIT') && SHORTINIT:
             return;
     }
     /**
      * Handle mobile or referrer redirects
      */
     if ($this->_mobile || $this->_referrer) {
         $mobile_redirect = $referrer_redirect = '';
         if ($this->_mobile) {
             $mobile_redirect = $this->_mobile->get_redirect();
         }
         if ($this->_referrer) {
             $referrer_redirect = $this->_referrer->get_redirect();
         }
         $redirect = $mobile_redirect ? $mobile_redirect : $referrer_redirect;
         if ($redirect) {
             Util_Environment::redirect($redirect);
             exit;
         }
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:35,代码来源:Mobile_Redirect.php


示例9: 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');
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:28,代码来源:Generic_Plugin_AdminNotifications.php


示例10: __construct

 /**
  * Constructor
  *
  * @param array   $config
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     if (isset($config['cache_dir'])) {
         $this->_cache_dir = trim($config['cache_dir']);
     } else {
         $this->_cache_dir = Util_Environment::cache_blog_dir($config['section'], $config['blog_id']);
     }
     $this->_exclude = isset($config['exclude']) ? (array) $config['exclude'] : array();
     $this->_flush_timelimit = isset($config['flush_timelimit']) ? (int) $config['flush_timelimit'] : 180;
     $this->_locking = isset($config['locking']) ? (bool) $config['locking'] : false;
     if (isset($config['flush_dir'])) {
         $this->_flush_dir = $config['flush_dir'];
     } else {
         if ($config['blog_id'] <= 0 && !isset($config['cache_dir'])) {
             // clear whole section if we operate on master cache
             // and in a mode when cache_dir not strictly specified
             $this->_flush_dir = Util_Environment::cache_dir($config['section']);
         } else {
             $this->_flush_dir = $this->_cache_dir;
         }
     }
     if (isset($config['use_wp_hash']) && $config['use_wp_hash']) {
         $this->_use_wp_hash = true;
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:31,代码来源:Cache_File.php


示例11: admin_init

 public function admin_init()
 {
     $config = Dispatcher::config();
     $groups = $config->get_array('mobile.rgroups');
     if (Util_Environment::is_w3tc_edge($config) && isset($groups['google']) && sizeof($groups['google']['agents']) == 1 && $groups['google']['agents'][0] == 'googlebot') {
         w3tc_delete_user_agent_group('google');
     }
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:8,代码来源:Extension_WordPressSeo_Plugin_Admin.php


示例12: get_suggested_home_ip

 public static function get_suggested_home_ip()
 {
     $ip = gethostbyname(Util_Environment::home_url_host());
     // check if it resolves to local IP, means host cant know its real IP
     if (substr($ip, 0, 4) == '127.' || substr($ip, 0, 3) == '10.' || substr($ip, 0, 8) == '192.168.') {
         return '';
     }
     return $ip;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:9,代码来源:Cdn_Fsd_Util.php


示例13: _request

 /**
  * Make API request
  *
  * @param string  $url
  * @return string
  */
 function _request($url)
 {
     $request_url = Util_Environment::url_format(W3TC_PAGESPEED_API_URL, array('url' => $url, 'key' => $this->key));
     $response = Util_Http::get($request_url, array('timeout' => 120));
     if (!is_wp_error($response) && $response['response']['code'] == 200) {
         return $response['body'];
     }
     return false;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:15,代码来源:PageSpeed_Api.php


示例14: instance

 /**
  * Returns cache engine instance
  *
  * @param string  $engine
  * @param array   $config
  * @return W3_Cache_Base
  */
 static function instance($engine, $config = array())
 {
     static $instances = array();
     // common configuration data
     if (!isset($config['blog_id'])) {
         $config['blog_id'] = Util_Environment::blog_id();
     }
     $instance_key = sprintf('%s_%s', $engine, md5(serialize($config)));
     if (!isset($instances[$instance_key])) {
         switch ($engine) {
             case 'apc':
                 if (function_exists('apcu_store')) {
                     $instances[$instance_key] = new Cache_Apcu($config);
                 } else {
                     if (function_exists('apc_store')) {
                         $instances[$instance_key] = new Cache_Apc($config);
                     }
                 }
                 break;
             case 'eaccelerator':
                 $instances[$instance_key] = new Cache_Eaccelerator($config);
                 break;
             case 'file':
                 $instances[$instance_key] = new Cache_File($config);
                 break;
             case 'file_generic':
                 $instances[$instance_key] = new Cache_File_Generic($config);
                 break;
             case 'memcached':
                 if (class_exists('\\Memcached')) {
                     $instances[$instance_key] = new Cache_Memcached($config);
                 } else {
                     if (class_exists('\\Memcache')) {
                         $instances[$instance_key] = new Cache_Memcache($config);
                     }
                 }
                 break;
             case 'redis':
                 $instances[$instance_key] = new Cache_Redis($config);
                 break;
             case 'wincache':
                 $instances[$instance_key] = new Cache_Wincache($config);
                 break;
             case 'xcache':
                 $instances[$instance_key] = new Cache_Xcache($config);
                 break;
             default:
                 trigger_error('Incorrect cache engine ' . $engine, E_USER_WARNING);
                 $instances[$instance_key] = new Cache_Base($config);
                 break;
         }
         if (!isset($instances[$instance_key]) || !$instances[$instance_key]->available()) {
             $instances[$instance_key] = new Cache_Base($config);
         }
     }
     return $instances[$instance_key];
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:64,代码来源:Cache.php


示例15: _get_origin

 /**
  * Returns origin
  *
  * @return string
  */
 function _get_origin()
 {
     if ($this->type == W3TC_CDN_CF_TYPE_S3) {
         $origin = sprintf('%s.s3.amazonaws.com', $this->_config['bucket']);
     } else {
         $origin = Util_Environment::host_port();
     }
     return $origin;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:14,代码来源:CdnEngine_S3_Cf.php


示例16: action_payment_code

 function action_payment_code()
 {
     $request_type = Util_Request::get_string('request_type');
     $request_id = date('YmdHi');
     $return_url = admin_url('admin.php?page=w3tc_support&request_type=' . $request_type . '&payment=1&request_id=' . $request_id);
     $cancel_url = admin_url('admin.php?page=w3tc_dashboard');
     $form_values = array("cmd" => "_xclick", "business" => W3TC_PAYPAL_BUSINESS, "item_name" => esc_attr(sprintf('%s: %s (#%s)', ucfirst(Util_Environment::host()), $this->_json_request_types[$request_type], $request_id)), "amount" => sprintf('%.2f', $this->_request_prices[$request_type]), "currency_code" => "USD", "no_shipping" => "1", "rm" => "2", "return" => esc_attr($return_url), "cancel_return" => esc_attr($cancel_url));
     echo json_encode($form_values);
     die;
 }
开发者ID:getupcloud,项目名称:wordpress-ex,代码行数:10,代码来源:Generic_Plugin_WidgetServices.php


示例17: minified_url

 public static function minified_url($minify_filename)
 {
     $path = Util_Environment::cache_blog_minify_dir();
     $filename = $path . '/' . $minify_filename;
     $c = Dispatcher::config();
     if (Util_Rule::can_check_rules() && $c->get_boolean('minify.rewrite')) {
         return Util_Environment::filename_to_url($filename);
     }
     return network_site_url('?w3tc_minify=' . $minify_filename);
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:10,代码来源:Minify_Core.php


示例18: dbcluster_config

 /**
  * Database cluster config editor
  *
  * @return void
  */
 function dbcluster_config()
 {
     $this->_page = 'w3tc_dbcluster_config';
     if (Util_Environment::is_dbcluster()) {
         $content = @file_get_contents(W3TC_FILE_DB_CLUSTER_CONFIG);
     } else {
         $content = @file_get_contents(W3TC_DIR . '/ini/dbcluster-config-sample.php');
     }
     include W3TC_INC_OPTIONS_DIR . '/enterprise/dbcluster-config.php';
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:15,代码来源:DbCache_Page.php


示例19: widget_form

 function widget_form()
 {
     $storage = new UsageStatistics_StorageReader();
     $summary_promise = $storage->get_history_summary_promise();
     $c = Dispatcher::config();
     if ($c->get_boolean('stats.enabled') && Util_Environment::is_w3tc_pro($c)) {
         include W3TC_DIR . '/UsageStatistics_Widget_View.php';
     } else {
         include W3TC_DIR . '/UsageStatistics_Widget_View_Disabled.php';
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:11,代码来源:UsageStatistics_Widget.php


示例20: cleanup

 function cleanup()
 {
     $c = Dispatcher::config();
     $engine = $c->get_string(array('fragmentcache', 'engine'));
     switch ($engine) {
         case 'file':
             $w3_cache_file_cleaner = new Cache_File_Cleaner(array('cache_dir' => Util_Environment::cache_blog_dir('fragment'), 'clean_timelimit' => $c->get_integer('timelimit.cache_gc')));
             $w3_cache_file_cleaner->clean();
             break;
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:11,代码来源:Extension_FragmentCache_Core.php



注:本文中的Util_Environment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Util_Ui类代码示例发布时间:2022-05-23
下一篇:
PHP UtilObjeto类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap