Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/class-convertkit-resource-v4.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ public function init() {
// a last query time. This handles upgrades from < 1.9.7.4 where resources
// would never expire.
if ( ! $this->last_queried ) {
$this->refresh();
return;
return $this->refresh();
}

// If the resources have expired, refresh them now.
if ( time() > ( $this->last_queried + $this->cache_duration ) ) {
$this->refresh();
return;
return $this->refresh();
}

}
Expand Down Expand Up @@ -344,13 +342,13 @@ public function exist() {
*
* @since 1.0.0
*
* @return bool|WP_Error|array
* @return WP_Error|array
*/
public function refresh() {

// Bail if no API class was defined.
if ( ! $this->api ) {
return false;
return new WP_Error( 'convertkit_resource_refresh_error', 'Connect the Plugin to your Kit account to refresh resources.' );
}

// Fetch resources.
Expand Down