Ejemplo n.º 1
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 2
0
 public static function initialize()
 {
     self::$url = plugins_url('', __FILE__);
     self::$path = plugin_dir_path(__FILE__);
     self::plugins_loaded();
     self::add_actions();
     // Dependency Injection.  Singleton pattern.
     self::$config = WPIMConfig::getInstance();
     self::$api = WPIMAPI::getInstance();
     self::plugin_updater();
 }
Ejemplo n.º 3
0
 private static function update_reg_key($settings)
 {
     $all_reg_info = self::get_reg_info();
     $add_ons = self::get_add_ons(TRUE);
     $add_ons['core'] = FALSE;
     foreach ($add_ons as $add_on => $data) {
         $field_key = $add_on == 'core' ? 'license_key' : 'license_key_' . $add_on;
         $reg_info = isset($all_reg_info[$add_on]) ? $all_reg_info[$add_on] : FALSE;
         $reg_key = isset($settings[$field_key]) ? $settings[$field_key] : '';
         if (!$reg_key || $reg_key && !empty($reg_info['key']) && $reg_key == $reg_info['key']) {
             // Do nothing if they didn't enter a key, or it's the same key as already saved.
         } else {
             WPIMAPI::activate($data, $reg_key);
         }
     }
 }
Ejemplo n.º 4
0
 protected static function get_add_ons($installed = FALSE, $force = FALSE)
 {
     $add_ons = get_transient('wpim_add_ons');
     if ($force) {
         $add_ons = FALSE;
     }
     if (!$add_ons) {
         $add_ons = WPIMAPI::make_call('get_add_ons');
         set_transient('wpim_add_ons', $add_ons, 12 * HOUR_IN_SECONDS);
     }
     $add_ons = apply_filters('wpim_add_ons_list', $add_ons);
     if (!$installed) {
         return $add_ons;
     }
     $new_add_ons = array();
     foreach ($add_ons as $add_on) {
         if (isset($add_on->key)) {
             $new_add_ons[$add_on->key] = $add_on;
         }
     }
     if ($installed) {
         foreach ($new_add_ons as $key => $add_on) {
             if (empty($add_on->installed)) {
                 unset($new_add_ons[$key]);
             }
         }
     }
     return $new_add_ons;
 }