Flickr Badges Widget - Version 1.2.9

Version Description

  • Added default widget paramaters
  • Added widget shortcode and PHP function
Download this release

Release Info

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

Code changes from version 1.2.8 to 1.2.9

Files changed (4) hide show
  1. index.php +4 -3
  2. main.php +131 -0
  3. readme.txt +7 -3
  4. widget.php +17 -62
index.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Flickr Badges Widget
4
  Plugin URI: http://www.ground6.com/wordpress-plugins/flickr-badges-widget/
5
  Description: Display your Flickr latest photostream in widget area using javascript. Easy to customize, just put your Flickr id and your widget ready to lunch.
6
- Version: 1.2.8
7
  Author: zourbuth
8
  Author URI: http://zourbuth.com
9
  License: Under GPL2
10
 
11
- Copyright 2015 zourbuth (email : zourbuth@gmail.com)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License, version 2, as
@@ -37,7 +37,7 @@ if ( ! defined( 'ABSPATH' ) )
37
  * Set constant path to the members plugin directory
38
  * @since 1.0
39
  */
40
- define( 'FLICKR_BADGES_WIDGET_VERSION', '1.2.8' );
41
  define( 'FLICKR_BADGES_WIDGET_DIR', plugin_dir_path( __FILE__ ) );
42
  define( 'FLICKR_BADGES_WIDGET_URL', plugin_dir_url( __FILE__ ) );
43
 
@@ -55,6 +55,7 @@ add_action( 'plugins_loaded', 'flickr_badges_widget_plugins_loaded' );
55
  * @since 1.0
56
  */
57
  function flickr_badges_widget_plugins_loaded() {
 
58
  add_action( 'widgets_init', 'flickr_badges_widget_init' );
59
  }
60
 
3
  Plugin Name: Flickr Badges Widget
4
  Plugin URI: http://www.ground6.com/wordpress-plugins/flickr-badges-widget/
5
  Description: Display your Flickr latest photostream in widget area using javascript. Easy to customize, just put your Flickr id and your widget ready to lunch.
6
+ Version: 1.2.9
7
  Author: zourbuth
8
  Author URI: http://zourbuth.com
9
  License: Under GPL2
10
 
11
+ Copyright 2016 zourbuth (email : zourbuth@gmail.com)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License, version 2, as
37
  * Set constant path to the members plugin directory
38
  * @since 1.0
39
  */
40
+ define( 'FLICKR_BADGES_WIDGET_VERSION', '1.2.9' );
41
  define( 'FLICKR_BADGES_WIDGET_DIR', plugin_dir_path( __FILE__ ) );
42
  define( 'FLICKR_BADGES_WIDGET_URL', plugin_dir_url( __FILE__ ) );
43
 
55
  * @since 1.0
56
  */
57
  function flickr_badges_widget_plugins_loaded() {
58
+ require_once( FLICKR_BADGES_WIDGET_DIR . 'main.php' );
59
  add_action( 'widgets_init', 'flickr_badges_widget_init' );
60
  }
61
 
