'ids', 'number' => 0, ) ); foreach ( $site_ids as $site_id ) { switch_to_blog( $site_id ); self::install(); restore_current_blog(); } return; } self::install(); // Open the SpaceBay page once, only for the person who activated it in the browser. if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) && get_current_user_id() ) { update_option( 'spacebay_activation_redirect', get_current_user_id(), false ); } } /** * Runs on plugin deactivation. Data is always kept; scheduled events are removed. * * @return void */ public static function deactivate() { delete_option( 'rewrite_rules' ); delete_option( 'spacebay_activation_redirect' ); wp_clear_scheduled_hook( 'spacebay_daily' ); wp_clear_scheduled_hook( 'spacebay_event_reminders' ); wp_unschedule_hook( 'spacebay_send_notification_email' ); wp_unschedule_hook( 'spacebay_notification_emails' ); wp_unschedule_hook( 'spacebay_message_email' ); wp_unschedule_hook( 'spacebay_event_notify' ); } /** * Installs or upgrades the current site. * * @return void */ public static function install() { Schema::create(); Capabilities::add(); add_option( Settings::OPTION, Settings::defaults() ); update_option( self::DB_VERSION_OPTION, SPACEBAY_DB_VERSION ); update_option( 'spacebay_flush_rewrite', 1 ); if ( ! get_option( 'spacebay_installed_at' ) ) { update_option( 'spacebay_installed_at', time() ); } /** * Fires after SpaceBay is installed or upgraded on a site. * * @since 1.0.0 */ do_action( 'spacebay_installed' ); } /** * Upgrades the database when the stored version is older than the code. * * @return void */ public static function maybe_upgrade() { if ( get_option( self::DB_VERSION_OPTION ) !== SPACEBAY_DB_VERSION ) { self::install(); } } /** * Installs SpaceBay on a new multisite site when network active. * * @param \WP_Site $site New site object. * @return void */ public static function install_new_site( $site ) { if ( ! function_exists( 'is_plugin_active_for_network' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } if ( ! is_plugin_active_for_network( plugin_basename( SPACEBAY_FILE ) ) ) { return; } switch_to_blog( $site->blog_id ); self::install(); restore_current_blog(); } /** * Adds SpaceBay tables to the list WordPress drops when a site is deleted. * * @param string[] $tables Tables WordPress will drop. * @return string[] */ public static function drop_tables_on_site_delete( $tables ) { return array_merge( $tables, \SpaceBay\Database\Tables::all() ); } }