woocommerce/plugins/woocommerce-admin/bin/starter-pack/_main.php

44 lines
1.0 KiB
PHP
Raw Normal View History

<?php
/**
* Plugin Name: {{extension_name}}
*
* @package WooCommerce\Admin
*/
/**
* Register the JS.
*/
function add_extension_register_script() {
2020-11-19 01:09:07 +00:00
if ( ! is_admin() ) {
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(
'{{extension_slug}}',
$script_url,
$script_asset['dependencies'],
$script_asset['version'],
true
);
wp_register_style(
'{{extension_slug}}',
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( '{{extension_slug}}' );
wp_enqueue_style( '{{extension_slug}}' );
}
add_action( 'admin_enqueue_scripts', 'add_extension_register_script' );