array(), 'version' => filemtime( $script_path ), ); $script_url = plugins_url( $script_path, __FILE__ ); $script_asset['dependencies'][] = WC_ADMIN_APP; // Add WCA as a dependency to ensure it loads first. wp_register_script( 'woocommerce-admin-test-helper', $script_url, $script_asset['dependencies'], $script_asset['version'], true ); wp_enqueue_script( 'woocommerce-admin-test-helper' ); $css_file_version = filemtime( dirname( __FILE__ ) . '/build/index.css' ); wp_register_style( 'wp-components', plugins_url( 'dist/components/style.css', __FILE__ ), array(), $css_file_version ); wp_register_style( 'woocommerce-admin-test-helper', plugins_url( '/build/index.css', __FILE__ ), // Add any dependencies styles may have, such as wp-components. array( 'wp-components', ), $css_file_version ); wp_enqueue_style( 'woocommerce-admin-test-helper' ); } add_action( 'admin_enqueue_scripts', 'add_extension_register_script' ); add_action( 'before_woocommerce_init', function() { if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'product_block_editor', __FILE__, true ); } } ); /** * Simulate a WooCommerce error for remote logging testing. * * @throws Exception A simulated WooCommerce error if the option is set. */ function simulate_woocommerce_error() { throw new Exception( 'Simulated WooCommerce error for remote logging test' ); } $simulate_error = get_option( 'wc_beta_tester_simulate_woocommerce_php_error', false ); if ( $simulate_error ) { delete_option( 'wc_beta_tester_simulate_woocommerce_php_error' ); if ( 'core' === $simulate_error ) { add_action( 'woocommerce_loaded', 'simulate_woocommerce_error' ); } elseif ( 'beta-tester' === $simulate_error ) { throw new Exception( 'Test PHP exception from WooCommerce Beta Tester' ); } } // Initialize the live branches feature. require_once dirname( __FILE__ ) . '/includes/class-wc-beta-tester-live-branches.php';