diff --git a/bin/phpcs-whitelist.js b/bin/phpcs-whitelist.js index 555f217197a7d..04d3c4929ed31 100644 --- a/bin/phpcs-whitelist.js +++ b/bin/phpcs-whitelist.js @@ -23,6 +23,7 @@ module.exports = [ 'modules/sitemaps/sitemaps.php', 'modules/theme-tools/social-menu/', 'modules/verification-tools.php', + 'modules/widgets/social-icons.php', 'modules/wpcom-block-editor/class-jetpack-wpcom-block-editor.php', 'packages', ]; diff --git a/modules/widgets/social-icons.php b/modules/widgets/social-icons.php index 7a323ed150772..bea4a14720b01 100644 --- a/modules/widgets/social-icons.php +++ b/modules/widgets/social-icons.php @@ -1,6 +1,12 @@ - + ?> - id_base ); - echo $args['before_widget']; + echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( ! empty( $title ) ) { - echo $args['before_title'] . esc_html( $title ) . $args['after_title']; + echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } if ( ! empty( $instance['icons'] ) ) : @@ -118,13 +135,13 @@ public function widget( $args, $instance ) { $social_icons = $this->get_supported_icons(); $default_icon = $this->get_svg_icon( array( 'icon' => 'chain' ) ); - // Set target attribute for the link + // Set target attribute for the link. if ( true === $instance['new-tab'] ) { $target = '_blank'; } else { $target = '_self'; } - ?> + ?> - defaults['icon-size']; - if ( in_array( $new_instance['icon-size'], array( 'small', 'medium', 'large' ) ) ) { + if ( in_array( $new_instance['icon-size'], array( 'small', 'medium', 'large' ), true ) ) { $instance['icon-size'] = $new_instance['icon-size']; } $instance['new-tab'] = isset( $new_instance['new-tab'] ) ? (bool) $new_instance['new-tab'] : false; - $icon_count = count( $new_instance['url-icons'] ); $instance['icons'] = array(); foreach ( $new_instance['url-icons'] as $url ) { @@ -222,13 +250,13 @@ public function form( $instance ) { ?>

- - + +

- - $label ) : ?> @@ -236,8 +264,8 @@ public function form( $instance ) {

- /> - + /> +

- '', 'url-icon-name' => '', @@ -388,277 +416,256 @@ public function get_svg_icon( $args = array() ) { public function get_supported_icons() { $social_links_icons = array( array( - 'url' => '500px.com', + 'url' => array( '500px.com' ), 'icon' => '500px', 'label' => '500px', ), array( - 'url' => 'amazon.cn', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.in', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.fr', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.de', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.it', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.nl', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.es', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.co', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.ca', - 'icon' => 'amazon', - 'label' => 'Amazon', - ), - array( - 'url' => 'amazon.com', + 'url' => array( + 'amazon.cn', + 'amazon.in', + 'amazon.fr', + 'amazon.de', + 'amazon.it', + 'amazon.nl', + 'amazon.es', + 'amazon.co', + 'amazon.ca', + 'amazon.com', + ), 'icon' => 'amazon', 'label' => 'Amazon', ), array( - 'url' => 'apple.com', + 'url' => array( 'apple.com' ), 'icon' => 'apple', 'label' => 'Apple', ), array( - 'url' => 'itunes.com', + 'url' => array( 'itunes.com' ), 'icon' => 'apple', 'label' => 'iTunes', ), array( - 'url' => 'bandcamp.com', + 'url' => array( 'bandcamp.com' ), 'icon' => 'bandcamp', 'label' => 'Bandcamp', ), array( - 'url' => 'behance.net', + 'url' => array( 'behance.net' ), 'icon' => 'behance', 'label' => 'Behance', ), array( - 'url' => 'codepen.io', + 'url' => array( 'codepen.io' ), 'icon' => 'codepen', 'label' => 'CodePen', ), array( - 'url' => 'deviantart.com', + 'url' => array( 'deviantart.com' ), 'icon' => 'deviantart', 'label' => 'DeviantArt', ), array( - 'url' => 'digg.com', + 'url' => array( 'digg.com' ), 'icon' => 'digg', 'label' => 'Digg', ), array( - 'url' => 'discord.gg', - 'icon' => 'discord', - 'label' => 'Discord', - ), - array( - 'url' => 'discordapp.com', + 'url' => array( 'discord.gg', 'discordapp.com' ), 'icon' => 'discord', 'label' => 'Discord', ), array( - 'url' => 'dribbble.com', + 'url' => array( 'dribbble.com' ), 'icon' => 'dribbble', 'label' => 'Dribbble', ), array( - 'url' => 'dropbox.com', + 'url' => array( 'dropbox.com' ), 'icon' => 'dropbox', 'label' => 'Dropbox', ), array( - 'url' => 'etsy.com', + 'url' => array( 'etsy.com' ), 'icon' => 'etsy', 'label' => 'Etsy', ), array( - 'url' => 'facebook.com', + 'url' => array( 'facebook.com' ), 'icon' => 'facebook', 'label' => 'Facebook', ), array( - 'url' => '/feed/', + 'url' => array( + '/feed/', // WordPress default feed url. + '/feeds/', // Blogspot and others. + '/blog/feed', // No trailing slash WordPress feed, could use /feed but may match unexpectedly. + 'format=RSS', // Squarespace and others. + '/rss', // Tumblr. + '/.rss', // Reddit. + '/rss.xml', // Moveable Type, Typepad. + 'http://rss.', // Old custom format. + 'https://rss.', // Old custom format. + 'rss=1', + '/feed=rss', // Catches feed=rss / feed=rss2. + '?feed=rss', // WordPress non-permalink - Catches feed=rss / feed=rss2. + '?feed=rdf', // WordPress non-permalink. + '?feed=atom', // WordPress non-permalink. + 'http://feeds.', // FeedBurner. + 'https://feeds.', // FeedBurner. + '/feed.xml', // Feedburner Alias, and others. + '/index.xml', // Moveable Type, and others. + '/atom.xml', // Typepad, Squarespace. + '.atom', // Shopify blog. + '/atom', // Some non-WordPress feeds. + 'index.rdf', // Typepad. + ), 'icon' => 'feed', 'label' => __( 'RSS Feed', 'jetpack' ), ), array( - 'url' => 'flickr.com', + 'url' => array( 'flickr.com' ), 'icon' => 'flickr', 'label' => 'Flickr', ), array( - 'url' => 'foursquare.com', + 'url' => array( 'foursquare.com' ), 'icon' => 'foursquare', 'label' => 'Foursquare', ), array( - 'url' => 'goodreads.com', + 'url' => array( 'goodreads.com' ), 'icon' => 'goodreads', 'label' => 'Goodreads', ), array( - 'url' => 'google.com', + 'url' => array( 'google.com', 'google.co.uk', 'google.ca', 'google.cn', 'google.it' ), 'icon' => 'google', 'label' => 'Google', ), array( - 'url' => 'github.com', + 'url' => array( 'github.com' ), 'icon' => 'github', 'label' => 'GitHub', ), array( - 'url' => 'instagram.com', + 'url' => array( 'instagram.com' ), 'icon' => 'instagram', 'label' => 'Instagram', ), array( - 'url' => 'linkedin.com', + 'url' => array( 'linkedin.com' ), 'icon' => 'linkedin', 'label' => 'LinkedIn', ), array( - 'url' => 'mailto:', + 'url' => array( 'mailto:' ), 'icon' => 'mail', 'label' => __( 'Email', 'jetpack' ), ), array( - 'url' => 'meetup.com', + 'url' => array( 'meetup.com' ), 'icon' => 'meetup', 'label' => 'Meetup', ), array( - 'url' => 'medium.com', + 'url' => array( 'medium.com' ), 'icon' => 'medium', 'label' => 'Medium', ), array( - 'url' => 'pinterest.', + 'url' => array( 'pinterest.' ), 'icon' => 'pinterest', 'label' => 'Pinterest', ), array( - 'url' => 'getpocket.com', + 'url' => array( 'getpocket.com' ), 'icon' => 'pocket', 'label' => 'Pocket', ), array( - 'url' => 'reddit.com', + 'url' => array( 'reddit.com' ), 'icon' => 'reddit', 'label' => 'Reddit', ), array( - 'url' => 'skype.com', + 'url' => array( 'skype.com' ), 'icon' => 'skype', 'label' => 'Skype', ), array( - 'url' => 'skype:', + 'url' => array( 'skype:' ), 'icon' => 'skype', 'label' => 'Skype', ), array( - 'url' => 'slideshare.net', + 'url' => array( 'slideshare.net' ), 'icon' => 'slideshare', 'label' => 'SlideShare', ), array( - 'url' => 'snapchat.com', + 'url' => array( 'snapchat.com' ), 'icon' => 'snapchat', 'label' => 'Snapchat', ), array( - 'url' => 'soundcloud.com', + 'url' => array( 'soundcloud.com' ), 'icon' => 'soundcloud', 'label' => 'SoundCloud', ), array( - 'url' => 'spotify.com', + 'url' => array( 'spotify.com' ), 'icon' => 'spotify', 'label' => 'Spotify', ), array( - 'url' => 'stackoverflow.com', + 'url' => array( 'stackoverflow.com' ), 'icon' => 'stackoverflow', 'label' => 'Stack Overflow', ), array( - 'url' => 'stumbleupon.com', + 'url' => array( 'stumbleupon.com' ), 'icon' => 'stumbleupon', 'label' => 'StumbleUpon', ), array( - 'url' => 'tumblr.com', + 'url' => array( 'tumblr.com' ), 'icon' => 'tumblr', 'label' => 'Tumblr', ), array( - 'url' => 'twitch.tv', + 'url' => array( 'twitch.tv' ), 'icon' => 'twitch', 'label' => 'Twitch', ), array( - 'url' => 'twitter.com', + 'url' => array( 'twitter.com' ), 'icon' => 'twitter', 'label' => 'Twitter', ), array( - 'url' => 'vimeo.com', + 'url' => array( 'vimeo.com' ), 'icon' => 'vimeo', 'label' => 'Vimeo', ), array( - 'url' => 'vk.com', + 'url' => array( 'vk.com' ), 'icon' => 'vk', 'label' => 'VK', ), array( - 'url' => 'wordpress.com', - 'icon' => 'wordpress', - 'label' => 'WordPress.com', - ), - array( - 'url' => 'wordpress.org', + 'url' => array( 'wordpress.com', 'wordpress.org' ), 'icon' => 'wordpress', 'label' => 'WordPress', ), array( - 'url' => 'yelp.com', + 'url' => array( 'yelp.com' ), 'icon' => 'yelp', 'label' => 'Yelp', ), array( - 'url' => 'youtube.com', + 'url' => array( 'youtube.com' ), 'icon' => 'youtube', 'label' => 'YouTube', ),