From 2368771617eba3c9f9939d70a96075ae13a1ee83 Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Thu, 5 Jun 2025 16:06:21 +0300 Subject: [PATCH] Add filters for primary button classes in UM forms Introduced new filters to customize CSS classes for primary buttons in login, registration, and password reset forms. This allows developers to extend button styling by applying custom classes via WordPress hooks. Changes enhance flexibility and improve theme compatibility. --- includes/core/um-actions-login.php | 21 ++++++++++++++++++++- includes/core/um-actions-register.php | 20 ++++++++++++++++++++ templates/password-reset.php | 20 ++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/includes/core/um-actions-login.php b/includes/core/um-actions-login.php index 20e85f50..dd1ea922 100644 --- a/includes/core/um-actions-login.php +++ b/includes/core/um-actions-login.php @@ -362,7 +362,26 @@ function um_add_submit_button_to_login( $args ) { if ( ! isset( $primary_btn_word ) || $primary_btn_word == '' ){ $primary_btn_word = UM()->options()->get( 'login_primary_btn_word' ); } - + /** + * Filters the classes applied to the primary button on the login form. + * + * @hook um_login_form_primary_btn_classes + * @since 2.10.5 + * + * @param {array} $classes An array of CSS classes applied to the primary button. + * @param {array} $args An array of arguments or configurations used in the login form. + * + * @return {array} Button CSS classes. + * + * @example Extend the classes applied to the primary button on the login form. + * function my_custom_classes( $classes, $args ) { + * // Add a new class to the button + * $classes[] = 'new-button-class'; + * + * return $classes; + * } + * add_filter( 'um_login_form_primary_btn_classes', 'my_custom_classes', 10, 2 ); + */ $primary_btn_classes = apply_filters( 'um_login_form_primary_btn_classes', array( 'um-button' ), $args ); /** diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index f9d44f0f..ca5e7540 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -597,6 +597,26 @@ function um_add_submit_button_to_register( $args ) { $primary_btn_word = UM()->options()->get( 'register_primary_btn_word' ); } + /** + * Filters the classes applied to the primary button on the registration form. + * + * @hook um_register_form_primary_btn_classes + * @since 2.10.5 + * + * @param {array} $classes An array of CSS classes applied to the primary button. + * @param {array} $args An array of arguments or configurations used in the registration form. + * + * @return {array} Button CSS classes. + * + * @example Extend the classes applied to the primary button on the registration form. + * function my_custom_classes( $classes, $args ) { + * // Add a new class to the button + * $classes[] = 'new-button-class'; + * + * return $classes; + * } + * add_filter( 'um_register_form_primary_btn_classes', 'my_custom_classes', 10, 2 ); + */ $primary_btn_classes = apply_filters( 'um_register_form_primary_btn_classes', array( 'um-button' ), $args ); $secondary_btn_word = $args['secondary_btn_word']; diff --git a/templates/password-reset.php b/templates/password-reset.php index 51adbeee..0984a2f7 100644 --- a/templates/password-reset.php +++ b/templates/password-reset.php @@ -120,6 +120,26 @@ if ( ! defined( 'ABSPATH' ) ) { */ do_action( 'um_after_password_reset_fields', $args ); + /** + * Filters the classes applied to the primary button on the password reset form. + * + * @hook um_password_reset_form_primary_btn_classes + * @since 2.10.5 + * + * @param {array} $classes An array of CSS classes applied to the primary button. + * @param {array} $args An array of arguments or configurations used in the password reset form. + * + * @return {array} Button CSS classes. + * + * @example Extend the classes applied to the primary button on the password reset form. + * function my_custom_classes( $classes, $args ) { + * // Add a new class to the button + * $classes[] = 'new-button-class'; + * + * return $classes; + * } + * add_filter( 'um_password_reset_form_primary_btn_classes', 'my_custom_classes', 10, 2 ); + */ $primary_btn_classes = apply_filters( 'um_password_reset_form_primary_btn_classes', array( 'um-button' ), $args ); ?>