1.5 KiB
WP Admin Scripts
Scripts located in this directory are meant to be loaded on wp-admin pages outside the context of WooCommerce Admin, such as the post editor.
Each subdirectory of this directory is automatically added as an entrypoint in the webpack build script of WooCommerce Admin. When they are built, each one results in a pair of <subdirectory-name>.asset.php
and <subdirectory-name>.js
file in the build\wp-admin-scripts\
path, but they will not be automatically loaded on every PHP page.
The <subdirectory-name>.asset.php
file contains a list of automatically detected dependencies generated by the Dependency Extraction Webpack Plugin, so JS dependencies are not required to be manually enqueued as long as the WCAdminAssets::register_script()
function is used to enqueue the script.
As an example, the payment-method-promotions
wp-admin-scripts has generated payment-method-promotions.asset.php
with the contents below:
<?php return array('dependencies' => array('react', 'wc-components', 'wc-experimental', 'wc-settings', 'wc-store-data', 'wc-tracks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'e64b1e69145febe07734');
And is registered as a script like so: plugins/woocommerce/src/Internal/Admin/WCPayPromotion/Init.php
,
WCAdminAssets::register_script( 'wp-admin-scripts', 'payment-method-promotions', true );