woocommerce/plugins/woocommerce-admin/docs/examples/extensions/dashboard-section/woocommerce-admin-dashboard...

29 lines
660 B
PHP
Raw Normal View History

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