Filter uncanny-learndash-groups

ulgm_admin_sidebar_try_automator_inner_html

Filters the inner HTML of the "Try Automator" section in the admin sidebar, allowing for customization of its content.

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

Description

Filters the HTML for the "Try Automator" sidebar menu item. Developers can modify the menu item's text or entirely replace its HTML content to customize the display, potentially offering alternative integrations or conditional visibility. This hook fires during admin sidebar generation.


Usage

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

Parameters

$menu_item_text (mixed)
This parameter contains the text for the menu item that prompts users to try Uncanny Automator.

Return Value

The filtered value.


Examples

/**
 * Example of modifying the inner HTML for the "Try Automator" sidebar menu item.
 * This allows developers to inject custom HTML or modify the existing structure.
 *
 * @param string $inner_html The default inner HTML for the menu item.
 * @return string The modified inner HTML.
 */
add_filter( 'ulgm_admin_sidebar_try_automator_inner_html', function( $inner_html ) {
	// In this example, we'll append a small badge to indicate it's a featured item.
	// We'll assume $inner_html already contains something like:
	// '<span class="ulgm-sidebar-featured-item__text">Automation</span>'

	// Add a custom class and some text for a badge.
	$custom_badge = '<span class="ulgm-sidebar-featured-item__badge">New!</span>';

	// We want to append our badge *inside* the main featured item span,
	// but potentially after the text span if it exists.
	// A more robust approach might involve DOM manipulation if the structure was complex,
	// but for this simple case, string concatenation is sufficient.

	// Let's assume the default $inner_html looks like this:
	// '<span class="ulgm-sidebar-featured-item__text">Automation</span>'
	// We want to transform it into:
	// '<span class="ulgm-sidebar-featured-item__text">Automation</span><span class="ulgm-sidebar-featured-item__badge">New!</span>'

	// If the default $inner_html is just text, wrap it first.
	if ( ! str_contains( $inner_html, '<span class="ulgm-sidebar-featured-item__text">' ) ) {
		$inner_html = '<span class="ulgm-sidebar-featured-item__text">' . esc_html( $inner_html ) . '</span>';
	}

	// Append the custom badge HTML.
	$modified_html = $inner_html . $custom_badge;

	return $modified_html;
}, 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/classes/admin/install-automator/install-automator.php:126

public function menu_uncanny_automator() {

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

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

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

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

		add_submenu_page(
			'uncanny-groups-create-group',
			$menu_item_text,
			$menu_item_html,
			'manage_options',
			'groups-install-automator',
			array(
				$this,
				'admin_page_uncanny_automator',
			),
			6
		);

	}


Scroll to Top