id; $is_woocommerce_page = property_exists( $current_screen, 'parent_base' ) && 'woocommerce' === $current_screen->parent_base; return $is_plugins_page || $is_woocommerce_page; } if ( version_compare( $GLOBALS['wp_version'], $minimum_wp_version, '<' ) ) { /** * Outputs for an admin notice about running WooCommerce Blocks on outdated WordPress. * * @since 2.5.0 */ function woocommerce_blocks_admin_unsupported_wp_notice() { if ( should_display_compatibility_notices() ) { ?>
'; printf( /* translators: %1$s is referring to a php constant name, %2$s is referring to the wp-config.php file. */ esc_html__( 'WooCommerce Blocks development mode requires the %1$s constant to be defined and true in your %2$s file. Otherwise you are loading the blocks package from WooCommerce core.', 'woo-gutenberg-products-block' ), 'JETPACK_AUTOLOAD_DEV', 'wp-config.php' ); echo '
'; } ); } /** * Autoload packages. * * The package autoloader includes version information which prevents classes in this feature plugin * conflicting with WooCommerce core. * * We want to fail gracefully if `composer install` has not been executed yet, so we are checking for the autoloader. * If the autoloader is not present, let's log the failure and display a nice admin notice. */ $autoloader = __DIR__ . '/vendor/autoload_packages.php'; if ( is_readable( $autoloader ) ) { require $autoloader; } else { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( // phpcs:ignore sprintf( /* translators: 1: composer command. 2: plugin directory */ esc_html__( 'Your installation of the WooCommerce Blocks feature plugin is incomplete. Please run %1$s within the %2$s directory.', 'woo-gutenberg-products-block' ), '`composer install`', '`' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '`' ) ); } /** * Outputs an admin notice if composer install has not been ran. */ add_action( 'admin_notices', function() { ?>
composer install',
'' . esc_html( str_replace( ABSPATH, '', __DIR__ ) ) . '
'
);
?>