Filter uncanny-automator

automator_report_titles

Filters the admin title for reports, allowing modification before display.

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

Description

Fires in the Uncanny Automator core admin to modify report titles displayed in the admin area. Developers can use this filter to customize or prepend/append text to these titles, allowing for more specific or branded reporting views. It receives the current admin title and a general title as parameters.


Usage

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

Parameters

$admin_title (mixed)
This parameter contains the current administrative title being generated for the page.
$title (mixed)
This parameter holds the administrative title for the current page, which can be modified by the filter.

Return Value

The filtered value.


Examples

// Filter to modify the admin page title for the Uncanny Automator Reports.
// We'll add a prefix based on the report type to make it more specific.
add_filter( 'automator_report_titles', 'my_custom_automator_report_title', 10, 2 );

function my_custom_automator_report_title( $admin_title, $title ) {
    // $admin_title typically contains the main title string for the page.
    // $title is usually the main WordPress admin title context, often the site title.

    // Let's assume we want to prepend "My Custom Reports:" to all report titles.
    // This is a simple example, but you could conditionally add prefixes
    // based on the value of $admin_title if needed.

    $prefix = esc_html__( 'My Custom Reports:', 'my-text-domain' );
    return $prefix . ' ' . $admin_title;
}

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/class-admin-menu.php:1023

public function modify_report_titles( $admin_title, $title ) {

		if ( automator_filter_has_var( 'tab' ) ) {
			switch ( sanitize_text_field( automator_filter_input( 'tab' ) ) ) {
				case 'recipe-log':
					$admin_title = sprintf( '%s — %s', esc_attr__( 'Recipe log', 'uncanny-automator' ), $admin_title );
					break;
				case 'trigger-log':
					$admin_title = sprintf( '%s — %s', esc_attr__( 'Trigger log', 'uncanny-automator' ), $admin_title );
					break;
				case 'action-log':
					$admin_title = sprintf( '%s — %s', esc_attr__( 'Action log', 'uncanny-automator' ), $admin_title );
					break;
			}
		}

		return apply_filters( 'automator_report_titles', $admin_title, $title );
	}

Scroll to Top