Action uncanny-automator

automator_tables_purged

Fires after automator tables have been successfully purged, allowing for custom actions upon data cleanup.

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

Description

Fires after specific Uncanny Automator log and meta tables have been purged from the database. Developers can hook into this action to perform custom cleanup tasks, clear related transient data, or trigger secondary cleanup processes after the core tables are cleared.


Usage

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

Examples

<?php
/**
 * Example function to demonstrate the 'automator_tables_purged' action hook.
 * This function logs a message to the WordPress debug log when the automator tables are purged.
 * It accepts no arguments as per the hook's definition.
 */
function my_automator_tables_purged_callback() {
    // Check if WP_DEBUG is enabled to avoid unnecessary logging in production.
    if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
        error_log( 'Uncanny Automator tables have been successfully purged.' );

        // You could also perform other cleanup tasks here, like clearing caches
        // related to automator data if necessary. For this example, we'll just log.
    }
}

// Add the callback function to the 'automator_tables_purged' action hook.
// The third parameter '1' indicates that this callback accepts 1 argument.
// However, 'automator_tables_purged' is defined to not pass any arguments,
// so we can safely set this to 0 or omit it, as it's the default.
// For clarity, we'll explicitly set it to 0.
add_action( 'automator_tables_purged', 'my_automator_tables_purged_callback', 10, 0 );
?>

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/class-automator-db.php:814

public static function purge_tables() {

		global $wpdb;

		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_recipe_log`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_recipe_log_meta`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_action_log`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_action_log_meta`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_closure_log`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_closure_log_meta`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_trigger_log`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_trigger_log_meta`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_api_log`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_api_log_response`;" );
		$wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}uap_tokens_log`;" );

		do_action( 'automator_tables_purged' );

		return true;
	}

Internal Usage

Found in uncanny-automator-pro/src/core/loops/loop-entry-point.php:73:

add_action( 'automator_tables_purged', array( $this, 'purge_all_process' ) );
Scroll to Top