main.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Main Plugin Class 0.0.1
4
+
5
+ Copyright 2016 zourbuth.com (email: zourbuth@gmail.com)
6
+
7
+ This program is free software; you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License, version 2, as
9
+ published by the Free Software Foundation.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program; if not, write to the Free Software
18
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+
22
+ if ( ! defined( 'ABSPATH' ) ) // exit if is accessed directly
23
+ exit;
24
+
25
+
26
+ /**
27
+ * Class constructor
28
+ *
29
+ * @since 0.0.1
30
+ */
31
+ class Flickr_Badges_Widget_Main {
32
+
33
+ var $textdomain;
34
+
35
+ /**
36
+ * Class constructor
37
+ *
38
+ * @since 0.0.1
39
+ */
40
+ function __construct() {
41
+ add_shortcode( 'flickr-badge-widget', array( &$this, 'widget_shortcode' ) );
42
+ }
43
+
44
+
45
+ /**
46
+ * Add widget shortcode based on widget id
47
+ *
48
+ * @param $atts (array)
49
+ * @since 0.0.1
50
+ */
51
+ function widget_shortcode( $atts ) {
52
+ $atts = shortcode_atts( array(
53
+ 'id' => false,
54
+ ), $atts, 'urlink' );
55
+
56
+ $html = '';
57
+
58
+ $options = get_option( 'widget_zflickr' );
59
+ $widget_id = $atts['id'];
60
+ $instance = $options[$widget_id];
61
+
62
+ $args = wp_parse_args( (array) $instance, fbw_default_args() );
63
+
64
+ return fbw_output( $args );
65
+ }
66
+
67
+
68
+ } new Flickr_Badges_Widget_Main();
69
+
70
+
71
+ /**
72
+ * Default arguments
73
+ *
74
+ * @since 0.0.1
75
+ */
76
+ function fbw_default_args() {
77
+ return array(
78
+ 'title' => esc_attr__( 'Flickr Widget', 'flickr-badges-widget' ),
79
+ 'type' => 'user',
80
+ 'flickr_id' => '', // 71865026@N00
81
+ 'count' => 9,
82
+ 'display' => 'display',
83
+ 'size' => 's',
84
+ 'copyright' => true,
85
+ 'tab' => array( 0 => true, 1 => false, 2 => false, 3 => false ),
86
+ 'intro_text' => '',
87
+ 'outro_text' => '',
88
+ 'custom' => ''
89
+ );
90
+ }
91
+
92
+
93
+ /**
94
+ * Default arguments
95
+ *
96
+ * @since 0.0.1
97
+ */
98
+ function fbw_output( $args ) {
99
+
100
+ $output = '';
101
+
102
+ // Get the user direction, rtl or ltr
103
+ if ( function_exists( 'is_rtl' ) )
104
+ $dir = is_rtl() ? 'rtl' : 'ltr';
105
+
106
+ // Wrap the widget
107
+ if ( ! empty( $args['intro_text'] ) )
108
+ $output .= '<p>' . do_shortcode( $args['intro_text'] ) . '</p>';
109
+
110
+ $output .= "<div class='flickr-badge-wrapper zframe-flickr-wrap-$dir'>";
111
+
112
+ $protocol = is_ssl() ? 'https' : 'http';
113
+
114
+ // If the widget have an ID, we can continue
115
+ if ( ! empty( $args['flickr_id'] ) )
116
+ $output .= "<script type='text/javascript' src='$protocol://www.flickr.com/badge_code_v2.gne?count={$args['count']}&amp;display={$args['display']}&amp;size={$args['size']}&amp;layout=x&amp;source={$args['type']}&amp;{$args['type']}={$args['flickr_id']}'></script>";
117
+ else
118
+ $output .= '<p>' . __('Please provide an Flickr ID', 'flickr-badges-widget') . '</p>';
119
+
120
+ $output .= '</div>';
121
+
122
+ if ( ! empty( $args['outro_text'] ) )
123
+ $output .= '<p>' . do_shortcode( $args['outro_text'] ) . '</p>';
124
+
125
+ if ( $args['copyright'] )
126
+ $output .= '<a href="http://wordpress.org/extend/plugins/flickr-badges-widget/">
127
+ <span style="font-size: 11px;"><span style="color: #0063DC; font-weight: bold;">Flick</span><span style="color: #FF0084; font-weight: bold;">r</span> Badges Widget</span>
128
+ </a>';
129
+
130
+ return $output;
131
+ }
readme.txt CHANGED
@@ -3,10 +3,10 @@ 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, sidebar, gallery, photo, photo gallery, photography, sidebar, user, group, image, images, recent, random, picture, image-widget
5
  Requires at least: 4.1.1
6
- Tested up to: 4.3
7
- Stable tag: 1.2.8
8
 
9
- A fast plugin toisplay your Flickr photostream in a sidebar easily without authentication.
10
 
11
  == Description ==
12
 
@@ -64,6 +64,10 @@ http://www.ground6.com/wordpress-plugins/flickr-badges-widget/screenshots/
64
 
65
  == Changelog ==
66
 
 
 
 
 
67
  = 1.2.8 =
68
  * Fix deprecated WP_Widget for WP 4.3
