Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicate call to install() method #533

Merged
merged 3 commits into from
May 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 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 @@ -112,11 +115,10 @@ private function __construct() {

if ( is_admin() ) {
require_once WP_STREAM_INC_DIR . 'admin.php';
require_once WP_STREAM_INC_DIR . 'extensions.php';
add_action( 'plugins_loaded', array( 'WP_Stream_Admin', 'load' ) );
add_action( 'admin_init', array( 'WP_Stream_Extensions', 'get_instance' ) );

add_action( 'init', array( __CLASS__, 'install' ), 10, 1 );
require_once WP_STREAM_INC_DIR . 'extensions.php';
add_action( 'admin_init', array( 'WP_Stream_Extensions', 'get_instance' ) );

// Registers a hook that connectors and other plugins can use whenever a stream update happens
add_action( 'admin_init', array( __CLASS__, 'update_activation_hook' ) );
Expand Down Expand Up @@ -162,16 +164,6 @@ public static function i18n() {
* @return void
*/
public static function install() {
/**
* Filter will halt install() if set to true
*
* @param bool
* @return bool
*/
if ( apply_filters( 'wp_stream_no_tables', false ) ) {
return;
}

// Install plugin tables
require_once WP_STREAM_INC_DIR . 'install.php';
$update = WP_Stream_Install::get_instance();
Expand All @@ -183,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() if set to true
* Filter will halt install() if set to true
*
* @param bool
* @return bool
Expand All @@ -197,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 @@ -229,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