'stream-cherry-pick/stream-cherry-pick.php', 'WP_Stream_Data_Exporter' => 'stream-data-exporter/stream-data-exporter.php', 'WP_Stream_Notifications' => 'stream-notifications/stream-notifications.php', 'WP_Stream_Reports' => 'stream-reports/stream-reports.php', ); /** * 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 * * @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' ) ); 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' ) ); } } /** * Invoked when the PHP version check fails. Load up the translations and * add the error message to the admin notices */ public static function fail_php_version() { add_action( 'plugins_loaded', array( __CLASS__, 'i18n' ) ); self::notice( __( 'Stream requires PHP version 5.3+, plugin is currently NOT ACTIVE.', 'stream' ) ); } /** * */ public static function deprecated_plugins_exist() { foreach ( self::$deprecated_extensions as $class => $dir ) { if ( class_exists( $class ) ) { return true; } } return false; } /** * */ public static function deprecated_plugins_notice() { add_action( 'plugins_loaded', array( __CLASS__, 'i18n' ) ); if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $message = null; foreach ( self::$deprecated_extensions as $class => $dir ) { if ( class_exists( $class ) ) { $data = get_plugin_data( sprintf( '%s/%s', WP_PLUGIN_DIR, $dir ) ); $name = isset( $data['Name'] ) ? $data['Name'] : $dir; $message .= sprintf( '
  • %s
  • ', esc_html( $name ) ); deactivate_plugins( $dir ); } } if ( ! empty( $message ) ) { ob_start(); ?>

    Stream :

    =' ); } /** * Is Stream connected? * * @return bool */ public static function is_connected() { return ( self::$api->api_key && self::$api->site_uuid ); } /** * Is Stream in development mode? * * @return bool */ public static function is_development_mode() { $development_mode = false; if ( defined( 'WP_STREAM_DEV_DEBUG' ) ) { $development_mode = WP_STREAM_DEV_DEBUG; } else if ( site_url() && false === strpos( site_url(), '.' ) ) { $development_mode = true; } /** * Filter allows development mode to be overridden * * @return bool */ return apply_filters( 'wp_stream_development_mode', $development_mode ); } /** * Handle notice messages according to the appropriate context (WP-CLI or the WP Admin) * * @param string $message * @param bool $is_error * @return void */ public static function notice( $message, $is_error = true ) { if ( defined( 'WP_CLI' ) ) { $message = strip_tags( $message ); if ( $is_error ) { WP_CLI::warning( $message ); } else { WP_CLI::success( $message ); } } else { // Trigger admin notices late, so that any notices which occur during page load are displayed add_action( 'shutdown', array( __CLASS__, 'admin_notices' ) ); $notice = compact( 'message', 'is_error' ); if ( ! in_array( $notice, self::$notices ) ) { self::$notices[] = $notice; } } } /** * Show an error or other message in the WP Admin * * @action shutdown * @return void */ public static function admin_notices() { global $allowedposttags; $custom = array( 'progress' => array( 'class' => true, 'id' => true, 'max' => true, 'style' => true, 'value' => true, ), ); $allowed_html = array_merge( $allowedposttags, $custom ); ksort( $allowed_html ); foreach ( self::$notices as $notice ) { $class_name = empty( $notice['is_error'] ) ? 'updated' : 'error'; $html_message = sprintf( '
    %s
    ', esc_attr( $class_name ), wpautop( $notice['message'] ) ); echo wp_kses( $html_message, $allowed_html ); } } /** * Displays an HTML comment in the frontend head to indicate that Stream is activated, * and which version of Stream is currently in use. * * @since 1.4.5 * * @action wp_head * @return string|void An HTML comment, or nothing if the value is filtered out. */ public function frontend_indicator() { $comment = sprintf( 'Stream WordPress user activity plugin v%s', esc_html( self::VERSION ) ); // Localization not needed /** * Filter allows the HTML output of the frontend indicator comment * to be altered or removed, if desired. * * @return string The content of the HTML comment */ $comment = apply_filters( 'wp_stream_frontend_indicator', $comment ); if ( ! empty( $comment ) ) { echo sprintf( "\n", esc_html( $comment ) ); // xss ok } } /** * Return active instance of WP_Stream, create one if it doesn't exist * * @return WP_Stream */ public static function get_instance() { if ( empty( self::$instance ) ) { $class = __CLASS__; self::$instance = new $class; } return self::$instance; } } if ( ! WP_Stream::is_valid_php_version() ) { WP_Stream::fail_php_version(); } elseif ( WP_Stream::deprecated_plugins_exist() ) { WP_Stream::deprecated_plugins_notice(); } else { $GLOBALS['wp_stream'] = WP_Stream::get_instance(); } register_deactivation_hook( __FILE__, array( 'WP_Stream_Admin', 'remove_api_authentication' ) );