Commit ddc3212f authored by Erick Hitter's avatar Erick Hitter
Browse files

Handle multisite table setup

parent 15582049
...@@ -35,6 +35,7 @@ class Events_Store extends Singleton { ...@@ -35,6 +35,7 @@ class Events_Store extends Singleton {
protected function class_init() { protected function class_init() {
// Create tables during installation // Create tables during installation
add_action( 'wp_install', array( $this, 'create_table_during_install' ) ); add_action( 'wp_install', array( $this, 'create_table_during_install' ) );
add_action( 'wpmu_new_blog', array( $this, 'create_tables_during_multisite_install' ) );
// Enable plugin when conditions support it, otherwise limit errors as much as possible // Enable plugin when conditions support it, otherwise limit errors as much as possible
if ( self::is_installed() ) { if ( self::is_installed() ) {
...@@ -94,7 +95,7 @@ class Events_Store extends Singleton { ...@@ -94,7 +95,7 @@ class Events_Store extends Singleton {
} }
/** /**
* Create table during setup * Create table during initial install
*/ */
public function create_table_during_install() { public function create_table_during_install() {
if ( 'wp_install' !== current_action() ) { if ( 'wp_install' !== current_action() ) {
...@@ -104,6 +105,19 @@ class Events_Store extends Singleton { ...@@ -104,6 +105,19 @@ class Events_Store extends Singleton {
$this->_prepare_table(); $this->_prepare_table();
} }
/**
* Create table when new subsite is added to a multisite
*/
public function create_tables_during_multisite_install( $bid ) {
switch_to_blog( $bid );
if ( ! self::is_installed() ) {
$this->prepare_table();
}
restore_current_blog();
}
/** /**
* Create table in non-setup contexts, with some protections * Create table in non-setup contexts, with some protections
*/ */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment