Ejemplo n.º 1
0
 /**
  * Class constructor
  */
 private function __construct()
 {
     define('WP_STREAM_PLUGIN', plugin_basename(__FILE__));
     define('WP_STREAM_DIR', plugin_dir_path(__FILE__));
     define('WP_STREAM_URL', plugin_dir_url(__FILE__));
     define('WP_STREAM_INC_DIR', WP_STREAM_DIR . 'includes/');
     define('WP_STREAM_CLASS_DIR', WP_STREAM_DIR . 'classes/');
     define('WP_STREAM_EXTENSIONS_DIR', WP_STREAM_DIR . 'extensions/');
     spl_autoload_register(array($this, 'autoload'));
     // Load helper functions
     require_once WP_STREAM_INC_DIR . 'functions.php';
     // Load DB helper interface/class
     $driver = 'WP_Stream_DB';
     if (class_exists($driver)) {
         self::$db = new $driver();
     }
     if (!self::$db) {
         wp_die(__('Stream: Could not load chosen DB driver.', 'stream'), 'Stream DB Error');
     }
     /**
      * Filter allows a custom Stream API class to be instantiated
      *
      * @since 2.0.2
      *
      * @return object  The API class object
      */
     self::$api = apply_filters('wp_stream_api_class', new WP_Stream_API());
     // Install the plugin
     add_action('wp_stream_before_db_notices', array(__CLASS__, 'install'));
     // Load languages
     add_action('plugins_loaded', array(__CLASS__, 'i18n'));
     // Load settings, enabling extensions to hook in
     add_action('init', array('WP_Stream_Settings', 'load'), 9);
     // Load logger class
     add_action('plugins_loaded', array('WP_Stream_Log', 'load'));
     // Load connectors after widgets_init, but before the default of 10
     add_action('init', array('WP_Stream_Connectors', 'load'), 9);
     // Load extensions
     foreach (glob(WP_STREAM_EXTENSIONS_DIR . '*') as $extension) {
         require_once sprintf('%s/class-wp-stream-%s.php', $extension, basename($extension));
     }
     // Load support for feeds
     add_action('init', array('WP_Stream_Feeds', 'load'));
     // Add frontend indicator
     add_action('wp_head', array($this, 'frontend_indicator'));
     // Load admin area classes
     if (is_admin()) {
         add_action('init', array('WP_Stream_Admin', 'load'));
         add_action('init', array('WP_Stream_Dashboard_Widget', 'load'));
         add_action('init', array('WP_Stream_Live_Update', 'load'));
         add_action('init', array('WP_Stream_Pointers', 'load'));
         add_action('init', array('WP_Stream_Migrate', 'load'));
     }
     // Disable logging during the content import process
     add_filter('wp_stream_record_array', array(__CLASS__, 'disable_logging_during_import'), 10, 1);
     // Load WP-CLI command
     if (defined('WP_CLI') && WP_CLI) {
         require_once WP_STREAM_INC_DIR . 'wp-cli.php';
         WP_CLI::add_command(self::WP_CLI_COMMAND, 'WP_Stream_WP_CLI_Command');
     }
 }
Ejemplo n.º 2
0
 /**
  * Class constructor
  */
 private function __construct()
 {
     define('WP_STREAM_PLUGIN', plugin_basename(__FILE__));
     define('WP_STREAM_DIR', plugin_dir_path(__FILE__));
     define('WP_STREAM_URL', plugin_dir_url(__FILE__));
     define('WP_STREAM_INC_DIR', WP_STREAM_DIR . 'includes/');
     define('WP_STREAM_CLASS_DIR', WP_STREAM_DIR . 'classes/');
     define('WP_STREAM_EXTENSIONS_DIR', WP_STREAM_DIR . 'extensions/');
     spl_autoload_register(array($this, 'autoload'));
     // Load helper functions
     require_once WP_STREAM_INC_DIR . 'functions.php';
     // Load DB helper interface/class
     $driver = 'WP_Stream_DB';
     if (class_exists($driver)) {
         self::$db = new $driver();
     }
     if (!self::$db) {
         wp_die(__('Stream: Could not load chosen DB driver.', 'stream'), 'Stream DB Error');
     }
     // Load API helper interface/class
     self::$api = new WP_Stream_API();
     // Install the plugin
     add_action('wp_stream_before_db_notices', array(__CLASS__, 'install'));
     // Load languages
     add_action('plugins_loaded', array(__CLASS__, 'i18n'));
     // Load settings, enabling extensions to hook in
     add_action('init', array('WP_Stream_Settings', 'load'), 9);
     // Load network class
     if (is_multisite()) {
         WP_Stream_Network::get_instance();
     }
     // Load logger class
     add_action('plugins_loaded', array('WP_Stream_Log', 'load'));
     // Load connectors after widgets_init, but before the default of 10
     add_action('init', array('WP_Stream_Connectors', 'load'), 9);
     // Load extensions
     foreach (glob(WP_STREAM_EXTENSIONS_DIR . '*') as $extension) {
         require_once sprintf('%s/class-wp-stream-%s.php', $extension, basename($extension));
     }
     // Load support for feeds
     add_action('init', array('WP_Stream_Feeds', 'load'));
     // Add frontend indicator
     add_action('wp_head', array($this, 'frontend_indicator'));
     if (is_admin()) {
         add_action('plugins_loaded', array('WP_Stream_Admin', 'load'));
         add_action('plugins_loaded', array('WP_Stream_Dashboard_Widget', 'load'));
         add_action('plugins_loaded', array('WP_Stream_Live_Update', 'load'));
         add_action('plugins_loaded', array('WP_Stream_Pointers', 'load'));
         add_action('plugins_loaded', array('WP_Stream_Migrate', 'load'));
     }
 }