Action
Dynamic
uncanny-automator
automator_admin_tools_{dynamic}_tab
> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Fires when a dynamic tab within Automator's admin tools is loaded, allowing for custom tab content insertion.
add_action( 'automator_admin_tools_{dynamic}_tab', $callback, 10, 1 );
Description
Fires within the Admin Tools section for a specific tab. Use this to inject custom content or functionality into individual Admin Tools tabs, allowing for dynamic tab-specific integrations. The hook name is determined by the tab key (e.g., `automator_admin_tools_settings_tab`).
Usage
add_action( 'automator_admin_tools_{dynamic}_tab', 'your_function_name', 10, 1 );
Examples
/**
* Adds custom content to the "Logs" tab in the Automator admin tools.
*
* This function demonstrates how to hook into the 'automator_admin_tools_logs_tab'
* action to inject custom HTML and logic within a specific tab of the
* Automator admin interface.
*/
function my_automator_logs_tab_content() {
// Fetch recent log entries (example: last 5 entries)
$log_entries = get_posts( array(
'post_type' => 'uo-log', // Assuming 'uo-log' is the post type for logs
'posts_per_page' => 5,
'order' => 'DESC',
'orderby' => 'date',
) );
if ( ! empty( $log_entries ) ) {
echo '<div class="my-custom-logs-section">';
echo '<h3>Recent Automator Logs</h3>';
echo '<ul>';
foreach ( $log_entries as $log_entry ) {
$trigger_title = get_post_meta( $log_entry->ID, 'trigger_title', true ) ?: 'Unknown Trigger';
$timestamp = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $log_entry->post_date ) );
echo '<li>';
echo '<strong>' . esc_html( $trigger_title ) . '</strong> - ' . esc_html( $timestamp );
// Optionally, you could add a link to view the full log entry details
// echo ' <a href="' . admin_url( 'post.php?post=' . $log_entry->ID . '&action=edit' ) . '">View Details</a>';
echo '</li>';
}
echo '</ul>';
echo '<p><a href="' . admin_url( 'edit.php?post_type=uo-log' ) . '">View All Logs</a></p>';
echo '</div>';
} else {
echo '<p>No recent log entries found.</p>';
}
}
add_action( 'automator_admin_tools_logs_tab', 'my_automator_logs_tab_content', 10, 0 ); // 0 indicates no arguments are passed to the callback function
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-tools/admin-tools.php:64
foreach ( $tabs as $tab_key => $setting_tab ) {
if ( $setting_tab->is_selected || $setting_tab->preload ) {
?>
<uo-tab-panel id="<?php echo esc_attr( $tab_key ); ?>" <?php echo $setting_tab->is_selected ? 'active' : ''; ?>>
<?php do_action( 'automator_admin_tools_' . $tab_key . '_tab' ); ?>
</uo-tab-panel>
<?php
}
}