Filter
uncanny-automator-pro
uncanny_one_click_install_plugin_active_text
Filters the text displayed for an already active plugin during the one-click install process.
add_filter( 'uncanny_one_click_install_plugin_active_text', $callback, 10, 2 );
Description
Filters the text displayed for an active plugin in the one-click installer. Allows developers to customize the "active" message, such as adding specific instructions or altering the plugin name display. Modifies the `$button_text` before it's shown to the user, utilizing `$plugin_info` for context.
Usage
add_filter( 'uncanny_one_click_install_plugin_active_text', 'your_function_name', 10, 2 );
Parameters
-
$button_text(mixed) - This parameter contains the text that will be displayed on the button to indicate that a plugin is active.
-
$plugin_info(mixed) - This parameter holds the text that will be displayed on the button, indicating the plugin is active.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to modify the "active" button text for the One-Click Install feature.
*
* This example will append "(Already Installed!)" to the default active text
* if the plugin is already installed and active.
*
* @param string $button_text The current button text.
* @param object $plugin_info An object containing information about the plugin.
* @return string The modified button text.
*/
add_filter( 'uncanny_one_click_install_plugin_active_text', function( $button_text, $plugin_info ) {
// Check if the plugin object and its properties exist to avoid errors.
if ( is_object( $plugin_info ) && isset( $plugin_info->name ) && isset( $plugin_info->is_active ) && $plugin_info->is_active ) {
// Append a custom string to the existing button text.
$button_text .= ' (Already Installed!)';
}
return $button_text;
}, 10, 2 );
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
uncanny-automator-pro/src/core/admin/installer/class-plugin-installer.php:578
if ( $plugin_info->is_active ) {
$action = '';
$disabled = esc_attr( 'disabled="disabled"' );
/* translators: Button text */
$button_text = sprintf( esc_html__( '%s is active', 'uncanny-automator-pro' ), $plugin_info->name );
$button_text = apply_filters( 'uncanny_one_click_install_plugin_active_text', $button_text, $plugin_info );
} elseif ( $plugin_info->is_installed ) {
$action = esc_attr( 'activate' );
if ( 'uncanny-automator' === (string) $plugin_slug ) {
/* translators: Button text */