blog_id ); self::register_tables(); restore_current_blog(); } /** * Register Action Scheduler tables on the current site. */ private static function register_tables(): void { self::load_dependencies(); if ( ! class_exists( 'ActionScheduler_HybridStore' ) ) { return; } $store = new ActionScheduler_HybridStore(); add_action( 'action_scheduler/created_table', array( $store, 'set_autoincrement' ), 10, 2 ); if ( ! class_exists( 'ActionScheduler_StoreSchema' ) || ! class_exists( 'ActionScheduler_LoggerSchema' ) ) { return; } $store_schema = new ActionScheduler_StoreSchema(); $logger_schema = new ActionScheduler_LoggerSchema(); $store_schema->register_tables( true ); $logger_schema->register_tables( true ); remove_action( 'action_scheduler/created_table', array( $store, 'set_autoincrement' ), 10 ); } /** * Check if Action Scheduler tables exist. * * @return bool */ private static function tables_exist(): bool { self::load_dependencies(); if ( ! class_exists( 'ActionScheduler_StoreSchema' ) ) { return false; } $store_schema = new ActionScheduler_StoreSchema(); return $store_schema->tables_exist(); } /** * Load required Action Scheduler classes if not already loaded. */ private static function load_dependencies(): void { if ( ! class_exists( 'ActionScheduler_HybridStore' ) ) { require_once WP_DEFENDER_DIR . 'vendor/woocommerce/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php'; } if ( ! class_exists( 'ActionScheduler_StoreSchema' ) ) { require_once WP_DEFENDER_DIR . 'vendor/woocommerce/action-scheduler/classes/schema/ActionScheduler_StoreSchema.php'; } if ( ! class_exists( 'ActionScheduler_LoggerSchema' ) ) { require_once WP_DEFENDER_DIR . 'vendor/woocommerce/action-scheduler/classes/schema/ActionScheduler_LoggerSchema.php'; } } }