function getFeed($values, $imageHtml, $beforeImage, $picSize, $nextMaxId = '') { $tagFeed = !empty($values['tag']); $result = ""; if (!$tagFeed) { $userid = $values['userid']; if (!is_numeric($values['userid']) && $values['userid'] != 'self' && $values['userid'] != 'myfeed' && strlen($values['userid'])) { $userid = ColabsInstagram::getUserIdByName($values['userid']); } } $piccounter = 1; $odd = true; $lastShownId = $nextMaxId; do { $max_id = $nextMaxId; if (!$tagFeed) { $data = ColabsInstagram::getFeedByUserId($userid, $max_id, $nextMaxId, intval($values['piccount'])); } else { $data = ColabsInstagram::getFeedByTag($values['tag'], $max_id, $nextMaxId, intval($values['piccount'])); } if (count($data) > 0) { foreach ($data as $obj) { if (intval($values['piccount']) > 0 && $piccounter > $values['piccount']) { break; } $title = intval($values['title']) == 1 ? $obj->caption->text : ""; $result .= sprintf($beforeImage, $odd ? 'odd' : 'even', $piccounter++); $odd = !$odd; $imageKey = ColabsInstagram::getImageKey($picSize); $result .= '<a href="' . $obj->link . '" target="_blank">'; $result .= sprintf($imageHtml, $obj->images->{$imageKey}->url, $picSize); if ($nextMaxId) { $lastShownId = $obj->id; } else { $lastShownId = ''; } } } else { break; } } while ($nextMaxId && ($piccounter <= $values['piccount'] || intval($values['piccount']) == 0)); $result .= '<input type="hidden" id="colabs-next-max-id-' . (intval($values['paging']) + 1) . '" value="' . $nextMaxId . '" />'; return $result; }
$getlatlang = getLatLng($address); if (empty($limit)) { $limit = 10; } $nextMaxId = ''; $max_id = $nextMaxId; $piccounter = 1; $token = ColabsInstagram::getAccessToken(); if ($token) { if (!empty($getlatlang)) { $data = ColabsInstagram::getLocationBasedFeed($getlatlang); } else { if (empty($tag)) { $data = ColabsInstagram::getFeedByUserId($user, $max_id, $nextMaxId); } else { $data = ColabsInstagram::getFeedByTag($tag, $max_id, $nextMaxId); } } if (count($data) > 0) { if (get_option('colabs_random_instagram') == 'true') { shuffle($data); } foreach ($data as $obj) { if (intval($limit) > 0 && $piccounter > $limit) { break; } $title = $obj->caption->text; $urlimg = $obj->images->low_resolution->url; $urlimgori = $obj->images->standard_resolution->url; $likes = $obj->likes->count; $time = date(get_option('date_format'), $obj->created_time);