/*********************************************************************************************************** */
function bb_get_grabbook_category_feed($url) {
$cats_json = bb_get_grabbook_api($url);
return $cats_json;
}
function bb_get_grabbook_api($url) {
$bb_set_transient_urls = get_option( 'bb_set_transient_url', [] );
if ( ! is_array( $bb_set_transient_urls ) ) {
$bb_set_transient_urls = [];
}
if (get_transient($url) !== false) {
return get_transient($url);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
$bb_set_transient_urls[$url] = $data;
update_option( 'bb_set_transient_url', $bb_set_transient_urls );
set_transient($url, $data, 1800);
return $data;
}
function bb_mvp_brag_shortcode($parts_page_name, $combine_gallery_page_slug) {
ob_start();
update_option("bb_api_data", []);
update_option("bb_combine_api_data", []);
$api_tokens = get_option('bragbook_api_token', []);
$websiteproperty_ids = get_option('bragbook_websiteproperty_id', []);
$gallery_slugs = get_option('bb_gallery_page_slug', []);
$all_results = [];
$combine_results = [];
foreach ($api_tokens as $index => $api_token) {
$websiteproperty_id = $websiteproperty_ids[$index] ?? '';
$page_slug_bb = $gallery_slugs[$index] ?? '';
if(($page_slug_bb == $parts_page_name[0]) || ($combine_gallery_page_slug == $parts_page_name[0])) {
if (empty($api_token) || empty($websiteproperty_id)) {
continue;
}
$cat_url = "https://www.bragbookv2.com/api/plugin/categories?apiToken={$api_token}&websitepropertyId={$websiteproperty_id}";
$category_list = bb_get_grabbook_category_feed($cat_url);
$cat_set = json_decode($category_list, true) ?? [];
$url = "https://www.bragbookv2.com/api/plugin/cases?apiToken={$api_token}&websitepropertyId={$websiteproperty_id}";
$data = bb_get_grabbook_api($url);
$api_data = json_decode($data, true) ?? [];
$result = [
'categories' => $cat_set,
'api_data' => $api_data
];
if($combine_gallery_page_slug == $parts_page_name[0]) {
$combine_results[$api_token][$websiteproperty_id][$page_slug_bb] = $result;
} else {
$all_results[$api_token][$websiteproperty_id][$page_slug_bb] = $result;
}
}
}
$bragbook_api_information = json_encode($all_results);
$bragbook_combine_api_information = json_encode($combine_results);
update_option("bb_api_data", $bragbook_api_information);
update_option("bb_combine_api_data", $bragbook_combine_api_information);
ob_clean();
}
bb_mvp_brag_shortcode($parts_page_name, $combine_gallery_page_slug);
$data = get_option('bb_api_data');
$favorite_email_id = get_option('bragbook_favorite_email');
$favorite_caseIds_count = 0;
$favorite_caseIds = [];
if($combine_gallery_page_slug == $parts_page_name[0]) {
$data = get_option("bb_combine_api_data");
$bb_f_ajax_page = 'combine';
} else {
$data = get_option('bb_api_data');
$bb_f_ajax_page = 'single';
}
?>
Use the MyFavorites tool to help communicate your specific goals. If a result speaks to you, tap the heart.