Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion includes/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ private function init() {
$this->setup_beaver();
$this->setup_elementor();
}
$this->setup_sites_listing();
add_filter( 'themeisle_sdk_hide_dashboard_widget', '__return_true' );
add_filter(
'templates_patterns_collection_feedback_review_message',
Expand All @@ -112,6 +111,7 @@ function ( $message ) {
if ( ! $this->should_load() ) {
return;
}
$this->setup_sites_listing();
Comment thread
girishpanchal30 marked this conversation as resolved.
$this->setup_admin();
$this->setup_api();
$this->setup_active_state();
Expand Down
23 changes: 13 additions & 10 deletions includes/Sites_Listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ public function add_sites_library_support() {
* @return array
*/
private function get_sites() {
$response = $this->get_cached_sites();
$response = $this->get_cached_sites();
$is_cached = ( $response !== false );

if ( $response === false ) {
if ( ! $is_cached ) {
$response = wp_remote_get( esc_url( self::get_api_path() ) );

if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
Expand Down Expand Up @@ -168,14 +169,16 @@ private function get_sites() {
}
}

set_transient(
$this->transient_key,
array(
'fetched_at' => time(),
'data' => $response,
),
$this->cache_ttl
);
if ( ! $is_cached ) {
Comment thread
girishpanchal30 marked this conversation as resolved.
set_transient(
$this->transient_key,
array(
'fetched_at' => time(),
'data' => $response,
),
$this->cache_ttl
);
}

return $response;
}
Expand Down
Loading