get_settings(); $comment_count = isset($settings['numcomments']) ? $settings['numcomments'] : 5; $enable_comments = isset($settings['enablecomments']) ? (bool)$settings['enablecomments'] : false; if (!empty($video_id) && true === $enable_comments) { $get_cache = get_transient('sby_comment_cache'); $cache = json_decode($get_cache); if (!isset($cache->$video_id->etag) ) { $params = array( 'num' => (int) $comment_count, 'video_id' => $video_id ); $connection = new SBY_API_Connect_Pro(sby_get_first_connected_account(), 'comments', $params); $connection->connect(); $comment_data = array( $video_id => $connection->get_data() ); $current_set_cache = $comment_data; if ($cache) { $cache->$video_id = $comment_data[$video_id]; $current_set_cache = $cache; } set_transient('sby_comment_cache', json_encode($current_set_cache)); } $updated_cache = get_transient('sby_comment_cache'); if (!empty($updated_cache)) { $cache = json_decode(get_transient('sby_comment_cache')); echo wp_json_encode($cache->$video_id); } die(); } } }