uncanny_one_click_install_button_class
Filters the CSS classes applied to the one-click install button, allowing customization before it renders.
add_filter( 'uncanny_one_click_install_button_class', $callback, 10, 1 );
Description
Filters the CSS classes applied to the one-click install button. Developers can use this hook to dynamically add or remove classes, allowing for custom styling and behavior based on plugin information or other conditions. The default classes provide basic styling.
Usage
add_filter( 'uncanny_one_click_install_button_class', 'your_function_name', 10, 1 );
Parameters
-
$plugin_info(mixed) - This parameter contains the default CSS classes to be applied to the one-click install button.
Return Value
The filtered value.
Examples
/**
* Adds a custom class to the one-click install button for a specific plugin.
*
* @param array $button_classes An array of existing button classes.
* @param array $plugin_info Information about the plugin being installed.
* @return array The modified array of button classes.
*/
function my_custom_one_click_install_button_classes( $button_classes, $plugin_info ) {
// Check if the plugin slug matches a specific plugin we want to style differently.
if ( isset( $plugin_info['slug'] ) && 'my-special-plugin' === $plugin_info['slug'] ) {
// Add a custom class for our special plugin.
$button_classes[] = 'my-special-plugin-install-button';
}
// Optionally, remove a default class if it's not needed for a specific scenario.
// For example, if we always want to apply a different base style for our special plugin.
if ( in_array( 'auto-plugin-install-button', $button_classes ) && isset( $plugin_info['slug'] ) && 'my-special-plugin' === $plugin_info['slug'] ) {
// Remove the default class if it exists and we've added our custom one.
$key = array_search( 'auto-plugin-install-button', $button_classes );
if ( $key !== false ) {
unset( $button_classes[ $key ] );
}
}
return $button_classes;
}
add_filter( 'uncanny_one_click_install_button_class', 'my_custom_one_click_install_button_classes', 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
src/install-automator/vendor/uncanny-one-click-installer/class-auto-plugin-install.php:615
transform: rotate(360deg);
}
}
</style>
<div class="auto-plugin-install">
<?php
$button_class = apply_filters(
'uncanny_one_click_install_button_class',
array(
'uoc-generate-button',
'auto-plugin-install-button',
),
$plugin_info
);