Filter
uncanny-automator
automator_db_missing_tables
Filters the list of missing database tables required for the core plugin functionality.
add_filter( 'automator_db_missing_tables', $callback, 10, 1 );
Description
Fires when missing database tables are detected by the plugin. Developers can use this filter to modify the list of missing tables or inject custom table names. This hook executes during database schema verification, allowing for programmatic intervention before tables are created.
Usage
add_filter( 'automator_db_missing_tables', 'your_function_name', 10, 1 );
Parameters
-
$missing_tables(mixed) - This parameter contains a list of tables that are expected to exist but are missing from the database.
Return Value
The filtered value.
Examples
add_filter( 'automator_db_missing_tables', function( $missing_tables ) {
// Example: If there are missing tables, add a custom one to the list.
if ( ! empty( $missing_tables ) && is_array( $missing_tables ) ) {
// Let's assume we're expecting a table named 'wp_uncannyautomator_custom_log'
// and if it's not in the $missing_tables array, we'll add it for demonstration.
$expected_custom_table = 'wp_uncannyautomator_custom_log';
if ( ! in_array( $expected_custom_table, $missing_tables ) ) {
$missing_tables[] = $expected_custom_table;
// Optionally, you might want to log this addition or perform other actions.
// error_log( "Uncanny Automator Pro: Added custom table '$expected_custom_table' to missing tables list." );
}
}
// Always return the (potentially modified) $missing_tables array.
return $missing_tables;
}, 10, 1 ); // Priority 10, accepts 1 argument.
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:77
public static function verify_base_tables( $execute = false ) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
if ( $execute ) {
self::create_tables();
self::create_views();
}
$queries = dbDelta( self::get_schema(), false );
$missing_tables = array();
foreach ( $queries as $table_name => $result ) {
if ( "Created table $table_name" === $result ) {
$missing_tables[] = $table_name;
}
}
if ( 0 < count( $missing_tables ) ) {
automator_update_option( 'automator_schema_missing_tables', $missing_tables );
} else {
automator_update_option( 'uap_database_version', AUTOMATOR_DATABASE_VERSION );
automator_delete_option( 'automator_schema_missing_tables' );
automator_delete_option( 'automator_schema_missing_views' );
}
return apply_filters( 'automator_db_missing_tables', $missing_tables );
}
Internal Usage
Found in uncanny-automator-pro/src/schema.php:59:
add_filter( 'automator_db_missing_tables', array( $this, 'add_missing_tables' ) );