69
 
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, sidebar, gallery, photo, photo gallery, photography, sidebar, user, group, image, images, recent, random, picture, image-widget
5
  Requires at least: 4.1.1
6
+ Tested up to: 4.5
7
+ Stable tag: 1.2.9
8
 
9
+ A fast plugin to display your Flickr photostream in a sidebar easily without any authentications.
10
 
11
  == Description ==
12
 
64
 
65
  == Changelog ==
66
 
67
+ = 1.2.9 =
68
+ * Added default widget paramaters
69
+ * Added widget shortcode and PHP function
70
+
71
  = 1.2.8 =
72
  * Fix deprecated WP_Widget for WP 4.3
73
 
widget.php CHANGED
@@ -71,9 +71,7 @@ class Flickr_Badges_Widget extends WP_Widget {
71
  wp_enqueue_script( 'z-flickr-admin', FLICKR_BADGES_WIDGET_URL . 'js/jquery.dialog.js' );
72
  }
73
 
74
-
75
-
76
-
77
  /**
78
  * Outputs another item
79
  * @since 1.2.2
@@ -108,58 +106,21 @@ class Flickr_Badges_Widget extends WP_Widget {
108
  extract( $args );
109
 
110
  // Set up the arguments for wp_list_categories().
111
- $cur_arg = array(
112
- 'title' => $instance['title'],
113
- 'type' => empty( $instance['type'] ) ? 'user' : $instance['type'],
114
- 'flickr_id' => $instance['flickr_id'],
115
- 'count' => (int) $instance['count'],
116
- 'display' => empty( $instance['display'] ) ? 'latest' : $instance['display'],
117
- 'size' => isset( $instance['size'] ) ? $instance['size'] : 's',
118
- 'copyright' => ! empty( $instance['copyright'] ) ? true : false
119
- );
120
-
121
- extract( $cur_arg );
122
 
123
  // print the before widget
124
  echo $before_widget;
125
 
126
- if ( $title )
127
- echo $before_title . $title . $after_title;
128
 
129
- // Get the user direction, rtl or ltr
130
- if ( function_exists( 'is_rtl' ) )
131
- $dir = is_rtl() ? 'rtl' : 'ltr';
132
-
133
- // Wrap the widget
134
- if ( ! empty( $instance['intro_text'] ) )
135
- echo '<p>' . do_shortcode( $instance['intro_text'] ) . '</p>';
136
-
137
- echo "<div class='flickr-badge-wrapper zframe-flickr-wrap-$dir'>";
138
-
139
- $protocol = is_ssl() ? 'https' : 'http';
140
-
141
- // If the widget have an ID, we can continue
142
- if ( ! empty( $instance['flickr_id'] ) )
143
- echo "<script type='text/javascript' src='$protocol://www.flickr.com/badge_code_v2.gne?count=$count&amp;display=$display&amp;size=$size&amp;layout=x&amp;source=$type&amp;$type=$flickr_id'></script>";
144
- else
145
- echo '<p>' . __('Please provide an Flickr ID', $this->textdomain) . '</p>';
146
-
147
- echo '</div>';
148
-
149
- if ( ! empty( $instance['outro_text'] ) )
150
- echo '<p>' . do_shortcode( $instance['outro_text'] ) . '</p>';
151
-
152
- if ( $copyright )
153
- echo '<a href="http://zourbuth.com/archives/500/flickr-badges-widget-free-wordpress-plugin/">
154
- <span style="font-size: 11px;"><span style="color: #0063DC; font-weight: bold;">Flick</span><span style="color: #FF0084; font-weight: bold;">r</span> Badges Widget</span>
155
- </a>';
156
 
157
  // Print the after widget
158
  echo $after_widget;
159
  }
160
 
161
 
162
-
163
  /**
164
  * Widget update functino
165
  * @since 1.2.1
@@ -182,29 +143,13 @@ class Flickr_Badges_Widget extends WP_Widget {
182
  }
183
 
184
 
185
-
186
  /**
187
  * Widget form function
188
  * @since 1.2.1
189
  **/
