PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | modules/widgets/social-icons.php +55 -40 12.7.3 → 16.3-a.1 View file →
@@ -1,6 +1,10 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit( 0 );
5 +}
6 +
3 7 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
4 8
5 9 /**
6 10 * Social Icons Widget.
@@ -52,14 +56,8 @@
52 56 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
53 57 add_action( 'admin_print_footer_scripts', array( $this, 'render_admin_js' ) );
54 58 }
55 59
56 - // Enqueue scripts and styles for the display of the widget, on the frontend or in the customizer.
57 - if ( is_active_widget( false, $this->id, $this->id_base, true ) || is_customize_preview() ) {
58 - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_icon_scripts' ) );
59 - add_action( 'wp_footer', array( $this, 'include_svg_icons' ), 9999 );
60 - }
61 -
62 60 add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) );
63 61 }
64 62
65 63 /**
@@ -115,18 +113,39 @@
115 113 */
116 114 public function include_svg_icons() {
117 115 // Define SVG sprite file in Jetpack.
118 116 $svg_icons = dirname( __DIR__ ) . '/theme-tools/social-menu/social-menu.svg';
119 -
117 + $svg_icons = class_exists( 'Automattic\Jetpack\Classic_Theme_Helper\Main' ) ? JETPACK__PLUGIN_DIR . 'jetpack_vendor/automattic/jetpack-classic-theme-helper/src/social-menu/social-menu.svg' : dirname( __DIR__ ) . '/theme-tools/social-menu/social-menu.svg';
120 118 // Define SVG sprite file in WPCOM.
121 119 if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
122 - $svg_icons = dirname( __DIR__ ) . '/social-menu/social-menu.svg';
120 + $svg_icons = class_exists( 'Automattic\Jetpack\Classic_Theme_Helper\Main' ) ? JETPACK__PLUGIN_DIR . 'jetpack_vendor/automattic/jetpack-classic-theme-helper/src/social-menu/social-menu.svg' : dirname( __DIR__ ) . '/social-menu/social-menu.svg';
123 121 }
124 122
125 123 // If it exists, include it.
126 124 if ( is_file( $svg_icons ) ) {
127 - require_once $svg_icons;
125 + $svg_contents = file_get_contents( $svg_icons ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Only reading a local file.
128 126 }
127 +
128 + if ( ! empty( $svg_contents ) ) {
129 + $allowed_tags = array(
130 + 'svg' => array(
131 + 'style' => true,
132 + 'version' => true,
133 + 'xmlns' => true,
134 + 'xmlns:xlink' => true,
135 + ),
136 + 'defs' => array(),
137 + 'symbol' => array(
138 + 'id' => true,
139 + 'viewbox' => true,
140 + ),
141 + 'path' => array(
142 + 'd' => true,
143 + 'style' => true,
144 + ),
145 + );
146 + echo wp_kses( $svg_contents, $allowed_tags );
147 + }
129 148 }
130 149
131 150 /**
132 151 * Front-end display of widget.
@@ -138,8 +157,12 @@
138 157 */
139 158 public function widget( $args, $instance ) {
140 159 $instance = wp_parse_args( $instance, $this->defaults );
141 160
161 + // Enqueue front end assets.
162 + $this->enqueue_icon_scripts();
163 + add_action( 'wp_footer', array( $this, 'include_svg_icons' ), 9999 );
164 +
142 165 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
143 166 $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
144 167
145 168 echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -164,9 +187,9 @@
164 187 <li class="jetpack-social-widget-item">
165 188 <?php
166 189 printf(
167 190 '<a href="%1$s" %2$s>',
168 - esc_url( $icon['url'], array( 'http', 'https', 'mailto', 'skype' ) ),
191 + esc_url( $icon['url'], array( 'http', 'https', 'mailto', 'sms' ) ),
169 192 true === $instance['new-tab'] ?
170 193 'target="_blank" rel="noopener noreferrer"' :
171 194 'target="_self"'
172 195 );
@@ -181,13 +204,13 @@
181 204 */
182 205 if (
183 206 // First Regex.
184 207 (
185 - '#' === substr( $url_fragment, 0, 1 ) && '#' === substr( $url_fragment, -1 )
208 + str_starts_with( $url_fragment, '#' ) && str_ends_with( $url_fragment, '#' )
186 209 && preg_match( $url_fragment, $icon['url'] )
187 210 )
188 211 // Then, regular host name.
189 - || false !== strpos( $icon['url'], $url_fragment )
212 + || str_contains( $icon['url'], $url_fragment )
190 213 ) {
191 214 printf(
192 215 '<span class="screen-reader-text">%1$s</span>%2$s',
193 216 esc_attr( $social_icon['label'] ),
@@ -323,19 +346,21 @@
323 346 </button>
324 347 </p>
325 348
326 349 <?php
327 - switch ( get_locale() ) {
350 + $lang = strtolower( substr( get_locale(), 0, 2 ) );
351 + switch ( $lang ) {
328 352 case 'es':
329 - $support = 'https://es.support.wordpress.com/social-media-icons-widget/#iconos-disponibles';
353 + $support = 'https://wordpress.com/es/support/wordpress-editor/blocks/social-icons-block/display-social-profiles/#iconos-sociales-compatibles';
330 354 break;
331 355
332 - case 'pt-br':
333 - $support = 'https://br.support.wordpress.com/widgets/widget-de-icones-sociais/#ícones-disponíveis';
356 + case 'pt':
357 + $support = 'https://wordpress.com/pt-br/support/exibir-perfis-de-redes-sociais/#icones-de-redes-sociais-compativeis';
334 358 break;
335 359
336 360 default:
337 - $support = 'https://en.support.wordpress.com/widgets/social-media-icons-widget/#available-icons';
361 + $support = 'https://wordpress.com/support/wordpress-editor/blocks/social-icons-block/display-social-profiles/#supported-social-icons';
362 + break;
338 363 }
339 364 ?>
340 365
341 366 <p>
@@ -377,9 +402,9 @@
377 402 '<input class="widefat" id="%1$s" name="%2$s[]" type="text" placeholder="%3$s" value="%4$s"/>',
378 403 esc_attr( $args['url-icon-id'] ),
379 404 esc_attr( $args['url-icon-name'] ),
380 405 esc_attr__( 'Account URL', 'jetpack' ),
381 - esc_url( $args['url-value'], array( 'http', 'https', 'mailto', 'skype' ) )
406 + esc_url( $args['url-value'], array( 'http', 'https', 'mailto', 'sms' ) )
382 407 );
383 408 ?>
384 409 </p>
385 410
@@ -418,9 +443,9 @@
418 443 // Parse args.
419 444 $args = wp_parse_args( $args, $defaults );
420 445
421 446 // Define an icon.
422 - if ( false === array_key_exists( 'icon', $args ) ) {
447 + if ( ! array_key_exists( 'icon', $args ) ) {
423 448 return esc_html__( 'Please define an SVG icon filename.', 'jetpack' );
424 449 }
425 450
426 451 // Set aria hidden.
@@ -490,8 +515,13 @@
490 515 'icon' => 'blogger',
491 516 'label' => 'Blogger',
492 517 ),
493 518 array(
519 + 'url' => array( 'bsky.app' ),
520 + 'icon' => 'bluesky',
521 + 'label' => 'Bluesky',
522 + ),
523 + array(
494 524 'url' => array( 'codepen.io' ),
495 525 'icon' => 'codepen',
496 526 'label' => 'CodePen',
497 527 ),
@@ -610,13 +640,8 @@
610 640 'icon' => 'pinterest',
611 641 'label' => 'Pinterest',
612 642 ),
613 643 array(
614 - 'url' => array( 'getpocket.com' ),
615 - 'icon' => 'pocket',
616 - 'label' => 'Pocket',
617 - ),
618 - array(
619 644 'url' => array( 'ravelry.com' ),
620 645 'icon' => 'ravelry',
621 646 'label' => 'Ravelry',
622 647 ),
@@ -625,23 +650,18 @@
625 650 'icon' => 'reddit',
626 651 'label' => 'Reddit',
627 652 ),
628 653 array(
629 - 'url' => array( 'skype.com' ),
630 - 'icon' => 'skype',
631 - 'label' => 'Skype',
632 - ),
633 - array(
634 - 'url' => array( 'skype:' ),
635 - 'icon' => 'skype',
636 - 'label' => 'Skype',
637 - ),
638 - array(
639 654 'url' => array( 'slideshare.net' ),
640 655 'icon' => 'slideshare',
641 656 'label' => 'SlideShare',
642 657 ),
643 658 array(
659 + 'url' => array( 'sms:' ),
660 + 'icon' => 'sms',
661 + 'label' => 'SMS',
662 + ),
663 + array(
644 664 'url' => array( 'snapchat.com' ),
645 665 'icon' => 'snapchat',
646 666 'label' => 'Snapchat',
647 667 ),
@@ -695,13 +715,8 @@
695 715 'icon' => 'twitch',
696 716 'label' => 'Twitch',
697 717 ),
698 718 array(
699 - 'url' => array( 'twitter.com' ),
700 - 'icon' => 'twitter',
701 - 'label' => 'Twitter',
702 - ),
703 - array(
704 719 'url' => array( 'vimeo.com' ),
705 720 'icon' => 'vimeo',
706 721 'label' => 'Vimeo',
707 722 ),
@@ -730,9 +745,9 @@
730 745 'icon' => 'yelp',
731 746 'label' => 'Yelp',
732 747 ),
733 748 array(
734 - 'url' => array( 'x.com' ),
749 + 'url' => array( '#^https?:\/\/(www\.)?(twitter|x)\.com#' ),
735 750 'icon' => 'x',
736 751 'label' => 'X',
737 752 ),
738 753 array(