-
Notifications
You must be signed in to change notification settings - Fork 1
/
woocommerce-admin-test-helper.php
68 lines (56 loc) · 1.75 KB
/
woocommerce-admin-test-helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Plugin Name: WooCommerce Admin Test Helper
* Plugin URI: https://github.com/woocommerce/woocommerce-admin-test-helper
* Description: A helper plugin to assist with testing WooCommerce Admin
* Author: WooCommerce
* Author URI: https://woocommerce.com/
* Version: 0.7.6
*
* @package WooCommerce\Admin\TestHelper
*/
define( 'WC_ADMIN_TEST_HELPER_PLUGIN_FILE', 'woocommerce-admin-test-helper/woocommerce-admin-test-helper.php' );
/**
* Register the JS.
*/
function add_extension_register_script() {
$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(
'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', WC_ADMIN_TEST_HELPER_PLUGIN_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( 'plugins_loaded', function() {
if ( ! defined( 'WC_PLUGIN_FILE' ) ) {
return;
}
add_action( 'admin_enqueue_scripts', 'add_extension_register_script' );
// Load the plugin
require( 'plugin.php' );
});