VAT
Your cart

Your cart is empty.

Loading your own scripts and styles in Addofy

Queue your own scripts and stylesheets through Addofy instead of wp_enqueue_script(). They then follow Addofy's loading rules: never on the frontend, never in safe mode (?adba_safe=1 or the ADBA_SAFE_MODE constant) and never on an excluded screen.

Queue a script and a stylesheet

add_action( 'adba_screen', static function ( $screen ) {
	adba( 'assets' )->enqueue_external(
		'myplugin-admin',                          // Unique handle, prefixed with your slug.
		plugins_url( 'build/admin.js', __FILE__ ),
		array( 'adba-core' ),                      // Needed for window.adba.
		'1.2.0'
	);
	adba( 'assets' )->enqueue_external( 'myplugin-admin-css', plugins_url( 'build/admin.css', __FILE__ ) );
} );

Rules

  • The type follows the URL (a .css file is a stylesheet) or the fifth argument (script or style).
  • Addofy's own handles cannot be replaced.
  • Depend on adba-core when your script uses window.adba.
  • For a stylesheet that must load after the dark mode colors, depend on adba-module-darkmode-css.
  • The handles adba-module-design, adba-module-shell, adba-module-notices, adba-module-search and adba-module-help stay registered as aliases of adba-core, so an older dependency on them keeps working.

When to call it

Call enqueue_external() from the adba_screen action or from a module's on_screen(). Both run only when Addofy is active on the current screen, so you do not need to check the screen yourself.

Ready to connect your AI to real tools?

Start free trial