Filter Since 4.4 uncanny-continuing-education-credits

uoceu_admin_sidebar_try_automator_text

Add UncannyAutomator page. Filters the text displayed in the Uncanny Automator sidebar menu, defaulting to "Automation."

add_filter( 'uoceu_admin_sidebar_try_automator_text', $callback, 10, 1 );

Description

Filters the text displayed for the "Try Automator" link in the admin sidebar. Developers can use this to customize the label, perhaps for A/B testing or to provide more context about Uncanny Automator. The default text is "Automation".


Usage

add_filter( 'uoceu_admin_sidebar_try_automator_text', 'your_function_name', 10, 1 );

Return Value

void


Examples

/**
 * Example of how to filter the text used for the "Try Automator" link in the Uncanny CEU admin sidebar.
 * This example will append " (Free!)" to the default "Automation" text.
 *
 * @param string $menu_item_text The current text for the menu item.
 * @return string The modified text for the menu item.
 */
add_filter( 'uoceu_admin_sidebar_try_automator_text', 'my_custom_automator_menu_text', 10, 1 );

function my_custom_automator_menu_text( $menu_item_text ) {
	// Check if the default text is indeed "Automation" and append our custom string.
	if ( $menu_item_text === 'Automation' ) {
		return $menu_item_text . ' (Free!)';
	}

	// Otherwise, return the original text.
	return $menu_item_text;
}

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/install-automator/install-automator.php:123

public function menu_uncanny_automator() {

		if ( defined( 'AUTOMATOR_BASE_FILE' ) ) {
			return;
		}

		if ( ! apply_filters( 'uoceu_admin_sidebar_try_automator_add', true ) ) {
			return;
		}

		/* translators: Trademarked term */
		$menu_item_text = apply_filters( 'uoceu_admin_sidebar_try_automator_text', sprintf( __( '%s', 'uncanny-ceu' ), 'Automation' ) );

		$menu_item_html = '<span class="ulgm-sidebar-featured-item">' . apply_filters( 'uoceu_admin_sidebar_try_automator_inner_html', '<span class="ulgm-sidebar-featured-item__text">' . esc_html( $menu_item_text ) . '</span>' ) . '</span>';

		add_submenu_page(
			'uncanny-ceu-report',
			$menu_item_text,
			$menu_item_html,
			'manage_options',
			'ceu-install-automator',
			array(
				$this,
				'admin_page_uncanny_automator',
			),
			5
		);
	}


Scroll to Top