From ec042aa8f68afd8e213f3847fecc6abf6981e7d1 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Thu, 15 May 2014 16:02:37 -0500 Subject: [PATCH] Rework the methods for DB verification and installation --- stream.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/stream.php b/stream.php index 004538521..97dd78f53 100755 --- a/stream.php +++ b/stream.php @@ -71,9 +71,12 @@ private function __construct() { require_once WP_STREAM_INC_DIR . 'db.php'; $this->db = new WP_Stream_DB; - // Check DB and add message if not present + // Check DB and display an admin notice if there are tables missing add_action( 'init', array( $this, 'verify_database_present' ) ); + // Install the plugin + add_action( 'wp_stream_install', array( __CLASS__, 'install' ) ); + // Load languages add_action( 'plugins_loaded', array( __CLASS__, 'i18n' ) ); @@ -172,12 +175,8 @@ public static function install() { * @return void */ public function verify_database_present() { - if ( ! function_exists( 'is_plugin_active_for_network' ) ) { - require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); - } - /** - * Filter will halt verify_database_present() and install() if set to true + * Filter will halt install() if set to true * * @param bool * @return bool @@ -186,6 +185,10 @@ public function verify_database_present() { return; } + if ( ! function_exists( 'is_plugin_active_for_network' ) ) { + require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + } + global $wpdb; $database_message = ''; @@ -218,8 +221,8 @@ public function verify_database_present() { $uninstall_message = sprintf( __( 'Please uninstall the Stream plugin and activate it again.', 'stream' ), admin_url( 'plugins.php#stream' ) ); } - // Check upgrade routine - self::install(); + // Install the plugin + do_action( 'wp_stream_install' ); if ( ! empty( $database_message ) ) { self::notice( $database_message );