Action Dynamic uncanny-automator

automator_admin_tools_tools_{dynamic}_tab

> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Fires when a specific tab is loaded within the Automator admin tools section, allowing for custom tab content injection.

add_action( 'automator_admin_tools_tools_{dynamic}_tab', $callback, 10, 1 );

Description

Fires for each tool tab within the Automator admin tools. Developers can use this dynamic hook to add custom content or functionality to specific tool tabs, identified by `$tab_id`. Ensure your hook targets the correct tab for desired integration.


Usage

add_action( 'automator_admin_tools_tools_{dynamic}_tab', 'your_function_name', 10, 1 );

Examples

<?php
/**
 * Example action for the 'automator_admin_tools_tools_debug_tab' hook.
 * This example adds a custom information section to the 'Debug' tab in the Automator admin tools.
 *
 * The hook is 'automator_admin_tools_tools_debug_tab' because $tab_id is 'debug' in this case.
 * The function hooked to this action will execute when the 'Debug' tab is rendered.
 * No parameters are passed to this specific hook.
 */
add_action(
	'automator_admin_tools_tools_debug_tab',
	function() {
		// Check if we are in the WordPress admin area.
		if ( ! is_admin() ) {
			return;
		}

		// Assuming a global or accessible variable exists that holds debug information.
		// In a real scenario, you might fetch this data dynamically or from a plugin setting.
		$plugin_debug_info = [
			'version'               => '1.2.3',
			'last_run_timestamp'    => time() - ( 60 * 60 * 24 ), // 24 hours ago
			'active_integrations'   => [ 'Google Sheets', 'Zapier' ],
			'error_log_status'      => 'enabled',
			'cache_status'          => 'cleared_recently',
		];

		?>
		<div class="automator-debug-info">
			<h3>Custom Debug Information</h3>
			<p><strong>Plugin Version:</strong> <?php echo esc_html( $plugin_debug_info['version'] ); ?></p>
			<p><strong>Last Task Run:</strong> <?php echo esc_html( human_time_diff( $plugin_debug_info['last_run_timestamp'] ) ); ?> ago</p>
			<p><strong>Active Integrations:</strong> <?php echo esc_html( implode( ', ', $plugin_debug_info['active_integrations'] ) ); ?></p>
			<p><strong>Error Log:</strong> <?php echo esc_html( $plugin_debug_info['error_log_status'] ); ?></p>
			<p><strong>Cache Status:</strong> <?php echo esc_html( $plugin_debug_info['cache_status'] ); ?></p>

			<p>
				<a href="#" class="button button-secondary">Clear Specific Cache</a>
				<a href="#" class="button button-secondary">View Detailed Logs</a>
			</p>
		</div>
		<?php
	},
	10, // Priority
	0  // Accepted args (no parameters passed to the hook)
);

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/views/admin-tools/tab/tools.php:48
src/core/views/admin-tools/tab/debug.php:48

<?php foreach ( $tools_tabs as $tab_id => $tools_tab ) { ?>

			<?php if ( $tools_tab->is_selected || $tools_tab->preload ) { ?>

				<uo-tab-panel id="<?php echo esc_attr( $tab_id ); ?>" <?php echo esc_attr( $tools_tab->is_selected ? 'active' : '' ); ?> >

					<?php do_action( 'automator_admin_tools_tools_' . $tab_id . '_tab' ); ?>

				</uo-tab-panel>

			<?php } ?>

		<?php } ?>

Scroll to Top