No Description

social-icons.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
  2. /**
  3. * Social Icons Widget.
  4. */
  5. class Jetpack_Widget_Social_Icons extends WP_Widget {
  6. /**
  7. * Default widget options.
  8. *
  9. * @var array Default widget options.
  10. */
  11. protected $defaults;
  12. /**
  13. * Widget constructor.
  14. */
  15. public function __construct() {
  16. global $pagenow;
  17. $widget_ops = array(
  18. 'classname' => 'jetpack_widget_social_icons',
  19. 'description' => __( 'Add social-media icons to your site.', 'jetpack' ),
  20. 'customize_selective_refresh' => true,
  21. );
  22. parent::__construct(
  23. 'jetpack_widget_social_icons',
  24. /** This filter is documented in modules/widgets/facebook-likebox.php */
  25. apply_filters( 'jetpack_widget_name', __( 'Social Icons', 'jetpack' ) ),
  26. $widget_ops
  27. );
  28. $this->defaults = array(
  29. 'title' => __( 'Follow Us', 'jetpack' ),
  30. 'icon-size' => 'medium',
  31. 'new-tab' => false,
  32. 'icons' => array(
  33. array(
  34. 'url' => '',
  35. ),
  36. ),
  37. );
  38. // Enqueue admin scrips and styles, only in the customizer or the old widgets page.
  39. if ( is_customize_preview() || 'widgets.php' === $pagenow ) {
  40. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
  41. add_action( 'admin_print_footer_scripts', array( $this, 'render_admin_js' ) );
  42. }
  43. // Enqueue scripts and styles for the display of the widget, on the frontend or in the customizer.
  44. if ( is_active_widget( false, $this->id, $this->id_base, true ) || is_customize_preview() ) {
  45. add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_icon_scripts' ) );
  46. add_action( 'wp_footer', array( $this, 'include_svg_icons' ), 9999 );
  47. }
  48. }
  49. /**
  50. * Script & styles for admin widget form.
  51. */
  52. public function enqueue_admin_scripts() {
  53. wp_enqueue_script(
  54. 'jetpack-widget-social-icons-script',
  55. plugins_url( 'social-icons/social-icons-admin.js', __FILE__ ),
  56. array( 'jquery-ui-sortable' ),
  57. '20170506',
  58. true
  59. );
  60. wp_enqueue_style(
  61. 'jetpack-widget-social-icons-admin',
  62. plugins_url( 'social-icons/social-icons-admin.css', __FILE__ ),
  63. array(),
  64. '20170506'
  65. );
  66. }
  67. /**
  68. * Styles for front-end widget.
  69. */
  70. public function enqueue_icon_scripts() {
  71. wp_enqueue_style( 'jetpack-widget-social-icons-styles', plugins_url( 'social-icons/social-icons.css', __FILE__ ), array(), '20170506' );
  72. }
  73. /**
  74. * JavaScript for admin widget form.
  75. */
  76. public function render_admin_js() {
  77. ?>
  78. <script type="text/html" id="tmpl-jetpack-widget-social-icons-template">
  79. <?php self::render_icons_template(); ?>
  80. </script>
  81. <?php
  82. }
  83. /**
  84. * Add SVG definitions to the footer.
  85. */
  86. public function include_svg_icons() {
  87. // Define SVG sprite file in Jetpack.
  88. $svg_icons = dirname( __DIR__ ) . '/theme-tools/social-menu/social-menu.svg';
  89. // Define SVG sprite file in WPCOM.
  90. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
  91. $svg_icons = dirname( __DIR__ ) . '/social-menu/social-menu.svg';
  92. }
  93. // If it exists, include it.
  94. if ( is_file( $svg_icons ) ) {
  95. require_once $svg_icons;
  96. }
  97. }
  98. /**
  99. * Front-end display of widget.
  100. *
  101. * @see WP_Widget::widget()
  102. *
  103. * @param array $args Widget arguments.
  104. * @param array $instance Saved values from database.
  105. */
  106. public function widget( $args, $instance ) {
  107. $instance = wp_parse_args( $instance, $this->defaults );
  108. /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
  109. $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
  110. echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  111. if ( ! empty( $title ) ) {
  112. echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  113. }
  114. if ( ! empty( $instance['icons'] ) ) :
  115. // Get supported social icons.
  116. $social_icons = $this->get_supported_icons();
  117. $default_icon = $this->get_svg_icon( array( 'icon' => 'chain' ) );
  118. ?>
  119. <ul class="jetpack-social-widget-list size-<?php echo esc_attr( $instance['icon-size'] ); ?>">
  120. <?php foreach ( $instance['icons'] as $icon ) : ?>
  121. <?php if ( ! empty( $icon['url'] ) ) : ?>
  122. <li class="jetpack-social-widget-item">
  123. <?php
  124. printf(
  125. '<a href="%1$s" %2$s>',
  126. esc_url( $icon['url'], array( 'http', 'https', 'mailto', 'skype' ) ),
  127. true === $instance['new-tab'] ?
  128. 'target="_blank" rel="noopener noreferrer"' :
  129. 'target="_self"'
  130. );
  131. $found_icon = false;
  132. foreach ( $social_icons as $social_icon ) {
  133. foreach ( $social_icon['url'] as $url_fragment ) {
  134. if ( false !== stripos( $icon['url'], $url_fragment ) ) {
  135. printf(
  136. '<span class="screen-reader-text">%1$s</span>%2$s',
  137. esc_attr( $social_icon['label'] ),
  138. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  139. $this->get_svg_icon(
  140. array(
  141. 'icon' => esc_attr( $social_icon['icon'] ),
  142. )
  143. )
  144. );
  145. $found_icon = true;
  146. break 2;
  147. }
  148. }
  149. }
  150. if ( ! $found_icon ) {
  151. echo $default_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  152. }
  153. ?>
  154. </a>
  155. </li>
  156. <?php endif; ?>
  157. <?php endforeach; ?>
  158. </ul>
  159. <?php
  160. endif;
  161. echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  162. /** This action is documented in modules/widgets/gravatar-profile.php */
  163. do_action( 'jetpack_stats_extra', 'widget_view', 'social_icons' );
  164. }
  165. /**
  166. * Sanitize widget form values as they are saved.
  167. *
  168. * @see WP_Widget::update()
  169. *
  170. * @param array $new_instance Values just sent to be saved.
  171. * @param array $old_instance Previously saved values from database.
  172. *
  173. * @return array Updated safe values to be saved.
  174. */
  175. public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
  176. $instance = array();
  177. $instance['title'] = sanitize_text_field( $new_instance['title'] );
  178. $instance['icon-size'] = $this->defaults['icon-size'];
  179. $instance['url-icons'] = array_key_exists( 'url-icons', $new_instance ) ? $new_instance['url-icons'] : array();
  180. if ( in_array( $new_instance['icon-size'], array( 'small', 'medium', 'large' ), true ) ) {
  181. $instance['icon-size'] = $new_instance['icon-size'];
  182. }
  183. $instance['new-tab'] = isset( $new_instance['new-tab'] ) ? (bool) $new_instance['new-tab'] : false;
  184. $instance['icons'] = array();
  185. if ( array_key_exists( 'url-icons', $new_instance ) ) {
  186. foreach ( $new_instance['url-icons'] as $url ) {
  187. $url = filter_var( $url, FILTER_SANITIZE_URL );
  188. if ( ! empty( $url ) ) {
  189. $instance['icons'][] = array(
  190. 'url' => $url,
  191. );
  192. }
  193. }
  194. }
  195. return $instance;
  196. }
  197. /**
  198. * Back-end widget form.
  199. *
  200. * @see WP_Widget::form()
  201. *
  202. * @param array $instance Previously saved values from database.
  203. *
  204. * @return string|void
  205. */
  206. public function form( $instance ) {
  207. $instance = wp_parse_args( $instance, $this->defaults );
  208. $title = sanitize_text_field( $instance['title'] );
  209. $sizes = array(
  210. 'small' => __( 'Small', 'jetpack' ),
  211. 'medium' => __( 'Medium', 'jetpack' ),
  212. 'large' => __( 'Large', 'jetpack' ),
  213. );
  214. $new_tab = isset( $instance['new-tab'] ) ? (bool) $instance['new-tab'] : false;
  215. ?>
  216. <p>
  217. <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
  218. <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
  219. </p>
  220. <p>
  221. <label for="<?php echo esc_attr( $this->get_field_id( 'icon-size' ) ); ?>"><?php esc_html_e( 'Size:', 'jetpack' ); ?></label>
  222. <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'icon-size' ) ); ?>">
  223. <?php foreach ( $sizes as $value => $label ) : ?>
  224. <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $instance['icon-size'] ); ?>><?php echo esc_attr( $label ); ?></option>
  225. <?php endforeach; ?>
  226. </select>
  227. </p>
  228. <div class="jetpack-social-icons-widget-list"
  229. data-url-icon-id="<?php echo esc_attr( $this->get_field_id( 'url-icons' ) ); ?>"
  230. data-url-icon-name="<?php echo esc_attr( $this->get_field_name( 'url-icons' ) ); ?>"
  231. >
  232. <?php
  233. foreach ( $instance['icons'] as $icon ) {
  234. self::render_icons_template(
  235. array(
  236. 'url-icon-id' => $this->get_field_id( 'url-icons' ),
  237. 'url-icon-name' => $this->get_field_name( 'url-icons' ),
  238. 'url-value' => $icon['url'],
  239. )
  240. );
  241. }
  242. ?>
  243. </div>
  244. <p class="jetpack-social-icons-widget add-button">
  245. <button type="button" class="button jetpack-social-icons-add-button">
  246. <?php esc_html_e( 'Add an icon', 'jetpack' ); ?>
  247. </button>
  248. </p>
  249. <?php
  250. switch ( get_locale() ) {
  251. case 'es':
  252. $support = 'https://es.support.wordpress.com/social-media-icons-widget/#iconos-disponibles';
  253. break;
  254. case 'pt-br':
  255. $support = 'https://br.support.wordpress.com/widgets/widget-de-icones-sociais/#ícones-disponíveis';
  256. break;
  257. default:
  258. $support = 'https://en.support.wordpress.com/widgets/social-media-icons-widget/#available-icons';
  259. }
  260. ?>
  261. <p>
  262. <em><a href="<?php echo esc_url( $support ); ?>" target="_blank" rel="noopener noreferrer">
  263. <?php esc_html_e( 'View available icons', 'jetpack' ); ?>
  264. </a></em>
  265. </p>
  266. <p>
  267. <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'new-tab' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'new-tab' ) ); ?>" <?php checked( $new_tab ); ?> />
  268. <label for="<?php echo esc_attr( $this->get_field_id( 'new-tab' ) ); ?>"><?php esc_html_e( 'Open link in a new tab', 'jetpack' ); ?></label>
  269. </p>
  270. <?php
  271. }
  272. /**
  273. * Generates template to add icons.
  274. *
  275. * @param array $args Template arguments.
  276. */
  277. private static function render_icons_template( $args = array() ) {
  278. $defaults = array(
  279. 'url-icon-id' => '',
  280. 'url-icon-name' => '',
  281. 'url-value' => '',
  282. );
  283. $args = wp_parse_args( $args, $defaults );
  284. ?>
  285. <div class="jetpack-social-icons-widget-item">
  286. <div class="jetpack-social-icons-widget-item-wrapper">
  287. <div class="handle"></div>
  288. <p class="jetpack-widget-social-icons-url">
  289. <?php
  290. printf(
  291. '<input class="widefat" id="%1$s" name="%2$s[]" type="text" placeholder="%3$s" value="%4$s"/>',
  292. esc_attr( $args['url-icon-id'] ),
  293. esc_attr( $args['url-icon-name'] ),
  294. esc_attr__( 'Account URL', 'jetpack' ),
  295. esc_url( $args['url-value'], array( 'http', 'https', 'mailto', 'skype' ) )
  296. );
  297. ?>
  298. </p>
  299. <p class="jetpack-widget-social-icons-remove-item">
  300. <a class="jetpack-widget-social-icons-remove-item-button" href="javascript:;">
  301. <?php esc_html_e( 'Remove', 'jetpack' ); ?>
  302. </a>
  303. </p>
  304. </div>
  305. </div>
  306. <?php
  307. }
  308. /**
  309. * Return SVG markup.
  310. *
  311. * @param array $args {
  312. * Parameters needed to display an SVG.
  313. *
  314. * @type string $icon Required SVG icon filename.
  315. * }
  316. * @return string SVG markup.
  317. */
  318. public function get_svg_icon( $args = array() ) {
  319. // Make sure $args are an array.
  320. if ( empty( $args ) ) {
  321. return esc_html__( 'Please define default parameters in the form of an array.', 'jetpack' );
  322. }
  323. // Set defaults.
  324. $defaults = array(
  325. 'icon' => '',
  326. );
  327. // Parse args.
  328. $args = wp_parse_args( $args, $defaults );
  329. // Define an icon.
  330. if ( false === array_key_exists( 'icon', $args ) ) {
  331. return esc_html__( 'Please define an SVG icon filename.', 'jetpack' );
  332. }
  333. // Set aria hidden.
  334. $aria_hidden = ' aria-hidden="true"';
  335. // Begin SVG markup.
  336. $svg = '<svg class="icon icon-' . esc_attr( $args['icon'] ) . '"' . $aria_hidden . ' role="presentation">';
  337. /*
  338. * Display the icon.
  339. *
  340. * The whitespace around `<use>` is intentional - it is a work around to a keyboard navigation bug in Safari 10.
  341. *
  342. * See https://core.trac.wordpress.org/ticket/38387.
  343. */
  344. $svg .= ' <use href="#icon-' . esc_html( $args['icon'] ) . '" xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use> ';
  345. $svg .= '</svg>';
  346. return $svg;
  347. }
  348. /**
  349. * Returns an array of supported social links (URL, icon, and label).
  350. *
  351. * @return array $social_links_icons
  352. */
  353. public function get_supported_icons() {
  354. $social_links_icons = array(
  355. array(
  356. 'url' => array( '500px.com' ),
  357. 'icon' => '500px',
  358. 'label' => '500px',
  359. ),
  360. array(
  361. 'url' => array(
  362. 'amazon.cn',
  363. 'amazon.in',
  364. 'amazon.fr',
  365. 'amazon.de',
  366. 'amazon.it',
  367. 'amazon.nl',
  368. 'amazon.es',
  369. 'amazon.co',
  370. 'amazon.ca',
  371. 'amazon.com',
  372. ),
  373. 'icon' => 'amazon',
  374. 'label' => 'Amazon',
  375. ),
  376. array(
  377. 'url' => array( 'apple.com' ),
  378. 'icon' => 'apple',
  379. 'label' => 'Apple',
  380. ),
  381. array(
  382. 'url' => array( 'itunes.com' ),
  383. 'icon' => 'apple',
  384. 'label' => 'iTunes',
  385. ),
  386. array(
  387. 'url' => array( 'bandcamp.com' ),
  388. 'icon' => 'bandcamp',
  389. 'label' => 'Bandcamp',
  390. ),
  391. array(
  392. 'url' => array( 'behance.net' ),
  393. 'icon' => 'behance',
  394. 'label' => 'Behance',
  395. ),
  396. array(
  397. 'url' => array(
  398. 'blogger.com',
  399. 'blogspot.com',
  400. ),
  401. 'icon' => 'blogger',
  402. 'label' => 'Blogger',
  403. ),
  404. array(
  405. 'url' => array( 'codepen.io' ),
  406. 'icon' => 'codepen',
  407. 'label' => 'CodePen',
  408. ),
  409. array(
  410. 'url' => array( 'deviantart.com' ),
  411. 'icon' => 'deviantart',
  412. 'label' => 'DeviantArt',
  413. ),
  414. array(
  415. 'url' => array( 'digg.com' ),
  416. 'icon' => 'digg',
  417. 'label' => 'Digg',
  418. ),
  419. array(
  420. 'url' => array( 'discord.gg', 'discordapp.com' ),
  421. 'icon' => 'discord',
  422. 'label' => 'Discord',
  423. ),
  424. array(
  425. 'url' => array( 'dribbble.com' ),
  426. 'icon' => 'dribbble',
  427. 'label' => 'Dribbble',
  428. ),
  429. array(
  430. 'url' => array( 'dropbox.com' ),
  431. 'icon' => 'dropbox',
  432. 'label' => 'Dropbox',
  433. ),
  434. array(
  435. 'url' => array( 'etsy.com' ),
  436. 'icon' => 'etsy',
  437. 'label' => 'Etsy',
  438. ),
  439. array(
  440. 'url' => array( 'eventbrite.com' ),
  441. 'icon' => 'eventbrite',
  442. 'label' => 'Eventbrite',
  443. ),
  444. array(
  445. 'url' => array( 'facebook.com' ),
  446. 'icon' => 'facebook',
  447. 'label' => 'Facebook',
  448. ),
  449. array(
  450. 'url' => array( 'flickr.com' ),
  451. 'icon' => 'flickr',
  452. 'label' => 'Flickr',
  453. ),
  454. array(
  455. 'url' => array( 'foursquare.com' ),
  456. 'icon' => 'foursquare',
  457. 'label' => 'Foursquare',
  458. ),
  459. array(
  460. 'url' => array( 'ghost.org' ),
  461. 'icon' => 'ghost',
  462. 'label' => 'Ghost',
  463. ),
  464. array(
  465. 'url' => array( 'goodreads.com' ),
  466. 'icon' => 'goodreads',
  467. 'label' => 'Goodreads',
  468. ),
  469. array(
  470. 'url' => array( 'google.com', 'google.co.uk', 'google.ca', 'google.cn', 'google.it' ),
  471. 'icon' => 'google',
  472. 'label' => 'Google',
  473. ),
  474. array(
  475. 'url' => array( 'github.com' ),
  476. 'icon' => 'github',
  477. 'label' => 'GitHub',
  478. ),
  479. array(
  480. 'url' => array( 'instagram.com' ),
  481. 'icon' => 'instagram',
  482. 'label' => 'Instagram',
  483. ),
  484. array(
  485. 'url' => array( 'linkedin.com' ),
  486. 'icon' => 'linkedin',
  487. 'label' => 'LinkedIn',
  488. ),
  489. array(
  490. 'url' => array( 'mailto:' ),
  491. 'icon' => 'mail',
  492. 'label' => __( 'Email', 'jetpack' ),
  493. ),
  494. array(
  495. 'url' => array( 'meetup.com' ),
  496. 'icon' => 'meetup',
  497. 'label' => 'Meetup',
  498. ),
  499. array(
  500. 'url' => array( 'medium.com' ),
  501. 'icon' => 'medium',
  502. 'label' => 'Medium',
  503. ),
  504. array(
  505. 'url' => array( 'patreon.com' ),
  506. 'icon' => 'patreon',
  507. 'label' => 'Patreon',
  508. ),
  509. array(
  510. 'url' => array( 'pinterest.' ),
  511. 'icon' => 'pinterest',
  512. 'label' => 'Pinterest',
  513. ),
  514. array(
  515. 'url' => array( 'getpocket.com' ),
  516. 'icon' => 'pocket',
  517. 'label' => 'Pocket',
  518. ),
  519. array(
  520. 'url' => array( 'ravelry.com' ),
  521. 'icon' => 'ravelry',
  522. 'label' => 'Ravelry',
  523. ),
  524. array(
  525. 'url' => array( 'reddit.com' ),
  526. 'icon' => 'reddit',
  527. 'label' => 'Reddit',
  528. ),
  529. array(
  530. 'url' => array( 'skype.com' ),
  531. 'icon' => 'skype',
  532. 'label' => 'Skype',
  533. ),
  534. array(
  535. 'url' => array( 'skype:' ),
  536. 'icon' => 'skype',
  537. 'label' => 'Skype',
  538. ),
  539. array(
  540. 'url' => array( 'slideshare.net' ),
  541. 'icon' => 'slideshare',
  542. 'label' => 'SlideShare',
  543. ),
  544. array(
  545. 'url' => array( 'snapchat.com' ),
  546. 'icon' => 'snapchat',
  547. 'label' => 'Snapchat',
  548. ),
  549. array(
  550. 'url' => array( 'soundcloud.com' ),
  551. 'icon' => 'soundcloud',
  552. 'label' => 'SoundCloud',
  553. ),
  554. array(
  555. 'url' => array( 'spotify.com' ),
  556. 'icon' => 'spotify',
  557. 'label' => 'Spotify',
  558. ),
  559. array(
  560. 'url' => array( 'stackoverflow.com' ),
  561. 'icon' => 'stackoverflow',
  562. 'label' => 'Stack Overflow',
  563. ),
  564. array(
  565. 'url' => array( 'stumbleupon.com' ),
  566. 'icon' => 'stumbleupon',
  567. 'label' => 'StumbleUpon',
  568. ),
  569. array(
  570. 'url' => array( 'telegram.me', 't.me' ),
  571. 'icon' => 'telegram',
  572. 'label' => 'Telegram',
  573. ),
  574. array(
  575. 'url' => array( 'tiktok.com' ),
  576. 'icon' => 'tiktok',
  577. 'label' => 'TikTok',
  578. ),
  579. array(
  580. 'url' => array( 'tumblr.com' ),
  581. 'icon' => 'tumblr',
  582. 'label' => 'Tumblr',
  583. ),
  584. array(
  585. 'url' => array( 'twitch.tv' ),
  586. 'icon' => 'twitch',
  587. 'label' => 'Twitch',
  588. ),
  589. array(
  590. 'url' => array( 'twitter.com' ),
  591. 'icon' => 'twitter',
  592. 'label' => 'Twitter',
  593. ),
  594. array(
  595. 'url' => array( 'vimeo.com' ),
  596. 'icon' => 'vimeo',
  597. 'label' => 'Vimeo',
  598. ),
  599. array(
  600. 'url' => array( 'vk.com' ),
  601. 'icon' => 'vk',
  602. 'label' => 'VK',
  603. ),
  604. array(
  605. 'url' => array( 'whatsapp.com' ),
  606. 'icon' => 'whatsapp',
  607. 'label' => 'WhatsApp',
  608. ),
  609. array(
  610. 'url' => array( 'woocommerce.com' ),
  611. 'icon' => 'woocommerce',
  612. 'label' => 'WooCommerce',
  613. ),
  614. array(
  615. 'url' => array( 'wordpress.com', 'wordpress.org' ),
  616. 'icon' => 'wordpress',
  617. 'label' => 'WordPress',
  618. ),
  619. array(
  620. 'url' => array( 'yelp.com' ),
  621. 'icon' => 'yelp',
  622. 'label' => 'Yelp',
  623. ),
  624. array(
  625. 'url' => array( 'xanga.com' ),
  626. 'icon' => 'xanga',
  627. 'label' => 'Xanga',
  628. ),
  629. array(
  630. 'url' => array( 'youtube.com' ),
  631. 'icon' => 'youtube',
  632. 'label' => 'YouTube',
  633. ),
  634. // keep feed at the end so that more specific icons can take precedence.
  635. array(
  636. 'url' => array(
  637. '/feed/', // WordPress default feed url.
  638. '/feeds/', // Blogspot and others.
  639. '/blog/feed', // No trailing slash WordPress feed, could use /feed but may match unexpectedly.
  640. 'format=RSS', // Squarespace and others.
  641. '/rss', // Tumblr.
  642. '/.rss', // Reddit.
  643. '/rss.xml', // Moveable Type, Typepad.
  644. 'http://rss.', // Old custom format.
  645. 'https://rss.', // Old custom format.
  646. 'rss=1',
  647. '/feed=rss', // Catches feed=rss / feed=rss2.
  648. '?feed=rss', // WordPress non-permalink - Catches feed=rss / feed=rss2.
  649. '?feed=rdf', // WordPress non-permalink.
  650. '?feed=atom', // WordPress non-permalink.
  651. 'http://feeds.', // FeedBurner.
  652. 'https://feeds.', // FeedBurner.
  653. '/feed.xml', // Feedburner Alias, and others.
  654. '/index.xml', // Moveable Type, and others.
  655. '/atom.xml', // Typepad, Squarespace.
  656. '.atom', // Shopify blog.
  657. '/atom', // Some non-WordPress feeds.
  658. 'index.rdf', // Typepad.
  659. ),
  660. 'icon' => 'feed',
  661. 'label' => __( 'RSS Feed', 'jetpack' ),
  662. ),
  663. );
  664. return $social_links_icons;
  665. }
  666. } // Jetpack_Widget_Social_Icons
  667. /**
  668. * Register and load the widget.
  669. *
  670. * @access public
  671. * @return void
  672. */
  673. function jetpack_widget_social_icons_load() {
  674. register_widget( 'Jetpack_Widget_Social_Icons' );
  675. }
  676. add_action( 'widgets_init', 'jetpack_widget_social_icons_load' );