Filter uncanny-automator

automator_api_log_status

Filters the status of an API log entry after it has been processed.

add_filter( 'automator_api_log_status', $callback, 10, 2 );

Description

Filters the completion status of an API log entry. Developers can use this hook to programmatically modify the `$completed` status based on the provided `$request` object, allowing for custom logic in determining if an API log entry is considered complete.


Usage

add_filter( 'automator_api_log_status', 'your_function_name', 10, 2 );

Parameters

$completed (mixed)
This parameter represents the completion status of the API log entry, which can be modified by filters.
$request (mixed)
This parameter represents the completion status of an API log entry, allowing it to be modified by filters.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of using the 'automator_api_log_status' filter to modify the completion status display.
 * This example checks if the completion status is 'error' and appends a specific class
 * to it for potential styling or further processing.
 *
 * @param mixed $completed The original completion status.
 * @param object $request The request object containing details about the API log entry.
 * @return mixed The potentially modified completion status.
 */
add_filter( 'automator_api_log_status', function( $completed, $request ) {

	// Check if the request object and its 'completed' property are available.
	if ( $request && isset( $request->completed ) ) {

		// If the completion status is 'error', we can add a specific indicator.
		// In a real scenario, this might be to add a CSS class, change text, or log an additional detail.
		if ( $request->completed === 'error' ) {
			// For demonstration, we'll just append a string.
			// In a real plugin, you might return a more complex structure or modify an existing one.
			$completed = 'Error: ' . $completed;
		}
	}

	// Always return the (potentially modified) $completed value.
	return $completed;
}, 10, 2 ); // Priority 10, accepts 2 arguments ($completed, $request)

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/api-log/class-api-log-table.php:267

$name = '<div class="uap-logs-table__item-main-sentence">' . $this->format_human_readable_sentence( $sentence ) . '</div>';
					}
				}
			}

			$type          = $request->type;
			$date          = $request->date;
			$completed     = apply_filters( 'automator_api_log_status', $completed, $request );
			$error_message = apply_filters( 'automator_api_log_error', $request->error_message, $request );
			$recipe_link   = get_edit_post_link( absint( $request->automator_recipe_id ) );
			$recipe_name   = '<a href="' . $recipe_link . '" class="uap-log-table__recipe-name">' . $request->recipe_title . '</a>';

			$recipe_status   = Automator_Status::name( $request->completed );
			$recipe_finished = Automator_Status::finished( $request->completed );


Scroll to Top