'CatalogRelay Safe Importer for WooCommerce', 'php' => '7.4', 'wp' => '7.0', 'woo' => '10.0', 'woo_required' => true, ); } /** * Requirements checked while the plugin file loads: WooCommerce may load after this plugin, so its presence is checked * at plugins_loaded instead (see boot()), and only the PHP and WordPress versions are checked here. * * @return array */ public static function loadRequirements(): array { $req = self::requirements(); unset( $req['woo_required'], $req['woo'] ); return $req; } /** * Whether WooCommerce is active in a supported version (the importer's hooks are registered only then). * * @return bool */ public static function wooReady(): bool { return class_exists( 'WooCommerce' ) && defined( 'WC_VERSION' ) && version_compare( (string) WC_VERSION, self::requirements()['woo'], '>=' ); } /** * Product descriptor for the library (built once). * * @return ProductDescriptor */ public static function descriptor(): ProductDescriptor { if ( null === self::$descriptor ) { $d = new ProductDescriptor( array( 'id' => 'catalogrelay', 'name' => 'CatalogRelay', 'prefix' => 'catalogrelay_', 'slug' => Page::SLUG . '-settings', // The library's settings page; Page::SLUG is the import app. 'textDomain' => 'catalogrelay', 'file' => self::$file, 'version' => self::VERSION, 'capability' => 'manage_woocommerce', 'modules' => array( 'settings', 'log', 'jobs', 'plans', 'ledger', 'notify', 'compat', 'lifecycle' ), 'uninstallDefault' => 'delete', 'uninstallKey' => 'uninstall_delete', 'jobRetentionDays' => 90, 'ledgerRetentionDays' => 7, 'uninstall' => array( 'tables' => array( 'job_rows' ), 'options_like' => array( 'catalogrelay_' ), 'meta' => array( 'post' => array( '_catalogrelay_row_key', '_catalogrelay_source', '_catalogrelay_url_sha1', '_catalogrelay_stock_applied' ), ), 'cron' => array( Cleanup::CRON, Cleanup::CRON_CONTINUE ), 'as_groups' => array( 'catalogrelay', 'catalogrelay_jobs' ), 'dirs_always' => array( 'catalogrelay' ), 'dirs_on_delete' => array(), ), 'menuItems' => Page::menuItems(), 'healthTests' => SiteHealthTests::tests(), 'requirements' => self::requirements(), 'compat' => array( 'hpos' => true, 'blocks' => true, ), 'appSchema' => 2, 'migrations' => array( 1 => static function () { Schema::install(); }, 2 => static function () { Schema::install(); Schema::upgradeTo2(); }, ), ) ); $d->settings = SettingsDeclaration::declaration( $d ); self::$descriptor = $d; } return self::$descriptor; } /** * Activation: tables and schedule. * * @param bool $network_wide Network activation. * @return void */ public static function activate( bool $network_wide ): void { Bootstrap::activate( self::descriptor(), $network_wide ); Cleanup::schedule(); } /** * Deactivation: the library clears its schedule and ours (declared in the uninstall manifest), on every site for a * network deactivation. Data stays. Our own Action Scheduler actions (current site) would fail while no callback * exists: waiting downloads end with their warning, the recurring actions of scheduled imports are removed and waiting * repairs are set aside; the self-heal in boot() registers both again once the plugin runs. * * @param bool $network_wide Network deactivation. * @return void */ public static function deactivate( bool $network_wide = false ): void { ImageQueue::abandonPending(); ScheduledImport::unschedule(); Finalizer::park(); Bootstrap::deactivate( self::descriptor(), $network_wide ); } /** * Request-time wiring (plugins_loaded, priority 11, after the library booted at 10). * * @return void */ public static function boot(): void { Cleanup::hook(); // Also without WooCommerce: uploaded files and failed-rows CSVs still expire (NFR-012). if ( ! self::wooReady() ) { add_action( 'admin_notices', static function () { if ( current_user_can( 'activate_plugins' ) ) { echo '
' . esc_html__( 'CatalogRelay Safe Importer needs WooCommerce 10.0 or newer to be installed and active.', 'catalogrelay' ) . '