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.6 11.9 11.9.1 11.9.2 11.9.3 12.0 12.0.1 12.0.2 12.1 12.1.1 12.1.2 12.2 12.2.1 12.2.2 12.3 12.3.1 12.4 12.4.1 12.5 12.5.1 12.6 12.6.1 12.6.2 12.6.3 12.7 12.7.1 12.7.2 12.8 12.8.1 12.8.2 12.9 12.9.1 12.9.2 12.9.3 12.9.4 13.0 13.0.1 13.1 13.1.1 13.1.2 13.1.3 13.1.4 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.3.2 13.4 13.4.1 13.4.2 13.4.3 13.4.4 13.5 13.5.1 13.6 13.6.1 13.7 13.7.1 13.8 13.8.1 13.8.2 13.9 13.9.1 14.0 14.1 14.2 14.2.1 14.3 14.4 14.4.1 14.5 14.6 14.7 14.8 14.9 14.9.1 15.0 15.0.1 15.0.2 15.1 15.1.1 15.2 15.3 15.3.1 15.4 15.5 15.6 15.7 15.7-a.1 15.7-a.3 15.7-a.5 15.7-a.7 15.7-beta
jetpack / modules / widgets / facebook-likebox.php
jetpack / modules / widgets Last commit date
authors 6 months ago contact-info 6 months ago eu-cookie-law 6 months ago facebook-likebox 10 years ago flickr 6 months ago gallery 6 months ago goodreads 6 months ago google-translate 1 year ago image-widget 6 months ago instagram 3 months ago internet-defense-league 1 year ago milestone 3 months ago my-community 6 months ago social-icons 3 months ago social-media-icons 6 months ago top-posts 6 months ago wordpress-post-widget 3 days ago authors.php 6 months ago blog-stats.php 6 months ago class-jetpack-eu-cookie-law-widget.php 1 week ago class-jetpack-instagram-widget.php 5 months ago contact-info.php 1 week ago customizer-controls.css 6 months ago customizer-utils.js 1 year ago facebook-likebox.php 1 week ago flickr.php 6 months ago gallery.php 1 week ago goodreads.php 1 week ago google-translate.php 1 week ago gravatar-profile.css 6 months ago gravatar-profile.php 1 week ago image-widget.php 6 months ago internet-defense-league.php 6 months ago mailchimp.php 6 months ago milestone.php 6 months ago my-community.php 1 week ago rsslinks-widget.php 1 week ago simple-payments.php 6 months ago social-icons.php 2 weeks ago social-media-icons.php 6 months ago top-posts.php 1 week ago twitter-timeline-admin.js 1 year ago twitter-timeline.php 1 week ago upcoming-events.php 6 months ago wordpress-post-widget.php 6 months ago
facebook-likebox.php
458 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2
3 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit( 0 );
7 }
8
9 add_action( 'widgets_init', 'jetpack_facebook_likebox_init' );
10 /**
11 * Register the widget for use in Appearance -> Widgets
12 */
13 function jetpack_facebook_likebox_init() {
14 register_widget( 'WPCOM_Widget_Facebook_LikeBox' );
15 }
16
17 /**
18 * Facebook Page Plugin (formerly known as the Like Box)
19 * Display a Facebook Page Plugin as a widget (replaces the old like box plugin)
20 * https://developers.facebook.com/docs/plugins/page-plugin
21 */
22 class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
23 /**
24 * Default height.
25 *
26 * @var int
27 */
28 private $default_height = 580;
29
30 /**
31 * Default width.
32 *
33 * @var int
34 */
35 private $default_width = 340;
36
37 /**
38 * Max width.
39 *
40 * @var int
41 */
42 private $max_width = 500;
43
44 /**
45 * Min width.
46 *
47 * @var int
48 */
49 private $min_width = 180;
50
51 /**
52 * Max height.
53 *
54 * @var int
55 */
56 private $max_height = 9999;
57
58 /**
59 * Min height/
60 *
61 * @var int
62 */
63 private $min_height = 130;
64
65 /**
66 * WPCOM_Widget_Facebook_LikeBox constructor.
67 */
68 public function __construct() {
69 parent::__construct(
70 'facebook-likebox',
71 /**
72 * Filter the name of a widget included in the Extra Sidebar Widgets module.
73 *
74 * @module widgets
75 *
76 * @since 2.1.2
77 *
78 * @param string $widget_name Widget title.
79 */
80 apply_filters( 'jetpack_widget_name', __( 'Facebook Page Plugin', 'jetpack' ) ),
81 array(
82 'classname' => 'widget_facebook_likebox',
83 'description' => __( 'Use the Facebook Page Plugin to connect visitors to your Facebook Page', 'jetpack' ),
84 'customize_selective_refresh' => true,
85 )
86 );
87
88 if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) {
89 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
90 }
91 }
92
93 /**
94 * Enqueue scripts.
95 */
96 public function enqueue_scripts() {
97 wp_enqueue_script( 'jetpack-facebook-embed' );
98 wp_enqueue_style(
99 'jetpack_facebook_likebox',
100 plugins_url( 'facebook-likebox/style.css', __FILE__ ),
101 array(),
102 JETPACK__VERSION
103 );
104 // Inline styles. @see wp_maybe_inline_styles()
105 wp_style_add_data( 'jetpack_facebook_likebox', 'path', plugin_dir_path( __FILE__ ) . 'facebook-likebox/style.css' );
106 }
107
108 /**
109 * Display the widget.
110 *
111 * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
112 * @param array $instance The settings for the particular instance of the widget.
113 */
114 public function widget( $args, $instance ) {
115 $before_widget = $args['before_widget'] ?? '';
116 $before_title = $args['before_title'] ?? '';
117 $after_title = $args['after_title'] ?? '';
118 $after_widget = $args['after_widget'] ?? '';
119 $like_args = $this->get_default_args();
120
121 if ( isset( $instance['like_args'] ) ) {
122 $like_args = $this->normalize_facebook_args( $instance['like_args'] );
123 }
124
125 if ( empty( $like_args['href'] ) || ! $this->is_valid_facebook_url( $like_args['href'] ) ) {
126 if ( current_user_can( 'edit_theme_options' ) ) {
127 echo $before_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
128
129 $error_link = wp_kses(
130 sprintf(
131 /* translators: %s: link to widgets administration screen. */
132 __( 'It looks like your Facebook URL is incorrectly configured. Please check it in your <a href="%1$s">widget settings</a>.', 'jetpack' ),
133 esc_url( admin_url( 'widgets.php' ) )
134 ),
135 array( 'a' => array( 'href' => array() ) )
136 );
137 printf(
138 '<p>%s</p>',
139 $error_link // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
140 );
141
142 echo $after_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
143 }
144 echo '<!-- Invalid Facebook Page URL -->';
145 return;
146 }
147
148 /** This filter is documented in core/src/wp-includes/default-widgets.php */
149 $title = apply_filters( 'widget_title', $instance['title'] );
150 $page_url = set_url_scheme( $like_args['href'], 'https' );
151
152 $like_args['show_faces'] = (bool) $like_args['show_faces'] ? 'true' : 'false';
153 $like_args['stream'] = (bool) $like_args['stream'] ? 'timeline' : 'false';
154 $like_args['cover'] = (bool) $like_args['cover'] ? 'false' : 'true';
155 $like_args['small_header'] = (bool) $like_args['small_header'] ? 'true' : 'false';
156
157 /**
158 * Filter Facebook Likebox's widget call to action button
159 *
160 * @module widgets
161 *
162 * @since 8.4.0
163 *
164 * @param bool True value hides the call to action button
165 */
166 $hide_cta = apply_filters( 'jetpack_facebook_likebox_hide_cta', false );
167
168 echo $before_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
169
170 if ( ! empty( $title ) ) :
171 echo $before_title; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
172
173 $likebox_widget_title = '<a href="' . esc_url( $page_url ) . '">' . $title . '</a>';
174 /**
175 * Filter Facebook Likebox's widget title.
176 *
177 * @module widgets
178 *
179 * @since 3.3.0
180 *
181 * @param string $likebox_widget_title Likebox Widget title (including a link to the Page URL).
182 * @param string $title Widget title as set in the widget settings.
183 * @param string $page_url Facebook Page URL.
184 */
185 $likebox_widget_title = apply_filters( 'jetpack_facebook_likebox_title', $likebox_widget_title, $title, $page_url );
186
187 echo wp_kses(
188 $likebox_widget_title,
189 array( 'a' => array( 'href' => array() ) )
190 );
191
192 echo $after_title; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
193 endif;
194
195 ?>
196 <div id="fb-root"></div>
197 <div class="fb-page" data-href="<?php echo esc_url( $page_url ); ?>" data-width="<?php echo (int) $like_args['width']; ?>" data-height="<?php echo (int) $like_args['height']; ?>" data-hide-cover="<?php echo esc_attr( $like_args['cover'] ); ?>" data-show-facepile="<?php echo esc_attr( $like_args['show_faces'] ); ?>" data-tabs="<?php echo esc_attr( $like_args['stream'] ); ?>" data-hide-cta="<?php echo esc_attr( $hide_cta ? 'true' : 'false' ); ?>" data-small-header="<?php echo esc_attr( $like_args['small_header'] ); ?>">
198 <div class="fb-xfbml-parse-ignore"><blockquote cite="<?php echo esc_url( $page_url ); ?>"><a href="<?php echo esc_url( $page_url ); ?>"><?php echo esc_html( $title ); ?></a></blockquote></div>
199 </div>
200 <?php
201 wp_enqueue_script( 'jetpack-facebook-embed' );
202
203 echo $after_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
204
205 /** This action is documented in modules/widgets/gravatar-profile.php */
206 do_action( 'jetpack_stats_extra', 'widget_view', 'facebook-likebox' );
207 }
208
209 /**
210 * Update widget.
211 *
212 * @see WP_Widget::update()
213 *
214 * @param array $new_instance New widget instance data.
215 * @param array $old_instance Old widget instance data.
216 */
217 public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
218 $instance = array();
219
220 $instance['title'] = trim( wp_strip_all_tags( stripslashes( $new_instance['title'] ) ) );
221
222 // Set up widget values.
223 $instance['like_args'] = array(
224 'href' => trim( wp_strip_all_tags( stripslashes( $new_instance['href'] ) ) ),
225 'width' => (int) $new_instance['width'],
226 'height' => (int) $new_instance['height'],
227 'show_faces' => isset( $new_instance['show_faces'] ),
228 'stream' => isset( $new_instance['stream'] ),
229 'cover' => isset( $new_instance['cover'] ),
230 'small_header' => isset( $new_instance['small_header'] ),
231 );
232
233 $instance['like_args'] = $this->normalize_facebook_args( $instance['like_args'] );
234
235 // Include the new instance's args in the array's top level to support updating from the Widgets page.
236 $instance = array_merge( $instance, array_intersect_key( $instance['like_args'], $new_instance ) );
237
238 return $instance;
239 }
240
241 /**
242 * Outputs the widget settings form.
243 *
244 * @param array $instance Current settings.
245 * @return string|void
246 */
247 public function form( $instance ) {
248 $instance = wp_parse_args(
249 (array) $instance,
250 array(
251 'title' => '',
252 'like_args' => $this->get_default_args(),
253 )
254 );
255 $like_args = $this->normalize_facebook_args( $instance['like_args'] );
256 ?>
257
258 <p>
259 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
260 <?php esc_html_e( 'Title', 'jetpack' ); ?>
261 <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" />
262 </label>
263 </p>
264
265 <p>
266 <label for="<?php echo esc_attr( $this->get_field_id( 'href' ) ); ?>">
267 <?php esc_html_e( 'Facebook Page URL', 'jetpack' ); ?>
268 <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'href' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'href' ) ); ?>" value="<?php echo esc_url( $like_args['href'] ); ?>" class="widefat" />
269 <br />
270 <small><?php esc_html_e( 'The widget only works with Facebook Pages.', 'jetpack' ); ?></small>
271 </label>
272 </p>
273
274 <p>
275 <label for="<?php echo esc_attr( $this->get_field_id( 'width' ) ); ?>">
276 <?php esc_html_e( 'Width in pixels', 'jetpack' ); ?>
277 <input type="number" class="smalltext" min="<?php echo esc_attr( $this->min_width ); ?>" max="<?php echo esc_attr( $this->max_width ); ?>" maxlength="3" name="<?php echo esc_attr( $this->get_field_name( 'width' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'width' ) ); ?>" value="<?php echo esc_attr( $like_args['width'] ); ?>" style="text-align: center;" />
278 <small>
279 <?php
280 echo esc_html(
281 sprintf(
282 /* translators: %s is the minimum pixel width */
283 __( 'Minimum: %s', 'jetpack' ),
284 $this->min_width
285 )
286 );
287 echo ' / ';
288 echo esc_html(
289 sprintf(
290 /* translators: %s is the maximum pixel width */
291 __( 'Maximum: %s', 'jetpack' ),
292 $this->max_width
293 )
294 );
295 ?>
296 </small>
297 </label>
298 </p>
299
300 <p>
301 <label for="<?php echo esc_attr( $this->get_field_id( 'height' ) ); ?>">
302 <?php esc_html_e( 'Height in pixels', 'jetpack' ); ?>
303 <input type="number" class="smalltext" min="<?php echo esc_attr( $this->min_height ); ?>" max="<?php echo esc_attr( $this->max_height ); ?>" maxlength="3" name="<?php echo esc_attr( $this->get_field_name( 'height' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'height' ) ); ?>" value="<?php echo esc_attr( $like_args['height'] ); ?>" style="text-align: center;" />
304 <small>
305 <?php
306 echo esc_html(
307 sprintf(
308 /* translators: %s is the minimum pixel height */
309 __( 'Minimum: %s', 'jetpack' ),
310 $this->min_height
311 )
312 );
313 echo ' / ';
314 echo esc_html(
315 sprintf(
316 /* translators: %s is the maximum pixel height */
317 __( 'Maximum: %s', 'jetpack' ),
318 $this->max_height
319 )
320 );
321 ?>
322 </small>
323 </label>
324 </p>
325
326 <p>
327 <label for="<?php echo esc_attr( $this->get_field_id( 'show_faces' ) ); ?>">
328 <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_faces' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_faces' ) ); ?>" <?php checked( $like_args['show_faces'] ); ?> />
329 <?php esc_html_e( 'Show Faces', 'jetpack' ); ?>
330 <br />
331 <small><?php esc_html_e( 'Show profile photos in the plugin.', 'jetpack' ); ?></small>
332 </label>
333 </p>
334
335 <p>
336 <label for="<?php echo esc_attr( $this->get_field_id( 'stream' ) ); ?>">
337 <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'stream' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'stream' ) ); ?>" <?php checked( $like_args['stream'] ); ?> />
338 <?php esc_html_e( 'Show Timeline', 'jetpack' ); ?>
339 <br />
340 <small><?php esc_html_e( 'Show Page Posts.', 'jetpack' ); ?></small>
341 </label>
342 </p>
343
344 <p>
345 <label for="<?php echo esc_attr( $this->get_field_id( 'cover' ) ); ?>">
346 <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'cover' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'cover' ) ); ?>" <?php checked( $like_args['cover'] ); ?> />
347 <?php esc_html_e( 'Show Cover Photo', 'jetpack' ); ?>
348 <br />
349 </label>
350 </p>
351
352 <p>
353 <label for="<?php echo esc_attr( $this->get_field_id( 'small_header' ) ); ?>">
354 <input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'small_header' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'small_header' ) ); ?>" <?php checked( $like_args['small_header'] ); ?> />
355 <?php esc_html_e( 'Use Small Header', 'jetpack' ); ?>
356 <br />
357 </label>
358 </p>
359
360 <?php
361 }
362
363 /**
364 * Facebook Likebox default options.
365 */
366 public function get_default_args() {
367 $defaults = array(
368 'href' => '',
369 'width' => $this->default_width,
370 'height' => $this->default_height,
371 'show_faces' => 'true',
372 'stream' => '',
373 'cover' => 'true',
374 'small_header' => '',
375 );
376
377 /**
378 * Filter Facebook Likebox default options.
379 *
380 * @module widgets
381 *
382 * @since 1.3.1
383 *
384 * @param array $defaults Array of default options.
385 */
386 return apply_filters( 'jetpack_facebook_likebox_defaults', $defaults );
387 }
388
389 /**
390 * Normalize the Facebook Likebox options.
391 *
392 * @param array $args Array of arguments.
393 */
394 public function normalize_facebook_args( $args ) {
395 $args = wp_parse_args( (array) $args, $this->get_default_args() );
396
397 // Validate the Facebook Page URL.
398 if ( $this->is_valid_facebook_url( $args['href'] ) ) {
399 $temp = explode( '?', $args['href'] );
400 $args['href'] = str_replace( array( 'http://facebook.com', 'https://facebook.com' ), array( 'http://www.facebook.com', 'https://www.facebook.com' ), $temp[0] );
401 } else {
402 $args['href'] = '';
403 }
404
405 $args['width'] = $this->normalize_int_value( (int) $args['width'], $this->max_width, $this->min_width );
406 $args['height'] = $this->normalize_int_value( (int) $args['height'], $this->max_height, $this->min_height );
407 $args['show_faces'] = (bool) $args['show_faces'];
408 $args['stream'] = (bool) $args['stream'];
409 $args['cover'] = (bool) $args['cover'];
410 $args['small_header'] = (bool) $args['small_header'];
411
412 // The height used to be dependent on other widget settings
413 // If the user changes those settings but doesn't customize the height,
414 // let's intelligently assign a new height.
415 if ( in_array( $args['height'], array( 580, 110, 432 ), true ) ) {
416 if ( $args['show_faces'] && $args['stream'] ) {
417 $args['height'] = 580;
418 } elseif ( ! $args['show_faces'] && ! $args['stream'] ) {
419 $args['height'] = 130;
420 } else {
421 $args['height'] = 432;
422 }
423 }
424
425 return $args;
426 }
427
428 /**
429 * Check if URL is a valid Facebook Page URL.
430 *
431 * @param string $url URL to check.
432 */
433 public function is_valid_facebook_url( $url ) {
434 return str_contains( $url, 'facebook.com' );
435 }
436
437 /**
438 * Normalize an integer value within a given range.
439 *
440 * @param int $value Value to normalize.
441 * @param int $max Maximum value.
442 * @param int $min Minimum value.
443 *
444 * @return int Normalized value.
445 */
446 public function normalize_int_value( $value, $max = 0, $min = 0 ) {
447 $value = (int) $value;
448
449 if ( $value > $max ) {
450 $value = $max;
451 } elseif ( $value < $min ) {
452 $value = $min;
453 }
454
455 return (int) $value;
456 }
457 }
458