Filter uncanny-continuing-education-credits

uoceu_admin_sidebar_try_automator_inner_html

Filters the inner HTML content of the "Try Automator" section in the admin sidebar.

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

Description

Filters the HTML content displayed for the "Try Automator" link in the admin sidebar. Developers can modify this HTML to customize its appearance, add extra elements, or even replace it entirely. This hook runs within the `menu_uncanny_automator` method, allowing dynamic changes before the menu item is rendered.


Usage

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

Parameters

$menu_item_text (mixed)
This parameter contains the HTML content that will be displayed in the admin sidebar to encourage users to try Uncanny Automator.

Return Value

The filtered value.


Examples

/**
 * Example filter to modify the HTML for the "Try Uncanny Automator" sidebar item.
 * This example adds an icon before the text.
 */
add_filter(
	'uoceu_admin_sidebar_try_automator_inner_html',
	function ( $inner_html ) {
		// Assume the original $inner_html contains a span with text like '<span class="ulgm-sidebar-featured-item__text">Automation</span>'

		// Let's prepend an icon HTML to the existing inner HTML.
		// In a real scenario, you might fetch an icon URL or use an SVG.
		$icon_html = '<span class="dashicons dashicons-admin-generic ulgm-sidebar-featured-item__icon"></span> ';

		// Combine the icon with the original inner HTML.
		// We are wrapping the original $inner_html to ensure its structure is maintained.
		// The filter expects the *inner* HTML, so we're modifying what's inside the main span.
		// If $inner_html is just the text span, we might wrap it.
		// For realism, let's assume $inner_html is already a span.
		if ( strpos( $inner_html, '<span class="ulgm-sidebar-featured-item__text">' ) !== false ) {
			// If the original structure is detected, prepend the icon inside the main featured item span, before the text span.
			// This assumes the filter hook is inside a parent span, and $inner_html is the content of that parent.
			// A more robust approach might involve DOM manipulation if the structure was more complex.
			// For this example, we'll assume the structure is simple and we're adding before the text span.
			$modified_inner_html = str_replace(
				'<span class="ulgm-sidebar-featured-item__text">',
				$icon_html . '<span class="ulgm-sidebar-featured-item__text">',
				$inner_html
			);
		} else {
			// Fallback if the expected structure isn't found, wrap the original content with the icon.
			$modified_inner_html = $icon_html . $inner_html;
		}


		return $modified_inner_html;
	},
	10, // Priority
	1   // Number of accepted arguments
);

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:125

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