Filter Since 4.4 tin-canny-learndash-reporting

ultc_admin_sidebar_try_automator_text

Add UncannyAutomator page. Filters the text displayed for the "Automation" menu item in the Uncanny Automator admin sidebar.

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

Description

Filters the text displayed for the "Try Uncanny Automator" item in the admin sidebar. Developers can customize this text to prompt users to explore Uncanny Automator, for example, to suggest its integration with LearnDash reporting features.


Usage

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

Return Value

void


Examples

<?php
/**
 * Example of how to filter the 'ultc_admin_sidebar_try_automator_text' hook.
 * This example changes the text displayed for the Uncanny Automator suggestion
 * in the Uncanny Toolkit sidebar to be more prominent.
 *
 * @param mixed $menu_item_text The original text for the menu item.
 * @return string The modified text for the menu item.
 */
add_filter( 'ultc_admin_sidebar_try_automator_text', function( $menu_item_text ) {

	// Check if the current user has the capability to manage options.
	// This ensures that we only modify the text for users who can actually see
	// and potentially interact with the Uncanny Automator integration.
	if ( current_user_can( 'manage_options' ) ) {
		// Prepend a star emoji and bold tag for emphasis, and append a call to action.
		return '<span style="color: #0073aa; font-weight: bold;">★</span> ' . esc_html( $menu_item_text ) . ' <span style="color: #0073aa; font-weight: bold;">(Recommended!)</span>';
	}

	// If the user doesn't have manage_options capability, return the original text.
	return $menu_item_text;

}, 10, 1 ); // 10 is the priority, 1 is the number of arguments accepted by 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/includes/install-automator/install-automator.php:116

public function menu_uncanny_automator() {

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

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

		/* translators: Trademarked term */
		$menu_item_text = apply_filters( 'ultc_admin_sidebar_try_automator_text', __( 'Automation', 'uncanny-learndash-reporting' ) );

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

		add_submenu_page(
			'uncanny-learnDash-reporting',
			$menu_item_text,
			$menu_item_html,
			'manage_options',
			'tincanny-install-automator',
			array(
				$this,
				'admin_page_uncanny_automator',
			),
			6
		);

	}


Scroll to Top