WooCommerce Code Reference

WC_Admin_Assets
in package

WC_Admin_Assets Class.

These scripts are enqueued in the admin of the store. The registered script handles in this class can be used to enqueue the scripts in the admin by third party plugins and the handles will follow WooCommerce's L-1 support policy. Scripts registered outside of this class do not guarantee support and can be removed in future versions of WooCommerce.

Table of Contents

__construct()  : mixed
Hook in tabs.
admin_scripts()  : mixed
Enqueue scripts.
admin_styles()  : mixed
Enqueue styles.
enqueue_command_palette_assets()  : void
Enqueue command palette assets.
register_scripts()  : mixed
Register the scripts.
render_lost_connection_notice()  : void
Render WordPress core's #lost-connection-notice markup on Woo admin screens that don't already get it for free.
enqueue_script()  : void
Enqueue a script in WordPress admin.
get_scripts()  : array<string|int, mixed>
Get the scripts used for registration.
is_order_meta_box_screen()  : bool
Helper function to determine whether the current screen is an order edit screen.

Methods

register_scripts()

Register the scripts.

public register_scripts() : mixed

These scripts are registered early to allow other plugins to take advantage of them by handle.

Return values
mixed

render_lost_connection_notice()

Render WordPress core's #lost-connection-notice markup on Woo admin screens that don't already get it for free.

public render_lost_connection_notice() : void

WP core renders this element on classic post-type edit pages (via edit-form-advanced.php), and wp-autosave.js toggles it in response to Heartbeat events. By echoing the same markup here and enqueueing the autosave script (see admin_scripts()), Woo admin screens inherit the same offline awareness without any new copy, styling, or behavior.

Translation strings use the 'default' text domain so WP core's existing translations apply.

Skipped on:

  • Classic post-type edit screens (WP core already renders the notice).
  • wc-admin React pages (they use their own layout rather than the standard admin_notices position).
Return values
void

enqueue_script()

Enqueue a script in WordPress admin.

private enqueue_script(string $script_path_name, string $script_name) : void

Similar to WCAdminAssets::register_script() but without enqueuing unnecessary dependencies.

Parameters
$script_path_name : string
$script_name : string
Return values
void

is_order_meta_box_screen()

Helper function to determine whether the current screen is an order edit screen.

private is_order_meta_box_screen(string $screen_id) : bool
Parameters
$screen_id : string

Screen ID.

Return values
boolWhether the current screen is an order edit screen.