Filter uncanny-learndash-toolkit

ult_admin_sidebar_try_automator_inner_html

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

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

Description

This filter hook allows developers to modify the HTML content displayed within the "Try Automator" section of the Uncanny Toolkit admin sidebar. Use it to customize or replace the default text, links, or even add entirely new elements to this promotional area before it's rendered.


Usage

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

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to hook into the 'ult_admin_sidebar_try_automator_inner_html' filter.
 * This example adds an icon before the text in the sidebar menu item.
 *
 * @param string $menu_item_html The default HTML for the menu item's inner content.
 * @return string The modified HTML for the menu item's inner content.
 */
add_filter( 'ult_admin_sidebar_try_automator_inner_html', function( $menu_item_html ) {
	// Define an icon to prepend to the menu item text.
	$icon_html = '<span class="dashicons dashicons-admin-generic" style="margin-right: 5px;"></span>';

	// Ensure the original $menu_item_html is wrapped in a span with the specified class.
	// The original example creates this span, so we'll assume it's there or create it if not.
	// For robustness, we'll check if the text is already within a span.
	if ( strpos( $menu_item_html, '<span class="ult-sidebar-featured-item__text">' ) === false ) {
		$menu_item_html = '<span class="ult-sidebar-featured-item__text">' . $menu_item_html . '</span>';
	}

	// Prepend the icon to the existing HTML content.
	return $icon_html . $menu_item_html;
}, 10, 1 );

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.php:44

public function add_try_automator_page() {
		// Check if Automator is already installed
		if ( defined( 'AUTOMATOR_BASE_FILE' ) ) {
			return;
		}
		// Check if we have to render the item
		if ( ! apply_filters( 'ult_admin_sidebar_try_automator_add', true ) ) {
			return;
		}

		// Get the item text
		$menu_item_text = apply_filters( 'ult_admin_sidebar_try_automator_text', __( 'Automation', 'uncanny-learndash-toolkit' ) );

		// Create the link content
		$menu_item_html = '<span class="ult-sidebar-featured-item">' . apply_filters( 'ult_admin_sidebar_try_automator_inner_html', '<span class="ult-sidebar-featured-item__text">' . $menu_item_text . '</span>' ) . '</span>';

		// Add the subpage menu
		add_submenu_page(
			'uncanny-toolkit',
			$menu_item_text,
			$menu_item_html,
			'manage_options',
			'install-automator',
			array( $this, 'install_automator_page' ),
			1
		);

	}


Scroll to Top