From e6930e961de1f578f69f27c2054e36b77bc5713d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Sat, 4 Jan 2025 00:05:02 +0100 Subject: [PATCH] Using exit() instead of die() --- src/php/skautis-integration.php | 2 +- .../auth/class-connect-and-disconnect-wp-account.php | 8 ++++---- src/php/src/auth/class-skautis-gateway.php | 2 +- src/php/src/auth/class-skautis-login.php | 10 +++++----- src/php/src/auth/class-wp-login-logout.php | 6 +++--- src/php/src/general/class-actions.php | 2 +- src/php/src/modules/Register/class-register.php | 6 +++--- src/php/src/modules/Register/class-wp-register.php | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/php/skautis-integration.php b/src/php/skautis-integration.php index 47707d6c..afc8624d 100644 --- a/src/php/skautis-integration.php +++ b/src/php/skautis-integration.php @@ -22,7 +22,7 @@ namespace Skautis_Integration; if ( ! defined( 'ABSPATH' ) ) { - die(); + exit(); } define( 'SKAUTIS_INTEGRATION_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); diff --git a/src/php/src/auth/class-connect-and-disconnect-wp-account.php b/src/php/src/auth/class-connect-and-disconnect-wp-account.php index 45b06752..937b3032 100644 --- a/src/php/src/auth/class-connect-and-disconnect-wp-account.php +++ b/src/php/src/auth/class-connect-and-disconnect-wp-account.php @@ -61,7 +61,7 @@ private function set_skautis_user_id_to_wp_account( int $wp_user_id, int $skauti update_user_meta( $wp_user_id, 'skautisUserId_' . $this->skautis_gateway->get_env(), absint( $skautis_user_id ) ); wp_safe_redirect( $return_url, 302 ); - die(); + exit(); } } @@ -118,7 +118,7 @@ public function connect() { if ( ! $this->skautis_login->set_login_data_to_local_skautis_instance( $_POST ) ) { $return_url = Helpers::get_return_url() ?? Helpers::get_current_url(); wp_safe_redirect( esc_url_raw( $this->skautis_gateway->get_skautis_instance()->getLoginUrl( $return_url ) ), 302 ); - die(); + exit(); } } @@ -216,10 +216,10 @@ public function disconnect() { $return_url = Helpers::get_return_url(); if ( ! is_null( $return_url ) ) { wp_safe_redirect( $return_url, 302 ); - die(); + exit(); } else { wp_safe_redirect( get_home_url(), 302 ); - die(); + exit(); } } } diff --git a/src/php/src/auth/class-skautis-gateway.php b/src/php/src/auth/class-skautis-gateway.php index cb7f8484..ffe0ba3a 100644 --- a/src/php/src/auth/class-skautis-gateway.php +++ b/src/php/src/auth/class-skautis-gateway.php @@ -100,7 +100,7 @@ public function get_env(): string { public function get_skautis_instance(): Skautis\Skautis { if ( ! ( $this->skautis instanceof Skautis\Skautis ) ) { wp_die( esc_html__( 'The SkautIS integration plugin cannot be used without setting a valid App ID.', 'skautis-integration' ) ); - die(); + exit(); } return $this->skautis; } diff --git a/src/php/src/auth/class-skautis-login.php b/src/php/src/auth/class-skautis-login.php index c45d48eb..8394fdea 100644 --- a/src/php/src/auth/class-skautis-login.php +++ b/src/php/src/auth/class-skautis-login.php @@ -98,13 +98,13 @@ public function login() { if ( ! $this->is_user_logged_in_skautis() ) { wp_safe_redirect( esc_url_raw( $this->skautis_gateway->get_skautis_instance()->getLoginUrl( $return_url ) ), 302 ); - die(); + exit(); } if ( strpos( $return_url, 'noWpLogin' ) !== false ) { $this->wp_login_logout->try_to_login_to_wp(); wp_safe_redirect( esc_url_raw( $return_url ), 302 ); - die(); + exit(); } else { $this->wp_login_logout->login_to_wp(); } @@ -121,7 +121,7 @@ public function login_confirm() { $return_url = Helpers::get_return_url(); if ( null === $return_url ) { wp_die( esc_html__( "Couldn't find return URL.", 'skautis-integration' ) ); - die(); + exit(); } // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( $this->set_login_data_to_local_skautis_instance( $_POST ) ) { @@ -130,14 +130,14 @@ public function login_confirm() { } $this->wp_login_logout->try_to_login_to_wp(); wp_safe_redirect( $return_url, 302 ); - die(); + exit(); } elseif ( $this->is_user_logged_in_skautis() ) { if ( strpos( $return_url, 'noWpLogin' ) === false ) { $this->wp_login_logout->login_to_wp(); } $this->wp_login_logout->try_to_login_to_wp(); wp_safe_redirect( $return_url, 302 ); - die(); + exit(); } } diff --git a/src/php/src/auth/class-wp-login-logout.php b/src/php/src/auth/class-wp-login-logout.php index b8b9bd91..9957e2b8 100644 --- a/src/php/src/auth/class-wp-login-logout.php +++ b/src/php/src/auth/class-wp-login-logout.php @@ -83,7 +83,7 @@ private function login_wp_user_by_skautis_user_id( int $skautis_user_id, $dont_d if ( is_user_logged_in() && get_current_user_id() === $wp_user->ID ) { wp_safe_redirect( $return_url, 302 ); - die(); + exit(); } wp_destroy_current_session(); @@ -95,7 +95,7 @@ private function login_wp_user_by_skautis_user_id( int $skautis_user_id, $dont_d do_action( 'wp_login', $wp_user->user_login, $wp_user ); wp_safe_redirect( $return_url, 302 ); - die(); + exit(); } } @@ -206,6 +206,6 @@ public function logout() { $return_url = Helpers::get_login_logout_redirect(); wp_safe_redirect( esc_url_raw( $return_url ), 302 ); - die(); + exit(); } } diff --git a/src/php/src/general/class-actions.php b/src/php/src/general/class-actions.php index 1a163cc6..7f0bad68 100644 --- a/src/php/src/general/class-actions.php +++ b/src/php/src/general/class-actions.php @@ -186,7 +186,7 @@ public function auth_actions_router( \WP_Query $wp_query ) { wp_die( sprintf( esc_html__( 'Pro správné fungování pluginu skautIS integrace, je potřeba %1$snastavit APP ID%2$s', 'skautis-integration' ), '', '' ), esc_html__( 'Chyba v konfiguraci pluginu', 'skautis-integration' ) ); } else { wp_safe_redirect( get_home_url(), 302 ); - die(); + exit(); } } } diff --git a/src/php/src/modules/Register/class-register.php b/src/php/src/modules/Register/class-register.php index 32ef4058..67fa82cb 100644 --- a/src/php/src/modules/Register/class-register.php +++ b/src/php/src/modules/Register/class-register.php @@ -129,7 +129,7 @@ private function loginUserAfterRegistration() { $return_url = Helpers::get_login_logout_redirect(); $return_url = remove_query_arg( SKAUTIS_INTEGRATION_NAME . '_registerToWpBySkautis', urldecode( $return_url ) ); wp_safe_redirect( esc_url_raw( $this->wp_login_logout->get_login_url( $return_url ) ), 302 ); - die(); + exit(); } /** @@ -222,7 +222,7 @@ public function register() { if ( ! $this->skautis_login->is_user_logged_in_skautis() ) { $return_url = Helpers::get_return_url() ?? Helpers::get_current_url(); wp_safe_redirect( esc_url_raw( $this->skautis_gateway->get_skautis_instance()->getLoginUrl( $return_url ) ), 302 ); - die(); + exit(); } $this->registerUser(); @@ -293,7 +293,7 @@ public function registerUserManually() { if ( $this->wp_register->register_to_wp_manually( $wp_role, $skautis_user_id ) ) { wp_safe_redirect( $return_url, 302 ); - die(); + exit(); } else { wp_die( esc_html__( 'Uživatele se nepodařilo zaregistrovat', 'skautis-integration' ), esc_html__( 'Chyba při registraci uživatele', 'skautis-integration' ) ); } diff --git a/src/php/src/modules/Register/class-wp-register.php b/src/php/src/modules/Register/class-wp-register.php index 74c6bed4..27acc9cf 100644 --- a/src/php/src/modules/Register/class-wp-register.php +++ b/src/php/src/modules/Register/class-wp-register.php @@ -87,7 +87,7 @@ static function ( $user_id ) { } /* translators: The error message */ wp_die( sprintf( esc_html__( 'Při registraci nastala neočekávaná chyba: %s', 'skautis-integration' ), esc_html( $user_id->get_error_message() ) ), esc_html__( 'Chyba při registraci', 'skautis-integration' ) ); - die(); + exit(); } return $user_id;