Action uncanny-automator

automator_show_internal_admin_notice

Fires when internal admin notices should be displayed within the WordPress admin area.

add_action( 'automator_show_internal_admin_notice', $callback, 10, 1 );

Description

Fires on Automator admin pages after core admin notices are suppressed. Developers can hook into this action to display custom, context-specific admin notices related to Automator functionality, ensuring they only appear on relevant screens. This provides a clean way to manage internal notifications.


Usage

add_action( 'automator_show_internal_admin_notice', 'your_function_name', 10, 1 );

Examples

/**
 * Example function to display a custom admin notice if specific conditions are met.
 * This function is hooked to 'automator_show_internal_admin_notice'.
 *
 * @param string $current_screen_id The ID of the current admin screen.
 * @param array  $allowed_pages     An array of screen IDs where this notice should be displayed.
 */
function my_custom_automator_admin_notice( $current_screen_id, $allowed_pages ) {
	// Check if the current screen is one of the allowed Automator pages.
	if ( in_array( $current_screen_id, $allowed_pages, true ) ) {

		// Simulate a condition for displaying a notice, e.g., checking for a plugin option.
		$options = get_option( 'my_automator_plugin_settings' );
		if ( isset( $options['enable_custom_notice'] ) && $options['enable_custom_notice'] ) {
			?>
			<div class="notice notice-info is-dismissible">
				<p><?php esc_html_e( 'This is a custom admin notice from your plugin!', 'your-text-domain' ); ?></p>
			</div>
			<?php
		}
	}
}

// Register the custom admin notice function.
// We're providing $current_screen_id and $allowed_pages as arguments to the hook.
// The number of accepted arguments for this hook is 2.
add_action( 'automator_show_internal_admin_notice', 'my_custom_automator_admin_notice', 10, 2 );

// To make this example fully functional, you would need to define $current_screen_id and $allowed_pages
// in the context where 'automator_show_internal_admin_notice' is fired.
// For demonstration purposes, let's assume these are set globally or passed correctly.
// In a real scenario, these would likely be obtained from WordPress functions like get_current_screen()
// and defined within the Automator plugin's core logic.

// Example of how $current_screen_id and $allowed_pages might be defined before the hook is fired:
/*
global $current_screen, $automator_allowed_pages;
$current_screen_id = $current_screen->id;
$allowed_pages = $automator_allowed_pages; // Assuming this is an array like ['automation_page_slug', 'another_automator_page']

// ... later in the code where do_action( 'automator_show_internal_admin_notice' ); is called ...
*/

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-automator-review.php:485

public function hide_all_admin_notices_on_automator_pages() {

		$current_screen = get_current_screen();

		// Do not show if we cannot identify which screen it is.
		if ( ! $current_screen instanceof WP_Screen ) {
			return;
		}

		// Safe check in case WP_Screen changed its structure.
		if ( ! isset( $current_screen->id ) ) {
			return;
		}

		$allowed_pages = self::get_allowed_page_for_credits_notif( true );

		// Only remove admin_notices if its on Automator pages
		if ( in_array( $current_screen->id, $allowed_pages, true ) ) {
			// Remove all admin notices
			remove_all_actions( 'admin_notices' );
			remove_all_actions( 'all_admin_notices' );
		}

		do_action( 'automator_show_internal_admin_notice' );
	}

Internal Usage

Found in src/integrations/linkedin/helpers/linkedin-app-helpers.php:345:

add_action( 'automator_show_internal_admin_notice', array( $this, 'admin_notice_show_reminder' ) );

Found in src/integrations/facebook-groups/helpers/facebook-groups-helpers.php:135:

add_action( 'automator_show_internal_admin_notice', array( $this, 'admin_notice_template' ) );

Found in src/integrations/gravity-forms/class-gf-integration.php:78:

add_action( 'automator_show_internal_admin_notice', array( $this, 'automator_compatibility_notice' ) );

Found in src/core/integration-loader/class-integration-loader.php:217:

add_action( 'automator_show_internal_admin_notice', array( Load_Error_Handler::class, 'display_notice' ) );

Found in src/core/admin/class-import-recipe.php:83:

add_action( 'automator_show_internal_admin_notice', array( $this, 'maybe_display_import_errors' ) );

Found in src/core/admin/class-import-recipe.php:84:

add_action( 'automator_show_internal_admin_notice', array( $this, 'maybe_display_bulk_import_success' ) );

Found in src/core/admin/class-import-recipe.php:85:

add_action( 'automator_show_internal_admin_notice', array( $this, 'maybe_display_imported_recipe_warning' ) );

Found in src/core/admin/class-automator-review.php:69:

add_action( 'automator_show_internal_admin_notice', array( $this, 'maybe_ask_review' ) );

Found in src/core/admin/class-prune-logs.php:105:

add_action( 'automator_show_internal_admin_notice', array( $this, 'display_log_size_notification' ) );

Found in src/core/admin/notifications/notifications.php:82:

add_action( 'automator_show_internal_admin_notice', array( $this, 'show_notifications' ) );

Found in uncanny-automator-pro/src/integrations/modern-events-calendar/add-mec-integration.php:52:

add_action( 'automator_show_internal_admin_notice', array( $this, 'display_admin_notices' ) );

Found in uncanny-automator-pro/src/integrations/gravity-forms/class-gf-integration.php:155:

add_action( 'automator_show_internal_admin_notice', array( $this, 'automator_compatibility_notice' ) );

Found in uncanny-automator-pro/src/integrations/schedule/admin/admin-helper.php:21:

add_action( 'automator_show_internal_admin_notice', array( $this, 'display_cancel_schedule_success_message' ) );

Found in uncanny-automator-pro/src/core/admin/licensing/licensing.php:115:

add_action( 'automator_show_internal_admin_notice', array( $this, 'licensing_setup_error' ) );

Found in uncanny-automator-pro/src/core/admin/licensing/licensing.php:126:

add_action( 'automator_show_internal_admin_notice', array( $this, 'show_expiry_notice' ) );

Found in uncanny-automator-pro/src/core/admin/licensing/licensing.php:127:

add_action( 'automator_show_internal_admin_notice', array( $this, 'uapro_remind_to_add_license_notice_func' ) );
Scroll to Top