Filter
uncanny-automator-pro
uncanny_one_click_install_plugin_initial_text
Filters the initial text displayed for the one-click plugin installation button.
add_filter( 'uncanny_one_click_install_plugin_initial_text', $callback, 10, 1 );
Description
Filters the initial text displayed on the "One-Click Install" button for plugins. Developers can modify this text to customize the button's appearance before it's displayed. It's applied during the plugin installation process, allowing for dynamic button labels based on plugin information.
Usage
add_filter( 'uncanny_one_click_install_plugin_initial_text', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the uncanny_one_click_install_plugin_initial_text filter.
*
* This filter allows you to modify the default button text for plugin installation.
* In this example, we'll append a specific string to the button text if the plugin
* being installed is "Uncanny Automator".
*/
add_filter( 'uncanny_one_click_install_plugin_initial_text', function( $button_text, $plugin_info ) {
// Check if the plugin slug is 'uncanny-automator' and if the original button text
// indicates installation.
if ( isset( $plugin_info->slug ) && 'uncanny-automator' === $plugin_info->slug && false === strpos( $button_text, 'Install' ) ) {
// If it's Uncanny Automator and the button text doesn't already suggest installation,
// we'll append some custom text. This is just an example; the logic here would
// depend on your specific needs.
$button_text = $button_text . ' - Get Started!';
}
// You can also completely override the button text based on plugin info.
// For example, if you want a specific message for a particular plugin:
// if ( isset( $plugin_info->slug ) && 'another-plugin' === $plugin_info->slug ) {
// $button_text = 'Click to Add Another Plugin';
// }
// Always return the modified button text.
return $button_text;
}, 10, 2 ); // 10 is the priority, 2 is the number of arguments accepted by the callback function.
?>
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:570
if ( 'uncanny-automator' === (string) $plugin_slug ) {
$button_text = esc_html__( 'Install Uncanny Automator', 'uncanny-automator-pro' );
} else {
/* translators: Button text */
$button_text = sprintf( esc_html__( 'Install %s', 'uncanny-automator-pro' ), $plugin_info->name );
}
$button_text = apply_filters( 'uncanny_one_click_install_plugin_initial_text', $button_text, $plugin_info );
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 );