Пример #1
0
 /**
  * Runs plugin
  */
 function run()
 {
     add_filter('cron_schedules', array($this, 'cron_schedules'), 5);
     add_action('init', array($this, 'init'), 1);
     if (Util_Environment::is_w3tc_pro_dev() && Util_Environment::is_w3tc_pro($this->_config)) {
         add_action('wp_footer', array($this, 'pro_dev_mode'));
     }
     add_action('admin_bar_menu', array($this, 'admin_bar_menu'), 150);
     if (isset($_REQUEST['w3tc_theme']) && isset($_SERVER['HTTP_USER_AGENT']) && stristr($_SERVER['HTTP_USER_AGENT'], W3TC_POWERED_BY) !== false) {
         add_filter('template', array($this, 'template_preview'));
         add_filter('stylesheet', array($this, 'stylesheet_preview'));
     } elseif ($this->_config->get_boolean('mobile.enabled') || $this->_config->get_boolean('referrer.enabled')) {
         add_filter('template', array($this, 'template'));
         add_filter('stylesheet', array($this, 'stylesheet'));
     }
     /**
      * Create cookies to flag if a pgcache role was loggedin
      */
     if (!$this->_config->get_boolean('pgcache.reject.logged') && $this->_config->get_array('pgcache.reject.logged_roles')) {
         add_action('set_logged_in_cookie', array($this, 'check_login_action'), 0, 5);
         add_action('clear_auth_cookie', array($this, 'check_login_action'), 0, 5);
     }
     if ($this->_config->get_string('common.support') == 'footer') {
         add_action('wp_footer', array($this, 'footer'));
     }
     if ($this->can_ob()) {
         ob_start(array($this, 'ob_callback'));
     }
 }
 /**
  *
  *
  * @return string
  */
 function update_license_status()
 {
     $status = '';
     $license_key = $this->get_license_key();
     $old_plugin_type = $this->_config->get_string('plugin.type');
     $plugin_type = '';
     if (!empty($license_key) || defined('W3TC_LICENSE_CHECK')) {
         $license = edd_w3edge_w3tc_check_license($license_key, W3TC_VERSION);
         if ($license) {
             $status = $license->license_status;
             if ($this->_status_is($status, 'active')) {
                 $plugin_type = 'pro';
             } elseif ($this->_status_is($status, 'inactive.by_rooturi') && Util_Environment::is_w3tc_pro_dev()) {
                 $status = 'valid';
                 $plugin_type = 'pro_dev';
             }
         }
         $this->_config->set('plugin.type', $plugin_type);
     } else {
         $status = 'no_key';
     }
     if ($old_plugin_type != $plugin_type) {
         try {
             $this->_config->set('plugin.type', $plugin_type);
             $this->_config->save();
         } catch (\Exception $ex) {
         }
     }
     return $status;
 }
Пример #3
0
 /**
  *
  *
  * @var Config $config
  * @return string
  */
 public static function w3tc_edition($config = null)
 {
     if (Util_Environment::is_w3tc_enterprise($config)) {
         return 'enterprise';
     }
     if (Util_Environment::is_w3tc_pro($config) && Util_Environment::is_w3tc_pro_dev()) {
         return 'pro development';
     }
     if (Util_Environment::is_w3tc_pro($config)) {
         return 'pro';
     }
     return 'community';
 }