Skip to content

Commit

Permalink
Using exit() instead of die()
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Jan 3, 2025
1 parent 89fc1e7 commit e6930e9
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/php/skautis-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace Skautis_Integration;

if ( ! defined( 'ABSPATH' ) ) {
die();
exit();
}

define( 'SKAUTIS_INTEGRATION_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
Expand Down
8 changes: 4 additions & 4 deletions src/php/src/auth/class-connect-and-disconnect-wp-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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();
}
}
}
2 changes: 1 addition & 1 deletion src/php/src/auth/class-skautis-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/php/src/auth/class-skautis-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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 ) ) {
Expand All @@ -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();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/php/src/auth/class-wp-login-logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion src/php/src/general/class-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ), '<a href="' . esc_url( admin_url( 'admin.php?page=' . SKAUTIS_INTEGRATION_NAME ) ) . '">', '</a>' ), esc_html__( 'Chyba v konfiguraci pluginu', 'skautis-integration' ) );
} else {
wp_safe_redirect( get_home_url(), 302 );
die();
exit();
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/php/src/modules/Register/class-register.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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' ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/php/src/modules/Register/class-wp-register.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e6930e9

Please sign in to comment.