Action uncanny-automator

automator_log_body

Fires after the log entry details are prepared, allowing modification of the displayed log body content.

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

Description

Fires within the main log view to allow custom content injection into the log details. Developers can use this hook to add specific information or UI elements related to the selected log tab, like custom tables or detailed breakdowns. It's executed after core log content has been displayed but before the section closes.


Usage

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

Parameters

$current_tab (mixed)
This parameter indicates the currently active tab in the Automator logs interface.

Examples

add_action( 'automator_log_body', 'my_custom_automator_log_display', 10, 1 );

/**
 * Displays custom content within the automator log body for a specific tab.
 *
 * This function is hooked into the 'automator_log_body' action and will only
 * execute when the $current_tab parameter matches 'my-custom-log-tab'.
 *
 * @param mixed $current_tab The current log tab being displayed.
 */
function my_custom_automator_log_display( $current_tab ) {
	if ( 'my-custom-log-tab' === $current_tab ) {
		?>
		<div class="my-custom-log-section">
			<h3>My Custom Log Information</h3>
			<p>This is some additional custom information displayed for the 'my-custom-log-tab'.</p>
			<?php
			// Example: Fetch and display some data related to this custom tab
			$custom_data = get_option( 'my_automator_custom_log_data' );
			if ( ! empty( $custom_data ) && is_array( $custom_data ) ) {
				echo '<ul>';
				foreach ( $custom_data as $item ) {
					echo '<li>' . esc_html( $item ) . '</li>';
				}
				echo '</ul>';
			} else {
				echo '<p>No custom log data found.</p>';
			}
			?>
		</div>
		<?php
	}
}

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-logs/component/logs.php:233
src/core/includes/recipe-logs-view.php:257

function automator_setup_activity_logs( $current_tab ) {
	$headings = array(
		/* translators: Log column. */
		//'recipe_type'      => esc_attr__( 'Recipe type', 'uncanny-automator' ),
		/* translators: Log column. */
		'recipe_title'     => esc_attr__( 'Recipe', 'uncanny-automator' ),
		/* translators: Log column. The recipe status */
		'recipe_completed' => esc_attr__( 'Status', 'uncanny-automator' ),
		/* translators: Log column. The recipe completion date */
		'recipe_date_time' => esc_attr__( 'Completion date', 'uncanny-automator' ),
		/* translators: Log column. Noun. The recipe iteration */
		'run_number'       => esc_attr__( 'Run #', 'uncanny-automator' ),
		/* translators: Log column. */
		'display_name'     => esc_attr__( 'User', 'uncanny-automator' ),
		/* translators: Log column. */
		'actions'          => esc_attr__( 'Actions', 'uncanny-automator' ),
	);

	$sortables = array(
		'recipe_title'     => array( 'recipe_title', true ),
		'recipe_date_time' => array( 'recipe_date_time', true ),
		'display_name'     => array( 'display_name', true ),
		'recipe_completed' => array( 'recipe_completed', true ),
		'run_number'       => array( 'run_number', true ),
	);

	//Prepare Table of elements
	$wp_list_table = new Logs_List_Table();
	$wp_list_table->set_columns( $headings );
	$wp_list_table->set_sortable_columns( $sortables );
	$wp_list_table->set_tab( $current_tab );
	$wp_list_table->prepare_items();
	$wp_list_table->display();
}

Internal Usage

Found in src/core/admin/api-log/class-api-log.php:23:

add_action( 'automator_log_body', array( $this, 'log_body' ) );
Scroll to Top