woocommerce/woocommerce-admin-test-help...

44 lines
1.1 KiB
PHP
Raw Normal View History

2021-02-22 02:16:59 +00:00
<?php
/**
* Plugin Name: woocommerce-admin-test-helper
*
* @package WooCommerce\Admin
*/
/**
* Register the JS.
*/
function add_extension_register_script() {
if ( ! class_exists( 'Automattic\WooCommerce\Admin\Loader' ) || ! \Automattic\WooCommerce\Admin\Loader::is_admin_or_embed_page() ) {
return;
}
$script_path = '/build/index.js';
$script_asset_path = dirname( __FILE__ ) . '/build/index.asset.php';
$script_asset = file_exists( $script_asset_path )
? require( $script_asset_path )
: array( 'dependencies' => array(), 'version' => filemtime( $script_path ) );
$script_url = plugins_url( $script_path, __FILE__ );
wp_register_script(
'wca-test-helper',
$script_url,
$script_asset['dependencies'],
$script_asset['version'],
true
);
wp_register_style(
'wca-test-helper',
plugins_url( '/build/index.css', __FILE__ ),
// Add any dependencies styles may have, such as wp-components.
array(),
filemtime( dirname( __FILE__ ) . '/build/index.css' )
);
wp_enqueue_script( 'wca-test-helper' );
wp_enqueue_style( 'wca-test-helper' );
}
add_action( 'admin_enqueue_scripts', 'add_extension_register_script' );