“Back to Top” button with progressive fill based on scroll.
Automatically uses Elementor’s main color.
Simply copy paste the code inside a php file and place it inside your mu-plugins folder.
kits_manager->get_active_kit_for_frontend();
if ( ! $kit ) {
return $default;
}
$settings = $kit->get_settings();
// Les couleurs globales sont dans system_colors.
if ( ! empty( $settings['system_colors'] ) && is_array( $settings['system_colors'] ) ) {
foreach ( $settings['system_colors'] as $color ) {
if ( isset( $color['_id'] ) && $color['_id'] === 'primary' && ! empty( $color['color'] ) ) {
return $color['color'];
}
}
}
// Fallback : custom_colors si la couleur primaire a été définie là.
if ( ! empty( $settings['custom_colors'] ) && is_array( $settings['custom_colors'] ) ) {
foreach ( $settings['custom_colors'] as $color ) {
if ( isset( $color['_id'] ) && $color['_id'] === 'primary' && ! empty( $color['color'] ) ) {
return $color['color'];
}
}
}
return $default;
}
/**
* Rendu HTML du bouton.
*/
public function render_button(): void {
?>
get_primary_color();
?>