Filter
uncanny-automator
automator_enqueue_global_assets
Filters the list of admin screens where global Uncanny Automator assets are enqueued.
add_filter( 'automator_enqueue_global_assets', $callback, 10, 1 );
Description
Filter for `automator_enqueue_global_assets` to conditionally control which WordPress admin pages globally load Uncanny Automator's core assets. Developers can modify the provided array of hook suffixes to include or exclude specific pages, optimizing asset loading based on user needs or plugin integrations.
Usage
add_filter( 'automator_enqueue_global_assets', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Conditionally add a specific screen ID to the list of pages where global assets should be enqueued.
* This is an example of how you might add a custom Automator page to the list.
*
* @param array $hook_suffixes The array of screen IDs where global assets should be enqueued.
* @return array The modified array of screen IDs.
*/
add_filter( 'automator_enqueue_global_assets', function( $hook_suffixes ) {
// Let's say we have a custom integration setup page that needs these assets.
// The screen ID for this page might be 'my-custom-integration-setup'.
$custom_screen_id = 'my-custom-integration-setup';
// Check if our custom screen ID is not already in the array to avoid duplicates.
if ( ! in_array( $custom_screen_id, $hook_suffixes, true ) ) {
// Add our custom screen ID to the end of the array.
$hook_suffixes[] = $custom_screen_id;
}
// You could also remove specific pages if needed, for example:
// $hook_suffixes = array_diff( $hook_suffixes, array( 'options.php' ) );
return $hook_suffixes;
}, 10, 1 ); // 10 is the default priority, 1 is the number of accepted arguments.
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/core/admin/class-admin-menu.php:1295
/**
* Enqueues global assets in the Automator pages
*/
public function enqueue_global_assets( $hook ) {
global $current_screen;
// List of pages where we have to add the assets
$this->backend_enqueue_in = apply_filters(
'automator_enqueue_global_assets',
array(
'post.php', // Has filter, check callback
'edit-tags.php',
'options.php',
'uncanny-automator-dashboard',
'uncanny-automator-integrations',
Internal Usage
Found in src/core/admin/api-log/class-api-log.php:24:
add_filter( 'automator_enqueue_global_assets', array( $this, 'add_log_page' ) );