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 a #wc-lost-connection-notice mirroring WP core's own notice on post edit screens.
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.
should_show_lost_connection_notice()  : bool
Whether the current screen should get the #wc-lost-connection-notice markup and toggle handler.

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 a #wc-lost-connection-notice mirroring WP core's own notice on post edit screens.

public render_lost_connection_notice() : void

See should_show_lost_connection_notice() for which screens get it.

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.

should_show_lost_connection_notice()

Whether the current screen should get the #wc-lost-connection-notice markup and toggle handler.

private should_show_lost_connection_notice() : bool

Limited to Woo admin screens, minus wc-admin React pages and classic post edit screens, which get WP core's own notice. Classic order edit is the exception: core's notice there wrongly claims local autosave backups are running, which disable_autosave() has turned off.

Return values
boolWhether to render and toggle the notice.