-
Notifications
You must be signed in to change notification settings - Fork 8
Directly Remove Credentials on 401 #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
693dcac
bd03fdf
a419320
50489c6
c057ce5
5bef858
3c25fe1
f574154
d8e1bcf
3d72285
595b9f5
495c92c
9ac4e58
e7614e4
458e49d
739e6fa
b4e1707
2ff82d5
f8bfda8
9b77e11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,8 +50,34 @@ public function __construct( $context = false ) { | |
| ); | ||
| } | ||
|
|
||
| // Call parent initialization function. | ||
| parent::init(); | ||
| // Get last query time and existing resources. | ||
| $this->last_queried = get_option( $this->settings_name . '_last_queried' ); | ||
| $this->resources = get_option( $this->settings_name ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes certain any existing cached resources are available, if the API isn't available. |
||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Fetches resources (forms, landing pages or tags) from the API, storing them in the options table | ||
| * with a last queried timestamp. | ||
| * | ||
| * If the refresh results in a 401, removes the access and refresh tokens from the settings. | ||
| * | ||
| * @since 3.1.2 | ||
| * | ||
| * @return WP_Error|array | ||
| */ | ||
| public function refresh() { | ||
|
|
||
| // Call parent refresh method. | ||
| $result = parent::refresh(); | ||
|
|
||
| // If an error occured, maybe delete credentials from the Plugin's settings | ||
| // if the error is a 401 unauthorized. | ||
| if ( is_wp_error( $result ) ) { | ||
| convertkit_maybe_delete_credentials( $result, CONVERTKIT_OAUTH_CLIENT_ID ); | ||
| } | ||
|
|
||
| return $result; | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -496,7 +522,8 @@ public function get_html( $id, $post_id = 0 ) { | |
| /* translators: ConvertKit Form ID */ | ||
| __( 'Kit Form ID %s does not exist on Kit.', 'convertkit' ), | ||
| $id | ||
| ) | ||
| ), | ||
| 404 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provides context to the error i.e. a Kit Form ID was specified that either does not exist in the cached resources, is an ID for a legacy form, or truly doesn't exist (the user entered the wrong ID in the shortcode). |
||
| ); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drops the init() call, so refresh() can only occur if called directly by the Plugin.