← All changes
|
admin/section/class-convertkit-admin-section-oauth.php
+4
-7
3.4.2
→
2.7.4
View file →
| @@ -34,11 +34,8 @@ | ||
| 34 | 34 | |
| 35 | 35 | // Maybe output notices for this settings screen, and the Intercom messenger. |
| 36 | 36 | if ( $this->on_settings_screen( 'general' ) ) { |
| 37 | 37 | add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_notices' ) ); |
| 38 | - | |
| 39 | - // OAuth is a special case, as it'll register as the 'general' screen - so the Intercom | |
| 40 | - // call in ConvertKit_Admin_Section_Base's construct won't work. | |
| 41 | 38 | add_action( 'admin_footer', array( $this, 'output_intercom' ) ); |
| 42 | 39 | } |
| 43 | 40 | |
| 44 | 41 | parent::__construct(); |
| @@ -58,14 +55,14 @@ | ||
| 58 | 55 | return; |
| 59 | 56 | } |
| 60 | 57 | |
| 61 | 58 | // Bail if no authorization code is included in the request. |
| 62 | - if ( ! filter_has_var( INPUT_GET, 'code' ) ) { | |
| 59 | + if ( ! array_key_exists( 'code', $_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 63 | 60 | return; |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | 63 | // Sanitize token. |
| 67 | - $authorization_code = filter_input( INPUT_GET, 'code', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); | |
| 64 | + $authorization_code = sanitize_text_field( $_REQUEST['code'] ); // phpcs:ignore WordPress.Security.NonceVerification | |
| 68 | 65 | |
| 69 | 66 | // Exchange the authorization code and verifier for an access token. |
| 70 | 67 | $api = new ConvertKit_API_V4( CONVERTKIT_OAUTH_CLIENT_ID, CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI ); |
| 71 | 68 | $result = $api->get_access_token( $authorization_code ); |
| @@ -88,9 +85,9 @@ | ||
| 88 | 85 | $this->settings->save( |
| 89 | 86 | array( |
| 90 | 87 | 'access_token' => $result['access_token'], |
| 91 | 88 | 'refresh_token' => $result['refresh_token'], |
| 92 | - 'token_expires' => ( time() + $result['expires_in'] ), | |
| 89 | + 'token_expires' => ( $result['created_at'] + $result['expires_in'] ), | |
| 93 | 90 | ) |
| 94 | 91 | ); |
| 95 | 92 | |
| 96 | 93 | // Redirect to General screen, which will now show the Plugin's settings, because the Plugin |
| @@ -154,9 +151,9 @@ | ||
| 154 | 151 | * @return string Documentation URL. |
| 155 | 152 | */ |
| 156 | 153 | public function documentation_url() { |
| 157 | 154 | |
| 158 | - return 'https://help.kit.com/en/articles/2502591-how-to-set-up-the-kit-plugin-on-your-wordpress-website'; | |
| 155 | + return 'https://help.kit.com/en/articles/2502591-the-convertkit-wordpress-plugin'; | |
| 159 | 156 | |
| 160 | 157 | } |
| 161 | 158 | |
| 162 | 159 | } |