|
1 <?php |
|
2 |
|
3 /* |
|
4 |
|
5 Plugin Name: Flickr Widget |
|
6 Description: Plugin is used for Flickr pictures. |
|
7 Author: |
|
8 Version: 1.0 |
|
9 Author URI: |
|
10 |
|
11 */ |
|
12 |
|
13 class flickr_widget extends WP_Widget { |
|
14 |
|
15 |
|
16 /*-----------------------------------------------------------------------------------*/ |
|
17 /* Widget Setup |
|
18 /*-----------------------------------------------------------------------------------*/ |
|
19 |
|
20 function flickr_Widget() { |
|
21 |
|
22 $widget_options = array( |
|
23 'classname' => 'flickr_widget', |
|
24 'description' => 'Custom Flickr widget.'); |
|
25 |
|
26 $control_options = array( //dodama svoje incializirane mere |
|
27 'width' => 200, |
|
28 'height' => 400, |
|
29 'id_base' => 'flickr_widget' |
|
30 ); |
|
31 |
|
32 $this->WP_Widget( 'flickr_widget', 'Flickr Widget', $widget_options, $control_options ); |
|
33 |
|
34 } |
|
35 |
|
36 |
|
37 |
|
38 function widget( $args, $instance ) { |
|
39 |
|
40 extract( $args ); |
|
41 $title = apply_filters('widget_title', $instance['title'] ); |
|
42 $username = $instance['username']; |
|
43 $pics_number = $instance['pics_number']; |
|
44 |
|
45 echo $before_widget; |
|
46 |
|
47 if ( $title ) |
|
48 { |
|
49 echo $before_title; |
|
50 echo $title; |
|
51 echo $after_title; |
|
52 } |
|
53 |
|
54 ?> |
|
55 |
|
56 <div id="flickr_badge_wrapper"> |
|
57 <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?show_name=1&count=<?php echo $pics_number; ?>&display=latest&size=s&layout=x&source=user&user=<?php echo $username; ?>"></script> |
|
58 </div> |
|
59 <div class="clear"></div><?php |
|
60 echo $after_widget; |
|
61 |
|
62 } |
|
63 |
|
64 |
|
65 function form( $instance ) { |
|
66 |
|
67 /* Set default values. */ |
|
68 $defaults = array( |
|
69 'title' => 'Flickr Widget', |
|
70 'username' => '62421008@N06', |
|
71 'pics_number' => '9' |
|
72 ); |
|
73 $instance = wp_parse_args( (array) $instance, $defaults ); |
|
74 |
|
75 ?> |
|
76 |
|
77 <label for="<?php echo $this->get_field_id( 'title' ); ?>"> |
|
78 <?php _e('Title:','pego_tr'); ?> |
|
79 <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" |
|
80 name="<?php echo $this->get_field_name( 'title' ); ?>" |
|
81 value="<?php echo $instance['title']; ?>" /> |
|
82 </label> |
|
83 |
|
84 <label for="<?php echo $this->get_field_id( 'username' ); ?>"> |
|
85 <?php _e('Flickr username:','pego_tr'); ?> |
|
86 <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'username' ); ?>" |
|
87 name="<?php echo $this->get_field_name( 'username' ); ?>" |
|
88 value="<?php echo $instance['username']; ?>" /> |
|
89 </label> |
|
90 |
|
91 <?php _e('Number of pictures:','pego_tr'); ?> |
|
92 <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'pics_number' ); ?>" |
|
93 name="<?php echo $this->get_field_name( 'pics_number' ); ?>" |
|
94 value="<?php echo $instance['pics_number']; ?>" /> |
|
95 </label> |
|
96 |
|
97 |
|
98 <?php |
|
99 } |
|
100 } |
|
101 |
|
102 |
|
103 /* Adding widget to widgets_init and registering flickr widget */ |
|
104 add_action( 'widgets_init', 'flickr_widgets' ); |
|
105 |
|
106 function flickr_widgets() { |
|
107 register_widget( 'flickr_Widget' ); |
|
108 } |
|
109 ?> |