Filter uncanny-automator

uncanny_automator_log_get_delete_url

Filters the URL used to delete an entry from the Uncanny Automator log.

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

Description

This filter hook allows developers to modify the URL generated for deleting a specific Uncanny Automator log entry. It fires when the delete URL is being constructed for a log. Developers can intercept and alter this URL, for example, to implement custom deletion logic or redirect to a different endpoint. The current recipe, run number, and recipe log ID are passed as parameters for context.


Usage

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

Parameters

$delete_url (mixed)
This parameter contains the URL to delete a specific log entry.
$this (mixed)
This parameter contains the URL string used to delete a specific log entry.

Return Value

The filtered value.


Examples

// Example: Modify the delete URL for a log entry to append a specific query parameter.
add_filter( 'uncanny_automator_log_get_delete_url', function( $delete_url, $log_params ) {

	// Check if the log entry is associated with a specific recipe and has a run number.
	if ( ! empty( $log_params['recipe_id'] ) && ! empty( $log_params['run_number'] ) ) {
		// Append a custom query parameter to the delete URL.
		// This could be used, for example, to track deletions originating from a specific part of the admin interface.
		$delete_url = add_query_arg( 'source', 'admin-bulk-delete', $delete_url );
	}

	return $delete_url;

}, 10, 2 ); // Priority 10, 2 accepted arguments.

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/services/rest/endpoint/log-endpoint.php:364

public function get_delete_url() {

		if ( ! current_user_can( automator_get_admin_capability() ) ) {
			return '';
		}

		$delete_url = sprintf(
			'%s?post_type=%s&page=%s&recipe_id=%d&run_number=%d&recipe_log_id=%d&delete_specific_activity=1&wpnonce='
			. wp_create_nonce( AUTOMATOR_FREE_ITEM_NAME ),
			admin_url( 'edit.php' ),
			AUTOMATOR_POST_TYPE_RECIPE,
			'uncanny-automator-admin-logs',
			absint( $this->params['recipe_id'] ),
			absint( $this->params['run_number'] ),
			absint( $this->params['recipe_log_id'] )
		);

		return apply_filters( 'uncanny_automator_log_get_delete_url', $delete_url, $this->params );
	}


Scroll to Top