min_daily' ); wp_clear_scheduled_hook( 'generate_category_lookup_table' ); } /** * Setup plugin once all other plugins are loaded. * * @return void */ public function on_plugins_loaded() { $this->load_plugin_textdomain(); if ( ! $this->has_satisfied_dependencies() ) { add_action( 'admin_init', array( $this, 'deactivate_self' ) ); add_action( 'admin_notices', array( $this, 'render_dependencies_notice' ) ); return; } $this->includes(); $this->hooks(); } /** * Define Constants. */ protected function define_constants() { $this->define( 'WC_ADMIN_APP', 'wc-admin-app' ); $this->define( 'WC_ADMIN_ABSPATH', dirname( __DIR__ ) . '/' ); $this->define( 'WC_ADMIN_DIST_JS_FOLDER', 'dist/' ); $this->define( 'WC_ADMIN_DIST_CSS_FOLDER', 'dist/' ); $this->define( 'WC_ADMIN_PLUGIN_FILE', WC_ADMIN_ABSPATH . 'woocommerce-admin.php' ); // WARNING: Do not directly edit this version number constant. // It is updated as part of the prebuild process from the package.json value. $this->define( 'WC_ADMIN_VERSION_NUMBER', '2.1.6' ); } /** * Load Localisation files. */ protected function load_plugin_textdomain() { load_plugin_textdomain( 'woocommerce-admin', false, basename( dirname( __DIR__ ) ) . '/languages' ); } /** * Include WC Admin classes. */ public function includes() { // Initialize the WC API extensions. ReportsSync::init(); Install::init(); Events::instance()->init(); API\Init::instance(); ReportExporter::init(); // CRUD classes. Notes::init(); // Initialize category lookup. CategoryLookup::instance()->init(); // Admin note providers. // @todo These should be bundled in the features/ folder, but loading them from there currently has a load order issue. new WooSubscriptionsNotes(); new OrderMilestones(); new TrackingOptIn(); new WooCommercePayments(); new InstallJPAndWCSPlugins(); new DrawAttention(); new SetUpAdditionalPaymentTypes(); new TestCheckout(); new SellingOnlineCourses(); new LearnMoreAboutVariableProducts(); new WelcomeToWooCommerceForStoreUsers(); new ManageStoreActivityFromHomeScreen(); // Initialize RemoteInboxNotificationsEngine. RemoteInboxNotificationsEngine::init(); // Initialize MerchantEmailNotifications. MerchantEmailNotifications::init(); } /** * Set up our admin hooks and plugin loader. */ protected function hooks() { add_filter( 'woocommerce_admin_features', array( $this, 'replace_supported_features' ), 0 ); Loader::get_instance(); } /** * Get an array of dependency error messages. * * @return array */ protected function get_dependency_errors() { $errors = array(); $wordpress_version = get_bloginfo( 'version' ); $minimum_wordpress_version = '5.4'; $minimum_woocommerce_version = '4.8'; $wordpress_minimum_met = version_compare( $wordpress_version, $minimum_wordpress_version, '>=' ); $woocommerce_minimum_met = class_exists( 'WooCommerce' ) && version_compare( WC_VERSION, $minimum_woocommerce_version, '>=' ); if ( ! $woocommerce_minimum_met ) { $errors[] = sprintf( /* translators: 1: URL of WooCommerce plugin, 2: The minimum WooCommerce version number */ __( 'The WooCommerce Admin feature plugin requires WooCommerce %2$s or greater to be installed and active.', 'woocommerce' ), 'https://wordpress.org/plugins/woocommerce/', $minimum_woocommerce_version ); } if ( ! $wordpress_minimum_met ) { $errors[] = sprintf( /* translators: 1: URL of WordPress.org, 2: The minimum WordPress version number */ __( 'The WooCommerce Admin feature plugin requires WordPress %2$s or greater to be installed and active.', 'woocommerce' ), 'https://wordpress.org/', $minimum_wordpress_version ); } return $errors; } /** * Returns true if all dependencies for the wc-admin plugin are loaded. * * @return bool */ public function has_satisfied_dependencies() { $dependency_errors = $this->get_dependency_errors(); return 0 === count( $dependency_errors ); } /** * Deactivates this plugin. */ public function deactivate_self() { deactivate_plugins( plugin_basename( WC_ADMIN_PLUGIN_FILE ) ); unset( $_GET['activate'] ); // phpcs:ignore CSRF ok. } /** * Notify users of the plugin requirements. */ public function render_dependencies_notice() { $message = $this->get_dependency_errors(); printf( '

%s

', implode( ' ', $message ) ); /* phpcs:ignore xss ok. */ } /** * Overwrites the allowed features array using a local `feature-config.php` file. * * @param array $features Array of feature slugs. */ public function replace_supported_features( $features ) { $feature_config = apply_filters( 'woocommerce_admin_get_feature_config', wc_admin_get_feature_config() ); $features = array_keys( array_filter( $feature_config ) ); return $features; } /** * Define constant if not already set. * * @param string $name Constant name. * @param string|bool $value Constant value. */ protected function define( $name, $value ) { if ( ! defined( $name ) ) { define( $name, $value ); } } /** * Prevent cloning. */ private function __clone() {} /** * Prevent unserializing. */ public function __wakeup() { die(); } }