Skip to content

Commit

Permalink
Rework the methods for DB verification and installation
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejarrett committed May 15, 2014
1 parent 076bed1 commit ec042aa
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );

Expand Down Expand Up @@ -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
Expand All @@ -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 = '';
Expand Down Expand Up @@ -218,8 +221,8 @@ public function verify_database_present() {
$uninstall_message = sprintf( __( 'Please <a href="%s">uninstall</a> 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 );
Expand Down

1 comment on commit ec042aa

@frankiejarrett
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukecarbis Thoughts?

Please sign in to comment.