Skip to content

Commit

Permalink
Calypsoify: Remove unnecessary redirect
Browse files Browse the repository at this point in the history
Currently, if we've specified `?calypsoify=1` or `?calypsoify=0`, we redirect after we set the user meta.

While this works, a redirect here is really unnecessary, because we can just enable or disable the flag if this argument is set. 

A redirect was needed in the original internal plugin version, because it works with cookies; while here, we just set a user meta.
  • Loading branch information
tyxla committed Sep 28, 2020
1 parent ca30cfd commit 157318a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/calypsoify/class.jetpack-calypsoify.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public static function getInstance() {

public function setup() {
$this->is_calypsoify_enabled = 1 == (int) get_user_meta( get_current_user_id(), 'calypsoify', true );
if ( isset( $_GET['calypsoify'] ) ) {
$this->is_calypsoify_enabled = (int) $_GET['calypsoify'];
}

add_action( 'admin_init', array( $this, 'check_param' ), 4 );

if ( $this->is_calypsoify_enabled ) {
Expand Down Expand Up @@ -450,10 +454,6 @@ public function check_param() {
} else {
update_user_meta( get_current_user_id(), 'calypsoify', 0 );
}

$page = remove_query_arg( 'calypsoify', wp_basename( $_SERVER['REQUEST_URI'] ) );

wp_safe_redirect( admin_url( $page ) );
}
}

Expand Down

0 comments on commit 157318a

Please sign in to comment.