/**
  * Activation hook
  * 
  * @return void
  */
 function activate()
 {
     //If we have no stored settings for this version of the plugin, try importing them
     //from other versions (i.e. the free or the Pro version).
     if (!$this->load_options()) {
         $this->import_settings();
     }
     parent::activate();
 }
 function init_finish()
 {
     parent::init_finish();
     $should_save_options = false;
     //If we have no stored settings for this version of the plugin, try importing them
     //from other versions (i.e. the free or the Pro version).
     if (!$this->load_options()) {
         $this->import_settings();
         $should_save_options = true;
     }
     //Track first install time.
     if (!isset($this->options['first_install_time'])) {
         $this->options['first_install_time'] = time();
         $should_save_options = true;
     }
     if ($this->options['plugin_db_version'] < $this->plugin_db_version) {
         /* Put any activation code here. */
         $this->options['plugin_db_version'] = $this->plugin_db_version;
         $should_save_options = true;
     }
     if ($should_save_options) {
         //Skip saving options if the plugin hasn't been fully activated yet.
         if ($this->is_plugin_active($this->plugin_basename)) {
             $this->save_options();
         } else {
             //Yes, this method can actually run before WP updates the list of active plugins. That means functions
             //like is_plugin_active_for_network() will return false. As as result, we can't determine whether
             //the plugin has been network-activated yet, so lets skip setting up the default config until
             //the next page load.
         }
     }
     //This is here and not in init() because it relies on $options being initialized.
     if ($this->options['security_logging_enabled']) {
         add_action('admin_notices', array($this, 'display_security_log'));
     }
 }
 function init_finish()
 {
     parent::init_finish();
     $should_save_options = false;
     //If we have no stored settings for this version of the plugin, try importing them
     //from other versions (i.e. the free or the Pro version).
     if (!$this->load_options()) {
         $this->import_settings();
         $should_save_options = true;
     }
     //Track first install time.
     if (!isset($this->options['first_install_time'])) {
         $this->options['first_install_time'] = time();
         $should_save_options = true;
     }
     if ($this->options['plugin_db_version'] < $this->plugin_db_version) {
         /* Put any activation code here. */
         $this->options['plugin_db_version'] = $this->plugin_db_version;
         $should_save_options = true;
     }
     if ($should_save_options) {
         $this->save_options();
     }
 }
Example #4
0
 /**
  * Activation hook
  * 
  * @return void
  */
 function activate()
 {
     //If we have no stored settings for this version of the plugin, try importing them
     //from other versions (i.e. the free or the Pro version).
     if (!$this->load_options()) {
         $this->import_settings();
     }
     //Track first install time. Could be useful for, for example, selectively displaying
     //a "What's New" message only to users who upgraded from an older version.
     $show_hints = $this->get_hint_visibility();
     $hint_id = 'ws_whats_new_120';
     if (!isset($show_hints[$hint_id])) {
         $show_hints[$hint_id] = empty($this->options['first_install_time']) && !empty($this->options['custom_menu']);
         $this->set_hint_visibility($show_hints);
     }
     if (empty($this->options['first_install_time'])) {
         $this->options['first_install_time'] = time();
     }
     parent::activate();
 }
 function init_finish()
 {
     parent::init_finish();
     $should_save_options = false;
     //If we have no stored settings for this version of the plugin, try importing them
     //from other versions (i.e. the free or the Pro version).
     if (!$this->load_options()) {
         $this->import_settings();
         $should_save_options = true;
     }
     //Track first install time.
     if (!isset($this->options['first_install_time'])) {
         $this->options['first_install_time'] = time();
         $should_save_options = true;
     }
     if ($this->options['plugin_db_version'] < $this->plugin_db_version) {
         /* Put any activation code here. */
         $this->options['plugin_db_version'] = $this->plugin_db_version;
         $should_save_options = true;
     }
     if ($should_save_options) {
         $this->save_options();
     }
     //This is here and not in init() because it relies on $options being initialized.
     if ($this->options['security_logging_enabled']) {
         add_action('admin_notices', array($this, 'display_security_log'));
     }
 }