190
  function form( $instance ) {
191
- // Set up the default form values.
192
- $defaults = array(
193
- 'title' => esc_attr__( 'Flickr Widget', $this->textdomain ),
194
- 'type' => 'user',
195
- 'flickr_id' => '', // 71865026@N00
196
- 'count' => 9,
197
- 'display' => 'display',
198
- 'size' => 's',
199
- 'copyright' => true,
200
- 'tab' => array( 0 => true, 1 => false, 2 => false, 3 => false ),
201
- 'intro_text' => '',
202
- 'outro_text' => '',
203
- 'custom' => ''
204
- );
205
-
206
- /* Merge the user-selected arguments with the defaults. */
207
- $instance = wp_parse_args( (array) $instance, $defaults );
208
 
209
  $types = array(
210
  'user' => esc_attr__( 'user', $this->textdomain ),
@@ -313,6 +258,16 @@ class Flickr_Badges_Widget extends WP_Widget {
313
 
314
  <li class="tab-pane <?php if ( $instance['tab'][1] ) : ?>active<?php endif; ?>">
315
  <ul>
 
 
 
 
 
 
 
 
 
 
316
  <li>
317
  <label for="<?php echo $this->get_field_id('intro_text'); ?>"><?php _e( 'Intro Text', $this->textdomain ); ?></label>
318
  <span class="controlDesc"><?php _e( 'This option will display addtional text before the widget content and HTML supports.', $this->textdomain ); ?></span>
71
  wp_enqueue_script( 'z-flickr-admin', FLICKR_BADGES_WIDGET_URL . 'js/jquery.dialog.js' );
72
  }
73
 
74
+
 
 
75
  /**
76
  * Outputs another item
77
  * @since 1.2.2
106
  extract( $args );
107
 
108
  // Set up the arguments for wp_list_categories().
109
+ $instance = wp_parse_args( (array) $instance, fbw_default_args() );
 
 
 
 
 
 
 
 
 
 
110
 
111
  // print the before widget
112
  echo $before_widget;
113
 
114
+ if ( $instance['title'] )
115
+ echo $before_title . $instance['title'] . $after_title;
116
 
117
+ echo fbw_output( $instance );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  // Print the after widget
120
  echo $after_widget;
121
  }
122
 
123
 
 
124
  /**
125
  * Widget update functino
126
  * @since 1.2.1
143
  }
144
 
145
 
 
146
  /**
147
  * Widget form function
148
  * @since 1.2.1
149
  **/
150
  function form( $instance ) {
151
+
152
+ $instance = wp_parse_args( (array) $instance, fbw_default_args() ); // merge the user-selected arguments with the defaults.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  $types = array(
155
  'user' => esc_attr__( 'user', $this->textdomain ),
258
 
259
  <li class="tab-pane <?php if ( $instance['tab'][1] ) : ?>active<?php endif; ?>">
260
  <ul>
261
+ <li>
262
+ <label><?php _e( 'Shortcode & Function', $this->textdomain ) ; ?></label>
263
+ <span class="controlDesc">
264
+ <?php _e( '<strong>Note</strong>: Drag this widget to the "Inactive Widgets" at the bottom of this page if you want to use this as a shortcode to your content or PHP function in your template with the codes above.', $this->textdomain ); ?>
265
+ <span class="shortcode" style="padding: 10px; border: 1px solid #ddd; display: inline-block; margin-top: 10px;">
266
+ <?php _e( 'Widget Shortcode: ', $this->textdomain ); ?><?php echo '[flickr-badge-widget id="' . $this->number . '"]'; ?><br />
267
+ <?php _e( 'PHP Function: ', $this->textdomain ); ?><?php echo '&lt;?php echo do_shortcode(\'[flickr-badge-widget id="' . $this->number . '"]\'); ?&gt;'; ?>
268
+ </span>
269
+ </span>
270
+ </li>
271
  <li>
272
  <label for="<?php echo $this->get_field_id('intro_text'); ?>"><?php _e( 'Intro Text', $this->textdomain ); ?></label>
273
  <span class="controlDesc"><?php _e( 'This option will display addtional text before the widget content and HTML supports.', $this->textdomain ); ?></span>