From 0f65c2186ae746a38159fbf046339a7326386244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Chrobak?= Date: Tue, 12 Aug 2025 11:50:56 +0200 Subject: [PATCH] #260 Do not use extract() in template display, use $variables directly instead --- src/Utils/Helper.php | 6 ------ templates/google-login-button.php | 11 ++++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Utils/Helper.php b/src/Utils/Helper.php index 86b2bcd4..59b2981e 100644 --- a/src/Utils/Helper.php +++ b/src/Utils/Helper.php @@ -41,12 +41,6 @@ public static function render_template( $template_path, $variables = [], $should return ''; } - if ( ! empty( $variables ) ) { - // This will needed for provide variables to the template. - // Will skips those variables, those already defined. - extract( $variables, EXTR_SKIP ); // phpcs:ignore - } - if ( true === $should_echo ) { // Load template and output the data. diff --git a/templates/google-login-button.php b/templates/google-login-button.php index c7817fca..07b98e81 100644 --- a/templates/google-login-button.php +++ b/templates/google-login-button.php @@ -4,21 +4,22 @@ * * @package RtCamp\GithubLogin * @since 1.0.0 + * @var array $variables */ use RtCamp\GoogleLogin\Utils\Helper; -if ( isset( $custom_btn_text ) && $custom_btn_text ) { - $button_text = esc_html( $custom_btn_text ); +if (!empty($variables['custom_btn_text'])) { + $button_text = esc_html($variables['custom_btn_text']); } else { - $button_text = ( ! empty( $button_text ) ) ? $button_text : __( 'Login with Google', 'login-with-google' ); + $button_text = $variables['button_text'] ?? __( 'Login with Google', 'login-with-google' ); } -if ( empty( $login_url ) ) { +if (empty($variables['login_url'])) { return; } -$button_url = $login_url; +$button_url = $variables['login_url']; if ( is_user_logged_in() ) { $button_text = __( 'Log out', 'login-with-google' );