Filter
uncanny-automator
automator_tooltip_notifications_disable_assets
Filters whether to disable assets for tooltip notifications.
add_filter( 'automator_tooltip_notifications_disable_assets', $callback, 10, 1 );
Description
Filters whether to disable loading assets for tooltip notifications on all admin pages. Return `true` to prevent the enqueueing of JavaScript and CSS for these tooltips. This hook fires early in the admin page load process, before assets are enqueued.
Usage
add_filter( 'automator_tooltip_notifications_disable_assets', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Disable the loading of tooltip notification assets for specific admin pages.
*
* This filter allows developers to conditionally prevent the JavaScript and CSS
* for the tooltip notifications from being loaded on certain admin screens,
* potentially to improve performance or avoid conflicts.
*
* @param bool $disable_assets Whether to disable loading assets. Default is false.
* @return bool True to disable assets, false to load them.
*/
add_filter( 'automator_tooltip_notifications_disable_assets', function( $disable_assets ) {
// Check if we are on a specific admin page where assets are not needed.
// For example, if you want to disable them on the general settings page.
$current_screen = get_current_screen();
if ( $current_screen && 'options-general.php' === $current_screen->id ) {
return true; // Disable assets on the general settings page.
}
// For any other page, keep the default behavior (load assets).
return $disable_assets;
}, 10, 1 );
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/tooltip-notification/class-tooltip-notification.php:121
public function enqueue_scripts() {
if ( apply_filters( 'automator_tooltip_notifications_disable_assets', false ) ) {
return;
}
Utilities::enqueue_asset(
'uap-tooltip-notification',
'tooltip-notification',
array(
'localize' => array(
'UncannyAutomatorTooltipNotification' => $this->assets_tooltip_notification_js_object(),
),
)
);
}