← All changes
|
vendor/elementor/wp-one-package/src/Connect/Components/Handler.php
+9
-6
1.7.5
→
trunk
View file →
| @@ -87,13 +87,11 @@ | ||
| 87 | 87 | |
| 88 | 88 | $code = sanitize_text_field( wp_unslash( $_GET['code'] ?? '' ) ); |
| 89 | 89 | $state = sanitize_text_field( wp_unslash( $_GET['state'] ?? '' ) ); |
| 90 | 90 | |
| 91 | - // Check if the state is valid | |
| 92 | 91 | $this->validate_nonce( $state ); |
| 93 | 92 | |
| 94 | 93 | try { |
| 95 | - // Exchange the code for an access token and store it | |
| 96 | 94 | [ 'access_token' => $access_token ] = $this->facade->service()->get_token( GrantTypes::AUTHORIZATION_CODE, $code ); |
| 97 | 95 | $this->facade->data()->set_share_usage_data( $this->is_share_usage_scope_granted( $access_token ) ? 'yes' : 'no' ); |
| 98 | 96 | $this->facade->data()->set_owner_user_id( get_current_user_id() ); |
| 99 | 97 | $this->facade->data()->set_home_url(); |
| @@ -98,18 +96,23 @@ | ||
| 98 | 96 | $this->facade->data()->set_owner_user_id( get_current_user_id() ); |
| 99 | 97 | $this->facade->data()->set_home_url(); |
| 100 | 98 | } catch ( \Throwable $th ) { |
| 101 | 99 | $this->facade->logger()->error( 'Unable to handle auth code: ' . $th->getMessage() ); |
| 100 | + | |
| 101 | + do_action( 'elementor_one/connect_fail', $this->facade ); | |
| 102 | + do_action( | |
| 103 | + 'elementor_one/' . $this->facade->get_config( 'app_prefix' ) . '_connect_fail', | |
| 104 | + $this->facade | |
| 105 | + ); | |
| 106 | + | |
| 107 | + wp_safe_redirect( $this->facade->utils()->get_admin_url() ); | |
| 108 | + exit; | |
| 102 | 109 | } |
| 103 | 110 | |
| 104 | - // Trigger the connected event for all apps | |
| 105 | 111 | do_action( 'elementor_one/connected', $this->facade ); |
| 106 | - | |
| 107 | - // Trigger the connected event for the app prefix | |
| 108 | 112 | do_action( 'elementor_one/' . $this->facade->get_config( 'app_prefix' ) . '_connected', $this->facade ); |
| 109 | 113 | |
| 110 | 114 | wp_safe_redirect( $this->facade->utils()->get_admin_url() ); |
| 111 | - | |
| 112 | 115 | exit; |
| 113 | 116 | } |
| 114 | 117 | |
| 115 | 118 | /** |