Flickr Badges Widget - Version 1.0

Version Description

  • Released

=

Download this release

Release Info

Developer zourbuth
Plugin Icon 128x128 Flickr Badges Widget
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (6) hide show
  1. Envato_marketplaces.php +332 -0
  2. css/admin.css +74 -0
  3. css/widget.css +19 -0
  4. flickr-badges-widget.php +162 -0
  5. index.php +66 -0
  6. readme.txt +48 -0
Envato_marketplaces.php ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Wrapper class for the Envato marketplaces API.
5
+ *
6
+ * @author Jeffrey Way <jeffrey@envato.com>
7
+ * @created April, 2011
8
+ * @license Do-whateva-ya-want-with-it
9
+ */
10
+
11
+
12
+ class Envato_marketplaces {
13
+ public $api_key;
14
+ protected $public_url = 'http://marketplace.envato.com/api/edge/set.json';
15
+
16
+ /**
17
+ * Attach your API key.
18
+ *
19
+ * @param string $api_key Can be accessed on the marketplaces via My Account
20
+ * -> My Settings -> API Key
21
+ */
22
+ public function set_api_key($api_key)
23
+ {
24
+ $this->api_key = $api_key;
25
+ }
26
+
27
+ /**
28
+ * Retrieve the value of your API KEY, if needed.
29
+ *
30
+ * @return string The requested API Key.
31
+ */
32
+ public function get_api_key()
33
+ {
34
+ if ( ! isset($this->api_key) ) return 'No API Key is set.';
35
+ return $this->api_key;
36
+ }
37
+
38
+ /**
39
+ * Available sets => 'vitals', 'earnings-and-sales-by-month', 'statement', 'recent-sales', 'account', 'verify-purchase', 'download-purchase'
40
+ *
41
+ */
42
+ public function private_user_data($user_name, $set, $purchase_code = null)
43
+ {
44
+ if ( ! isset($this->api_key) ) return 'You have not set an api key yet.';
45
+ if (! isset($set) ) return 'Missing parameters';
46
+
47
+ $url = "http://marketplace.envato.com/api/edge/$user_name/$this->api_key/$set";
48
+ if ( !is_null($purchase_code) ) $url .= ":$purchase_code";
49
+ $url .= '.json';
50
+
51
+ $result = $this->curl($url);
52
+
53
+ if ( isset($result->error) ) return 'Username, API Key, or purchase code is invalid.';
54
+ return $result->$set;
55
+ }
56
+
57
+ /**
58
+ * Can be used to verify if a person did in fact purchase your item.
59
+ *
60
+ * @param $user_name Author's username.
61
+ * @param $purchase_code - The buyer's purchase code. See Downloads page for
62
+ * receipt.
63
+ * @return object|bool If purchased, returns an object containing the details.
64
+ */
65
+ public function verify_purchase($user_name, $purchase_code)
66
+ {
67
+ $validity = $this->private_user_data($user_name, 'verify-purchase', $purchase_code);
68
+ return isset($validity->buyer) ? $validity : false;
69
+ }
70
+
71
+ /**
72
+ * Helper method to retrieve the balance on your account.
73
+ *
74
+ * @param string $user_name The username attached to your API KEY.
75
+ * @return string The balance in your account.
76
+ */
77
+ public function balance($user_name)
78
+ {
79
+ $vitals = $this->private_user_data($user_name, 'vitals');
80
+ return $vitals->balance;
81
+ }
82
+
83
+ /**
84
+ * Retrieve details for your most recent sales.
85
+ *
86
+ * @param string $user_name The username attached to your API KEY.
87
+ * @param int $limit The number of sales to return.
88
+ * @return array A list of your recent sales.
89
+ */
90
+ public function recent_sales($user_name, $limit = null)
91
+ {
92
+ $sales = $this->private_user_data($user_name, 'recent-sales');
93
+ return $this->apply_limit($sales, $limit);
94
+ }
95
+
96
+ /**
97
+ * Retrieve your account information -- balance, location, name, etc.
98
+ *
99
+ * @param string $user_name The username attached to your API KEY.
100
+ * @return array A list of account information for the user.
101
+ */
102
+ public function account_information($user_name)
103
+ {
104
+ return $this->private_user_data($user_name, 'account');
105
+ }
106
+
107
+ /**
108
+ * Grab quick monthly stats - number of sales, income, etc.
109
+ *
110
+ * @param string $user_name The username attached to your API KEY.
111
+ * @param int $limit The number of months to return.
112
+ * @return array A list of sales figures, ordered by month.
113
+ */
114
+ public function earnings_by_month($user_name, $limit = null)
115
+ {
116
+ $earnings = $this->private_user_data($user_name, 'earnings-and-sales-by-month');
117
+ return $this->apply_limit($earnings, $limit);
118
+ }
119
+
120
+ /**
121
+ * Generic method, to be used in combination with the marketplace API docs.
122
+ *
123
+ * @param string $user_name The user name of the seller to track.
124
+ * @return array The returned data wrapped in an array.
125
+ */
126
+ public function public_user_data($user_name)
127
+ {
128
+ $url = preg_replace('/set/i', 'user:' . $user_name, $this->public_url);
129
+ return $this->curl($url)->user;
130
+ }
131
+
132
+ /**
133
+ * Returns the featured item, author, and free file for a given marketplace.
134
+ *
135
+ * @param string $marketplace_name The desired marketplace name.
136
+ * @return array The featured file, free file, and featured author for the
137
+ * given site.
138
+ */
139
+ public function featured($marketplace_name = 'themeforest')
140
+ {
141
+ $url = preg_replace('/set/i', 'features:' . $marketplace_name, $this->public_url);
142
+ return $this->curl($url)->features;
143
+ }
144
+
145
+ /**
146
+ * Retrieve the details for a specific marketplace item.
147
+ *
148
+ * @param string $item_id The id of the item you need information for.
149
+ * @return object Details for the given item.
150
+ */
151
+ public function item_details($item_id)
152
+ {
153
+ $url = preg_replace('/set/i', 'item:' . $item_id, $this->public_url);
154
+ return $this->curl($url)->item;
155
+ }
156
+
157
+ /**
158
+ * Returns new files from a specific marketplaces and category.
159
+ *
160
+ * @param string $marketplace_name The desired marketplace name.
161
+ * @param string $category The name of the category you'd like to search.
162
+ * @param int $limit The number of files to return.
163
+ * @return array A list of ALL recent files.
164
+ */
165
+ public function new_files($marketplace_name = 'themeforest', $category = 'wordpress', $limit = null)
166
+ {
167
+ $url = preg_replace('/set/i', 'new-files:' . $marketplace_name . ','. $category, $this->public_url);
168
+ $new_files = $this->curl($url)->{'new-files'};
169
+
170
+ return $this->apply_limit($new_files, $limit);
171
+ }
172
+
173
+ /**
174
+ * Similar to new_files, but focuses on a specific author's files.
175
+ *
176
+ * @param string $user_name The desired username.
177
+ * @param string $marketplace_name The desired marketplace name.
178
+ * @param int $limit The number of files to return.
179
+ * @return array A list of recently added files by one user.
180
+ */
181
+ public function new_files_from_user($user_name, $marketplace_name = 'themeforest', $limit = null)
182
+ {
183
+ $url = preg_replace('/set/i', 'new-files-from-user:' . $user_name . ',' . $marketplace_name, $this->public_url);
184
+ $new_files = $this->curl($url)->{'new-files-from-user'};
185
+
186
+ // If a limit is passed, create new array from results with a count equal
187
+ // to the limit.
188
+ return $this->apply_limit($new_files, $limit);
189
+ }
190
+
191
+ /**
192
+ * Helper function which automatically echos out a list of thumbnails
193
+ * + links. Use new_files_from_user for more control.
194
+ *
195
+ * @param string $user_name The username of the account you want to display
196
+ * thumbnails from.
197
+ * @param string $marketplace_name The desired marketplace name.
198
+ * @param int $limit The number of thumbnails to display.
199
+ * @return string Helper function immediately echos out thumbnails.
200
+ * Careful...
201
+ */
202
+ public function display_thumbs($user_name, $marketplace_name, $limit = null)
203
+ {
204
+ $results = $this->new_files_from_user($user_name, $marketplace_name, $limit);
205
+
206
+ echo "<ul> \n";
207
+ foreach($results as $item) : ?>
208
+ <?php if ( is_null($item) ) break; ?>
209
+ <li>
210
+ <a href="<?php echo $item->url . "?ref=$user_name"; ?>">
211
+ <img src="<?php echo $item->thumbnail; ?>" />
212
+ </a>
213
+ </li>
214
+ <?php endforeach;
215
+ echo "\n</ul>";
216
+
217
+ }
218
+
219
+ /**
220
+ * Retrieve the most popular files of the previous week.
221
+ *
222
+ * @param string $marketplace_name Desired marketplace name.
223
+ * @param int $limit The number of items to return [optional].
224
+ * @return array A list of the most sold items in the given marketplace last
225
+ * week.
226
+ */
227
+ public function most_popular_last_week($marketplace_name = 'themeforest', $limit = null)
228
+ {
229
+ $url = preg_replace('/set/i', 'popular:' . $marketplace_name, $this->public_url);
230
+ $pop = $this->curl($url)->popular->items_last_week;
231
+ return $this->apply_limit($pop, $limit);
232
+ }
233
+
234
+ /**
235
+ * Perform search queries on all of the marketplaces, or a specific one.
236
+ *
237
+ * @param string $search_expression What are you searching for?
238
+ * @param string $marketplace_name The name of the marketplace you want to
239
+ * search. [optional]
240
+ * @param string $type The item type (category). See search options on
241
+ * marketplace for list. [optional]
242
+ * @param integer $limit The number of items to return [optional]
243
+ * @return array A list of the search results.
244
+ */
245
+ public function search($search_expression, $marketplace_name = '', $type = '', $limit = null)
246
+ {
247
+ if ( empty($search_expression) ) return false;
248
+ # Can't use spaces. Need to replace them with pipes.
249
+ else $search_expression = preg_replace('/\s/', '|', $search_expression);
250
+
251
+ $url = preg_replace('/set/i', 'search:' . $marketplace_name . ',' . $type . ',' . $search_expression, $this->public_url );
252
+ $search_results = $this->curl($url)->search;
253
+ return $this->apply_limit($search_results, $limit);
254
+ }
255
+
256
+ /**
257
+ * Retrieves general marketplace member information.
258
+ *
259
+ * @param string $user_name The username to query.
260
+ * @return object Contains the requested user information.
261
+ */
262
+ public function user_information($user_name)
263
+ {
264
+ $url = preg_replace('/set/i', 'user:' . $user_name, $this->public_url);
265
+ return $this->curl($url)->user;
266
+ }
267
+
268
+ /**
269
+ * Retrieve an array of all the items in a particular collection.
270
+ *
271
+ * @param string $collection_id The id of the requested collection. See url
272
+ * of collection page for id.
273
+ * @return array A list of all the items in the collection.
274
+ */
275
+ public function collection($collection_id)
276
+ {
277
+ $url = preg_replace('/set/i', 'collection:' . $collection_id, $this->public_url);
278
+ return $this->curl($url)->collection;
279
+ }
280
+
281
+ /**
282
+ * Filters returned result, according to the supplied $limit.
283
+ *
284
+ * @param string $orig_arr The original array to work on.
285
+ * @param int $limit Specifies the number of array items in the result.
286
+ * @return array A new array with a count equal to the passed $limit.
287
+ */
288
+ protected function apply_limit($orig_arr, $limit)
289
+ {
290
+ if ( !is_int($limit) ) return $orig_arr;
291
+
292
+ // Make sure that there are enough items to filter through...
293
+ if ( $limit > count($orig_arr) ) $limit = count($orig_arr);
294
+
295
+ $new_arr = array();
296
+ for ( $i = 0; $i <= $limit - 1; $i++ ) {
297
+ $new_arr[] = $orig_arr[$i];
298
+ }
299
+ return $new_arr;
300
+ }
301
+
302
+ /**
303
+ * General purpose function to query the marketplace API.
304
+ *
305
+ * @param string $url The url to access, via curl.
306
+ * @return object The results of the curl request.
307
+ */
308
+ protected function curl($url)
309
+ {
310
+ if ( empty($url) ) return false;
311
+
312
+ $ch = curl_init($url);
313
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
314
+
315
+ $data = curl_exec($ch);
316
+ curl_close($ch);
317
+
318
+ return json_decode($data);
319
+ }
320
+
321
+ /**
322
+ * A simple convenience function to save a few seconds during development.
323
+ *
324
+ * @param $data The array or object to display on the page, for testing.
325
+ */
326
+ public function prettyPrint($data)
327
+ {
328
+ echo "<pre>";
329
+ print_r($data);
330
+ echo "</pre>";
331
+ }
332
+ }
css/admin.css ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Widgets page. */
2
+ .columns-1 {
3
+ }
4
+ .columns-2 {
5
+ overflow: hidden;
6
+ float: left;
7
+ width: 48%;
8
+ }
9
+ .columns-3 {
10
+ overflow: hidden;
11
+ float: left;
12
+ width: 31%;
13
+ margin-right: 3.5%;
14
+ }
15
+ .column-last {
16
+ float: right;
17
+ margin-right: 0;
18
+ }
19
+
20
+ .zourbuth-widget-controls label {
21
+ font-size: 11px;
22
+ }
23
+ .zourbuth-widget-controls textarea:hover,
24
+ .zourbuth-widget-controls input[type="text"]:hover {
25
+ background-color: #F7F7F7;
26
+ }
27
+ .zourbuth-widget-controls textarea:hover,
28
+ .zourbuth-widget-controls input[type="text"]:hover {
29
+ background-color: #F7F7F7;
30
+ }
31
+ .columns-2 input.widefat, .columns-2 select.widefat {
32
+ width: 99%;
33
+ }
34
+ .columns-3 select.widefat {
35
+ width: 98.5%;
36
+ }
37
+ .zourbuth-widget-controls select[multiple="multiple"] {
38
+ width: 100%;
39
+ height: 5.0em !important;
40
+ }
41
+ input.smallfat {
42
+ float: right;
43
+ width: 66px;
44
+ }
45
+ select.smallfat {
46
+ float: right;
47
+ min-width: 66px;
48
+ }
49
+ .zourbuth-notes {
50
+ color: #666666;
51
+ }
52
+ .zourbuth-notes a{
53
+ text decoration: none;
54
+ }
55
+ img.zourbuth-logo {
56
+ vertical-align: middle;
57
+ }
58
+ img.zourbuth-feed {
59
+ vertical-align: middle;
60
+ }
61
+
62
+ .envato-marketplace li {
63
+ float: left;
64
+ margin-bottom: 0;
65
+ margin-right: 3px;
66
+ }
67
+ .clear {
68
+ clear: both;
69
+ display: block;
70
+ overflow: hidden;
71
+ visibility: hidden;
72
+ width: 0;
73
+ height: 0;
74
+ }
css/widget.css ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .zframe-flickr-wrap-ltr, .zframe-flickr-wrap-rtl {
2
+ display: block;
3
+ overflow: hidden;
4
+ }
5
+ .zframe-flickr-wrap-ltr img, .zframe-flickr-wrap-rtl img {
6
+ border: 1px solid #C9C9C9;
7
+ margin-bottom: 10px;
8
+ padding: 1px;
9
+ }
10
+
11
+ .zframe-flickr-wrap-ltr img {
12
+ float: left;
13
+ margin-right: 10px;
14
+ }
15
+
16
+ .zframe-flickr-wrap-rtl img {
17
+ float: right;
18
+ margin-left: 10px;
19
+ }
flickr-badges-widget.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget - Flickr Badges Widget
4
+ *
5
+ * @package zFrame
6
+ * @subpackage Classes
7
+ * For another improvement, you can drop email to zourbuth@gmail.com or visit http://zourbuth.com
8
+ **/
9
+
10
+ class Flickr_Badges_Widget extends WP_Widget {
11
+
12
+ /** Set up the widget's unique name, ID, class, description, and other options. **/
13
+ function __construct() {
14
+
15
+ /* Set up the widget control options. */
16
+ $control_options = array(
17
+ 'width' => 525,
18
+ 'height' => 350,
19
+ 'id_base' => "flickr-badges"
20
+ );
21
+ /** Add some informations to the widget **/
22
+ $widget_options = array('classname' => 'flickr-badges', 'description' => __( 'Displays a Flickr photo stream from an ID', $this->textdomain ) );
23
+
24
+ /* Create the widget. */
25
+ $this->WP_Widget('flickr-badges', __('Flickr Badge', $this->textdomain), $widget_options, $control_options );
26
+
27
+ /* Load the widget style only at the widget appereance page. */
28
+ add_action( 'load-widgets.php', array( &$this, 'flickr_badges_admin' ) );
29
+
30
+ if ( is_active_widget(false, false, $this->id_base, true) ) {
31
+ /* load the widget stylesheet for the widgets screen. */
32
+ wp_enqueue_style( 'flickr-badges', FLICKR_BADGES_WIDGET_URL . 'css/widget.css', false, 0.7, 'screen' );
33
+ wp_enqueue_style( 'flickr-badges' );
34
+ }
35
+ }
36
+
37
+ /** enqueue the widget option stylesheet css **/
38
+ function flickr_badges_admin() {
39
+ wp_enqueue_style( 'flickr-badges-admin', FLICKR_BADGES_WIDGET_URL . 'css/admin.css', false, 0.7, 'screen' );
40
+ }
41
+
42
+ function widget( $args, $instance ) {
43
+ extract( $args );
44
+
45
+ $title = apply_filters('widget_title', empty($instance['title']) ? __('Photos on flickr', $this->textdomain) : $instance['title'], $instance, $this->id_base);
46
+ $type = empty( $instance['type'] ) ? 'user' : $instance['type'];
47
+ $flickr_id = $instance['flickr_id'];
48
+ $count = (int)$instance['count'];
49
+ $intro_text = $instance['intro_text'];
50
+ $outro_text = $instance['outro_text'];
51
+ $display = empty( $instance['display'] ) ? 'latest' : $instance['display'];
52
+
53
+ /** if the photo is < 1, set it to 1 **/
54
+ if ( $count < 1 )
55
+ $count = 1;
56
+
57
+ /** if the widget have an ID, we can continue **/
58
+ if ( !empty( $flickr_id ) ) {
59
+
60
+ /** print the before widget **/
61
+ echo $before_widget;
62
+
63
+ if ( $title )
64
+ echo $before_title . $title . $after_title;
65
+
66
+ /** get the user direction, rtl or ltr **/
67
+ if ( function_exists( 'is_rtl' ) )
68
+ $dir= is_rtl() ? 'rtl' : 'ltr';
69
+
70
+ /** wrap the widget **/
71
+ ?> <?php if (!empty( $instance['intro_text'] ) ) echo '<p>' . do_shortcode( $instance['intro_text'] ) . '</p>'; ?>
72
+ <div class="zframe-flickr-wrap-<?php echo $dir; ?>">
73
+ <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=<?php echo $count; ?>&amp;display=<?php echo $display; ?>&amp;size=s&amp;layout=x&amp;source=<?php echo $type;?>&amp;<?php echo $type;?>=<?php echo $flickr_id; ?>"></script>
74
+ </div>
75
+ <div style="clear:both;">&nbsp;</div>
76
+ <?php if (!empty( $instance['outro_text'] ) ) echo '<p>' . do_shortcode( $instance['outro_text'] ) . '</p>'; ?>
77
+
78
+ <?php /** print the after widget **/
79
+ echo $after_widget;
80
+ }
81
+ }
82
+
83
+ function update( $new_instance, $old_instance ) {
84
+ $instance = $old_instance;
85
+ $instance['title'] = strip_tags($new_instance['title']);
86
+ $instance['intro_text'] = $new_instance['intro_text'];
87
+ $instance['outro_text'] = $new_instance['outro_text'];
88
+ $instance['type'] = strip_tags($new_instance['type']);
89
+ $instance['flickr_id'] = strip_tags($new_instance['flickr_id']);
90
+ $instance['count'] = (int) $new_instance['count'];
91
+ $instance['display'] = strip_tags($new_instance['display']);
92
+
93
+ return $instance;
94
+ }
95
+
96
+ function form( $instance ) {
97
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
98
+ $type = isset($instance['type']) ? esc_attr($instance['type']) : 'user';
99
+ $intro_text = $instance['intro_text'];
100
+ $outro_text = $instance['outro_text'];
101
+ $flickr_id = isset($instance['flickr_id']) ? esc_attr($instance['flickr_id']) : '';
102
+ $count = isset($instance['count']) ? absint($instance['count']) : 3;
103
+ $display = isset( $instance['display'] ) ? $instance['display'] : 'latest';
104
+ ?>
105
+
106
+ <div class="zframe-widget-controls columns-2">
107
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', $this->textdomain); ?></label>
108
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
109
+ </p>
110
+ <p>
111
+ <label for="<?php echo $this->get_field_id( 'intro_text' ); ?>"><?php _e('Intro Text:', $this->textdomain ) ?></label><br />
112
+ <textarea name="<?php echo $this->get_field_name( 'intro_text' ); ?>" id="<?php echo $this->get_field_id( 'intro_text' ); ?>" rows="4" class="widefat"><?php echo htmlentities($instance['intro_text']); ?></textarea>
113
+ <code>This field support HTML.</code>
114
+ </p>
115
+ <p>
116
+ <label for="<?php echo $this->get_field_id('type'); ?>"><?php _e( 'Type:', $this->textdomain ); ?></label>
117
+ <select class="column-last" name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>" class="widefat">
118
+ <option value="user"<?php selected($type,'user');?>>User</option>
119
+ <option value="group"<?php selected($type,'group');?>>Group</option>
120
+ </select>
121
+ </p>
122
+
123
+ <p><label for="<?php echo $this->get_field_id('flickr_id'); ?>"><?php _e('Flickr ID (<a href="http://www.idgettr.com" target="_blank">idGettr</a>):', $this->textdomain); ?></label>
124
+ <input class="column-last" id="<?php echo $this->get_field_id('flickr_id'); ?>" name="<?php echo $this->get_field_name('flickr_id'); ?>" type="text" value="<?php echo $flickr_id; ?>" /></p>
125
+
126
+ <p><label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Number of photo to show:', $this->textdomain); ?></label>
127
+ <input class="column-last" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" type="text" value="<?php echo $count; ?>" size="3" /></p>
128
+
129
+ <p><label for="<?php echo $this->get_field_id('display'); ?>"><?php _e('Display method:', $this->textdomain); ?></label>
130
+ <select class="column-last" id="<?php echo $this->get_field_id('display'); ?>" name="<?php echo $this->get_field_name('display'); ?>">
131
+ <option<?php if($display == 'latest') echo ' selected="selected"'?> value="latest"><?php _e('Latest', $this->textdomain); ?></option>
132
+ <option<?php if($display == 'random') echo ' selected="selected"'?> value="random"><?php _e('Random', $this->textdomain); ?></option>
133
+ </select></p>
134
+ <p>
135
+ <label for="<?php echo $this->get_field_id( 'outro_text' ); ?>"><?php _e('Outro Text:', $this->textdomain ) ?></label><br />
136
+ <textarea name="<?php echo $this->get_field_name( 'outro_text' ); ?>" id="<?php echo $this->get_field_id( 'outro_text' ); ?>" rows="4" class="widefat"><?php echo htmlentities($instance['outro_text']); ?></textarea>
137
+ <code>This field support HTML.</code>
138
+ </p>
139
+ <p>
140
+ <a href="http://feedburner.google.com/fb/a/mailverify?uri=zourbuth&amp;loc=en_US">Subscribe to zourbuth by Email</a><br />
141
+ <?php _e( 'Like my work? Please consider to ', $this->textdomain ); ?><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W6D3WAJTVKAFC" title="Donate"><?php _e( 'donate', $this->textdomain ); ?></a>.
142
+ </p>
143
+
144
+ </div>
145
+
146
+ <div class="zframe-widget-controls envato-marketplace columns-2 column-last">
147
+ <?php
148
+ require_once 'Envato_marketplaces.php';
149
+ $Envato = new Envato_marketplaces();
150
+ $Envato->display_thumbs('zourbuth', 'codecanyon', '5');
151
+ ?>
152
+ <br class="clear" />
153
+ <p>
154
+ <br />
155
+ &copy; Copyright <a href="http://zourbuth.com">zourbuth</a> 2011.
156
+ </p>
157
+ </div>
158
+
159
+ <div class="clear"></div>
160
+ <?php
161
+ }
162
+ }
index.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Flickr Badges Widget
4
+ Plugin URI: http://zourbuth.com/plugins/flickr-badges-widget
5
+ Description: Display your Flickr latest photostream in widget area.
6
+ Version: 1.0
7
+ Author: zourbuth
8
+ Author URI: http://zourbuth.com
9
+ License: Under GPL2
10
+ */
11
+
12
+ /*
13
+ Copyright 2011 zourbuth (email : zourbuth@gmail.com)
14
+
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License, version 2, as
17
+ published by the Free Software Foundation.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+ /* Launch the plugin. */
30
+ add_action( 'plugins_loaded', 'flickr_badges_widget_plugins_loaded' );
31
+
32
+ /* Initializes the plugin and it's features. */
33
+ function flickr_badges_widget_plugins_loaded() {
34
+
35
+ /* Set constant path to the members plugin directory. */
36
+ define( 'FLICKR_BADGES_WIDGET_DIR', plugin_dir_path( __FILE__ ) );
37
+
38
+ /* Set constant path to the members plugin directory. */
39
+ define( 'FLICKR_BADGES_WIDGET_URL', plugin_dir_url( __FILE__ ) );
40
+
41
+ /* Loads and registers the new widgets. */
42
+ add_action( 'widgets_init', 'flickr_badges_widget_init' );
43
+
44
+ /* Create additional links to plugin list */
45
+ add_filter( 'plugin_row_meta', '_fbw_my_portfolio', 10, 2 );
46
+ }
47
+
48
+ /* Register the extra widgets. Each widget is meant to replace or extend the current default */
49
+ function flickr_badges_widget_init() {
50
+
51
+ /* Load widget file. */
52
+ require_once( FLICKR_BADGES_WIDGET_DIR . 'flickr-badges-widget.php' );
53
+
54
+ /* Register widget. */
55
+ register_widget( 'flickr_badges_widget' );
56
+ }
57
+
58
+ function _fbw_my_portfolio($links, $file) {
59
+ $plugin = plugin_basename(__FILE__);
60
+
61
+ if ($file == $plugin) // create link
62
+ return array_merge( $links, array( sprintf( '<a href="http://codecanyon.net/user/zourbuth/portfolio?ref=zourbuth">Portfolios</a>', $plugin, __('Portfolios') ) ));
63
+ return $links;
64
+ }
65
+
66
+ ?>
readme.txt ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Flickr Badges Widget ===
2
+ Contributors: zourbuth
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W6D3WAJTVKAFC
4
+ Tags: Flickr, widget, badge, feed, photostream, javascript
5
+ Requires at least: 3.0
6
+ Tested up to: 3.3
7
+ Stable tag: 1.0
8
+
9
+ Display your Flickr latest photostream in widget area.
10
+
11
+ == Description ==
12
+
13
+ This is a simple widget to display your Flickr latest photostream in widget area using javascript from <code>http://www.flickr.com/badge_code_v2.gne</code>.
14
+ Find your Flickr ID from (<a href="http://www.idgettr.com" target="_blank">idGettr</a> if you do not know your id.
15
+ Easy to customize, just put your Flickr id and your widget ready to lunch.
16
+
17
+ <h3>Installation</h3>
18
+ You can use the built in installer and upgrader, or you can install the plugin manually.<br />
19
+ 1. Go to the menu 'Plugins' -> 'Install' and search for 'Flickr Badges Widget'.<br />
20
+ 2. Click 'install'.
21
+
22
+ == Installation ==
23
+
24
+ You can use the built in installer and upgrader, or you can install the plugin manually.
25
+ 1. Go to the menu 'Plugins' -> 'Install' and search for 'Flickr Badges Widget'
26
+ 2. Click 'install'.
27
+
28
+ == Frequently Asked Questions ==
29
+
30
+ = A question that someone might have =
31
+
32
+ Please read the FAQ under http://zourbuth.com/plugins/flickr-badges-widget
33
+
34
+
35
+ == Screenshots ==
36
+
37
+ 1. Widget Settings
38
+ 2. Widget in frontend
39
+
40
+ == Changelog ==
41
+
42
+ = 1.0 =
43
+ * Released
44
+
45
+ == Upgrade Notice ==
46
+
47
+ = 1.0 =
48
+ Just upgrade via Wordpress.