Created
April 3, 2013 13:53
-
-
Save aercolino/5301378 to your computer and use it in GitHub Desktop.
Shuffle option added to the Flickr Feed plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
'date_format' => get_option('date_format'), | |
'count' => 10, | |
'shuffle' => 0, | |
'sort' => null, | |
//... | |
else | |
return garees_flickr_feed_error("please enter your flickr-api-key in the settings!"); | |
$amount = $shuffle >= $count ? $shuffle : $count; | |
$shuffled = $shuffle >= $count; | |
// prepare params for query | |
$params = array( | |
'api_key' => $api_key, | |
//'user_id' => $user_id, | |
'per_page' => $amount, | |
'format' => "php_serial", | |
//'method' => "flickr.photos.search", // flickr.photos.getRecent | |
//... | |
$stream = wp_remote_fopen($query); | |
$images = garees_flickr_feed_filter($stream); | |
if ($shuffled) { | |
shuffle($images); | |
$images = array_slice($images, 0, $count); | |
} | |
unset($stream); | |
set_transient($cache_name, $images, 60*$cache_time); | |
//... | |
<dt>count</dt> | |
<dd>Define how many pictures the query should return. Defaults to 10 images.</dd> | |
<dt>shuffle</dt> | |
<dd>Define how many pictures should be shuffled before returning 'count' of them. Any number less than count is considered 0. Defaults to 0 images (no shuffle).</dd> | |
<dt>cache_time</dt> | |
<dd>Specify how long the flickr-results should be cached. Defaults to 15 minutes</dd> | |
//... | |
<h3>Example 4</h3> | |
Search for the 5 newest pictures containing the word "yellowstone". | |
<pre>[flickr_feed text="yellowstone" sort="date-taken-desc" count=5]</pre> | |
Search for the 5/10 newest pictures containing the word "yellowstone". | |
<pre>[flickr_feed text="yellowstone" sort="date-taken-desc" count=5 shuffle=10]</pre> | |
<h3>Example 5</h3> | |
//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment