PluginProbe ʕ •ᴥ•ʔ
Ocean Extra / 2.5.7
Ocean Extra v2.5.7
2.5.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.4.1 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.0.1 1.2.1 1.2.1.1 1.2.1.2 1.2.10 1.2.2 1.2.2.1 1.2.2.2 1.2.2.3 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 1.4.17 1.4.18 1.4.19 1.4.2 1.4.20 1.4.21 1.4.22 1.4.23 1.4.24 1.4.25 1.4.26 1.4.27 1.4.28 1.4.29 1.4.3 1.4.30 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.20 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6
ocean-extra / includes / widgets / flickr.php
ocean-extra / includes / widgets Last commit date
js 1 year ago about-me.php 2 years ago contact-info.php 5 years ago custom-header-logo.php 6 years ago custom-header-nav.php 6 years ago custom-links.php 4 years ago custom-menu.php 6 years ago facebook.php 2 years ago flickr.php 1 day ago instagram.php 3 years ago mailchimp.php 2 years ago recent-posts.php 4 years ago social-share.php 9 months ago social.php 2 years ago tags.php 6 years ago twitter.php 2 years ago video.php 6 years ago
flickr.php
164 lines
1 <?php
2 /**
3 * Flickr Widget.
4 *
5 * @package OceanWP WordPress theme
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 if ( ! class_exists( 'Ocean_Extra_Flickr_Widget' ) ) {
14 class Ocean_Extra_Flickr_Widget extends WP_Widget {
15
16 /**
17 * Register widget with WordPress.
18 *
19 * @since 1.0.0
20 */
21 public function __construct() {
22 parent::__construct(
23 'ocean_flickr',
24 esc_html__( '&raquo; Flickr', 'ocean-extra' ),
25 array(
26 'classname' => 'widget-oceanwp-flickr flickr-widget',
27 'description' => esc_html__( 'Pulls in images from your flickr account.', 'ocean-extra' ),
28 'customize_selective_refresh' => true,
29 )
30 );
31 }
32
33 /**
34 * Front-end display of widget.
35 *
36 * @see WP_Widget::widget()
37 *
38 * @param array $args Widget arguments.
39 * @param array $instance Saved values from database.
40 */
41 public function widget( $args, $instance ) {
42
43 $this->enqueue_scripts();
44
45 $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
46 $number = isset( $instance['number'] ) ? intval( $instance['number'] ) : '';
47 $id = isset( $instance['id'] ) ? sanitize_text_field( $instance['id'] ) : '';
48
49
50 echo $args['before_widget'];
51
52 if ( ! empty( $instance['title'] ) ) {
53 echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
54 }
55
56 $unique_id = 'oceanwp_flickr_photos_' . uniqid() . '_' . md5(rand());
57
58 if ( $id ) : ?>
59 <div class="oceanwp-flickr-wrap">
60 <div id="<?php echo $unique_id; ?>" class="oceanwp-flickr-container" data-user-id="<?php echo esc_attr( $id ); ?>" data-max-photos="<?php echo intval( $number ); ?>"></div>
61 <p class="flickr_stream_wrap"><a class="follow_btn" href="http://www.flickr.com/photos/<?php echo esc_attr(strip_tags($id)); ?>"><?php esc_html_e( 'View stream on flickr', 'ocean-extra' ); ?></a></p>
62 </div>
63 <?php
64 endif;
65
66 echo $args['after_widget'];
67
68
69 }
70
71 /**
72 * Sanitize widget form values as they are saved.
73 *
74 * @see WP_Widget::update()
75 * @since 1.0.0
76 *
77 * @param array $new_instance Values just sent to be saved.
78 * @param array $old_instance Previously saved values from database.
79 *
80 * @return array Updated safe values to be saved.
81 */
82 public function update( $new_instance, $old_instance ) {
83 $instance = $old_instance;
84 $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : '';
85 $instance['number'] = ! empty( $new_instance['number'] ) ? intval( $new_instance['number'] ) : '';
86 $instance['id'] = ! empty( $new_instance['id'] ) ? sanitize_text_field( $new_instance['id'] ) : '';
87 return $instance;
88 }
89
90 /**
91 * Back-end widget form.
92 *
93 * @see WP_Widget::form()
94 * @since 1.0.0
95 *
96 * @param array $instance Previously saved values from database.
97 */
98 public function form( $instance ) {
99 $settings = wp_parse_args(
100 (array) $instance,
101 array(
102 'title' => esc_attr__( 'Flickr Photos', 'ocean-extra' ),
103 'id' => '73064996@N08',
104 'number' => 6,
105 )
106 );
107
108 $title = esc_attr( $settings['title'] );
109 $id = esc_attr( $settings['id'] );
110 $number = intval( $settings['number'] );
111
112 ?>
113 <p>
114 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</label>
115 <input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
116 </p>
117
118 <p>
119 <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Flickr ID', 'ocean-extra' ); ?></label>
120 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" type="text" value="<?php echo esc_attr( $id ); ?>" />
121 <small><?php esc_html_e( 'Enter the url of your Flickr page on this site: idgettr.com.', 'ocean-extra' ); ?></small>
122 </p>
123
124 <p>
125 <label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number:', 'ocean-extra' ); ?></label>
126 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="number" value="<?php echo esc_attr( $number ); ?>" />
127 <small><?php esc_html_e( 'The maximum is 10 images.', 'ocean-extra' ); ?></small>
128 </p>
129
130 <?php
131
132 }
133
134 /**
135 * Scripts
136 */
137 public function enqueue_scripts() {
138
139 if ( wp_script_is( 'flickr-widget-script', 'enqueued' ) ) {
140 return;
141 }
142
143 wp_enqueue_script( 'flickr-widget-script', OE_URL . 'includes/widgets/js/flickr.min.js', array( 'jquery' ), false, true );
144
145 $widgets_settings = $this->get_settings();
146 $localized_data = array();
147
148 foreach ( $widgets_settings as $number => $instance ) {
149 $localized_data[] = array(
150 'userId' => ! empty( $instance['id'] ) ? esc_attr( $instance['id'] ) : '',
151 'maxPhotos' => ! empty( $instance['number'] ) ? intval( $instance['number'] ) : 6,
152 'containerId' => 'oceanwp-flickr-photos-' . esc_attr( $number ),
153 );
154 }
155
156 wp_localize_script( 'flickr-widget-script', 'flickrWidgetParams', array(
157 'widgets' => $localized_data,
158 ));
159 }
160
161 }
162 }
163 register_widget( 'Ocean_Extra_Flickr_Widget' );
164