2019-05-06 04:39:10 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Plugin Name: WooCommerce Admin Dashboard Section Example
|
|
|
|
*
|
2020-08-11 19:18:47 +00:00
|
|
|
* @package WooCommerce\Admin
|
2019-05-06 04:39:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the JS.
|
|
|
|
*/
|
|
|
|
function dashboard_section_register_script() {
|
|
|
|
|
2019-08-12 21:52:09 +00:00
|
|
|
if ( ! class_exists( 'Automattic\WooCommerce\Admin\Loader' ) || ! \Automattic\WooCommerce\Admin\Loader::is_admin_page() ) {
|
2019-05-06 04:39:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-23 22:10:32 +00:00
|
|
|
$asset_file = require __DIR__ . '/dist/index.asset.php';
|
2019-05-06 04:39:10 +00:00
|
|
|
wp_register_script(
|
2019-05-23 23:58:00 +00:00
|
|
|
'dashboard_section',
|
2019-05-06 04:39:10 +00:00
|
|
|
plugins_url( '/dist/index.js', __FILE__ ),
|
2021-03-23 22:10:32 +00:00
|
|
|
$asset_file['dependencies'],
|
|
|
|
$asset_file['version'],
|
2019-05-06 04:39:10 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
|
2019-05-23 23:58:00 +00:00
|
|
|
wp_enqueue_script( 'dashboard_section' );
|
2019-05-06 04:39:10 +00:00
|
|
|
}
|
|
|
|
add_action( 'admin_enqueue_scripts', 'dashboard_section_register_script' );
|