Filter tin-canny-learndash-reporting

ultc_admin_sidebar_try_automator_add

Filters whether to add the "Try Automator" section to the admin sidebar, allowing for programmatic control.

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

Description

This filter controls whether Uncanny Automator is suggested in the WordPress admin sidebar. Return `false` to hide the suggestion. Use this to prevent the prompt if Automator is already installed or if it's not relevant to your users.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Example of using the 'ultc_admin_sidebar_try_automator_add' filter hook.
 *
 * This filter determines whether to display the "Try Uncanny Automator"
 * menu item in the WordPress admin sidebar. By default, it's set to true.
 * This example shows how to conditionally disable it based on another
 * plugin being active.
 */
add_filter(
	'ultc_admin_sidebar_try_automator_add',
	function ( $should_add ) {
		// Check if the 'uncanny-automator' plugin is active.
		// If it is, we don't need to prompt the user to install it.
		if ( is_plugin_active( 'uncanny-automator/uncanny-automator.php' ) ) {
			return false; // Don't add the menu item.
		}

		// If Uncanny Automator is not active, return the original value (which is true by default).
		return $should_add;
	},
	10, // Priority
	1   // Accepted args
);

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

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