Пример #1
0
 function init_finish()
 {
     parent::init_finish();
     if (!isset($this->options['first_install_time'])) {
         $this->options['first_install_time'] = time();
         $this->save_options();
     }
 }
 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'));
     }
 }
Пример #3
0
 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();
     }
 }
Пример #4
0
 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'));
     }
 }