ulgm_admin_sidebar_try_automator_add
Filters whether to add the "Try Automator" link to the admin sidebar when the plugin is active.
add_filter( 'ulgm_admin_sidebar_try_automator_add', $callback, 10, 1 );
Description
Use this filter to conditionally display or hide the "Try Uncanny Automator" prompt in the admin sidebar. By default, it's set to `true`, allowing the prompt to show. Return `false` to prevent its display. This hook is useful for users who may already have Uncanny Automator active or for custom branding.
Usage
add_filter( 'ulgm_admin_sidebar_try_automator_add', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Prevent the "Try Uncanny Automator" sidebar item from displaying if Automator is already active.
*
* The hook `ulgm_admin_sidebar_try_automator_add` is a filter that determines whether
* the "Try Uncanny Automator" sidebar item should be added to the Uncanny Groups admin menu.
* If Uncanny Automator is already installed and active (checked by `defined('AUTOMATOR_BASE_FILE')`),
* this filter will return `false` to prevent the item from being displayed.
*
* @param bool $should_add Whether to add the sidebar item. Defaults to true.
* @return bool False if Automator is active, true otherwise.
*/
add_filter( 'ulgm_admin_sidebar_try_automator_add', function( $should_add ) {
// If Automator is already defined, it means the plugin is active.
if ( defined( 'AUTOMATOR_BASE_FILE' ) ) {
// Return false to prevent the sidebar item from being added.
return false;
}
// Otherwise, allow the sidebar item to be added.
return $should_add;
}, 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/classes/admin/install-automator/install-automator.php:119
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
);
}