Пример #1
0
 /**
  * Loads core functionality across both admin and frontend.
  *
  * Creates all plugin globals, registers activation and related hooks,
  * loads the text domain and loads all plugin modules
  *
  * @since 4.0
  *
  * @access private
  *
  * @param string $plugin_file The main plugin file
  * @param string $plugin_name The plugin name
  *
  */
 public function init($plugin_file, $plugin_name)
 {
     global $itsec_globals, $itsec_logger, $itsec_lockout;
     $this->plugin_build = 4044;
     // used to trigger updates
     $this->plugin_file = $plugin_file;
     $this->plugin_dir = dirname($plugin_file) . '/';
     $this->current_time = current_time('timestamp');
     $this->current_time_gmt = current_time('timestamp', true);
     $this->notices_loaded = false;
     $this->doing_data_upgrade = false;
     $this->interactive = false;
     // Used to distinguish between a user modifying settings and the API modifying
     // settings (such as from Sync requests).
     $itsec_globals = array('plugin_name' => sanitize_text_field($plugin_name), 'plugin_dir' => $this->plugin_dir, 'current_time' => $this->current_time, 'current_time_gmt' => $this->current_time_gmt);
     require $this->plugin_dir . 'core/class-itsec-modules.php';
     add_action('itsec-register-modules', array($this, 'register_modules'));
     ITSEC_Modules::init_modules();
     require $this->plugin_dir . 'core/class-itsec-lib.php';
     require $this->plugin_dir . 'core/class-itsec-logger.php';
     require $this->plugin_dir . 'core/class-itsec-lockout.php';
     require $this->plugin_dir . 'core/class-itsec-files.php';
     require $this->plugin_dir . 'core/class-itsec-notify.php';
     require $this->plugin_dir . 'core/class-itsec-response.php';
     require $this->plugin_dir . 'core/lib/class-itsec-lib-user-activity.php';
     $this->itsec_files = ITSEC_Files::get_instance();
     $this->itsec_notify = new ITSEC_Notify();
     $itsec_logger = new ITSEC_Logger();
     $itsec_lockout = new ITSEC_Lockout($this);
     //Determine if we need to run upgrade scripts
     $plugin_data = get_site_option('itsec_data');
     if (false === $plugin_data) {
         $plugin_data = $this->save_plugin_data();
     }
     $itsec_globals['data'] = $plugin_data;
     if (isset($plugin_data['build']) && $plugin_data['build'] !== $this->plugin_build) {
         // We need to upgrade the data. Delay init of the rest of the plugin until the upgrade is complete.
         $this->doing_data_upgrade = true;
         // Run the actions early so that the rest of the code can still use the plugins_loaded hook.
         add_action('plugins_loaded', array($this, 'execute_upgrade'), -100);
         add_action('plugins_loaded', array($this, 'continue_init'), -90);
     } else {
         $this->continue_init();
     }
 }