Completed
Push — update/8422-pinterest-tlds-soc... ( 896aa0...4343f7 )
by
unknown
08:14
created

Jetpack_Widget_Social_Icons::widget()   C

Complexity

Conditions 10
Paths 6

Size

Total Lines 72

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
nc 6
nop 2
dl 0
loc 72
rs 6.7442
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
class Jetpack_Widget_Social_Icons extends WP_Widget {
3
	/**
4
	 * @var array Default widget options.
5
	 */
6
	protected $defaults;
7
8
	/**
9
	 * Widget constructor.
10
	 */
11
	public function __construct() {
12
		$widget_ops = array(
13
			'classname'                   => 'jetpack_widget_social_icons',
14
			'description'                 => __( 'Add social-media icons to your site.', 'jetpack' ),
15
			'customize_selective_refresh' => true,
16
		);
17
18
		parent::__construct(
19
			'jetpack_widget_social_icons',
20
			/** This filter is documented in modules/widgets/facebook-likebox.php */
21
			apply_filters( 'jetpack_widget_name', __( 'Social Icons', 'jetpack' ) ),
22
			$widget_ops
23
		);
24
25
		$this->defaults = array(
26
			'title'     => __( 'Follow Us', 'jetpack' ),
27
			'icon-size' => 'medium',
28
			'new-tab'   => false,
29
			'icons'     => array(
30
				array(
31
					'url' => '',
32
				),
33
			),
34
		);
35
36
		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
37
		add_action( 'admin_print_footer_scripts', array( $this, 'render_admin_js' ) );
38
		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_icon_scripts' ) );
39
		add_action( 'wp_footer', array( $this, 'include_svg_icons' ), 9999 );
40
	}
41
42
	/**
43
	 * Script & styles for admin widget form.
44
	 */
45
	public function enqueue_admin_scripts() {
46
		wp_enqueue_script( 'jetpack-widget-social-icons-script', plugins_url( 'social-icons/social-icons-admin.js', __FILE__ ), array( 'jquery-ui-sortable' ), '20170506' );
47
		wp_enqueue_style( 'jetpack-widget-social-icons-admin', plugins_url( 'social-icons/social-icons-admin.css', __FILE__ ), array(), '20170506' );
48
	}
49
50
	/**
51
	 * Styles for front-end widget.
52
	 */
53
	public function enqueue_icon_scripts() {
54
		wp_enqueue_style( 'jetpack-widget-social-icons-styles', plugins_url( 'social-icons/social-icons.css', __FILE__ ), array(), '20170506' );
55
	}
56
57
	/**
58
	 * JavaScript for admin widget form.
59
	 */
60
	public function render_admin_js() {
61
		global $wp_customize;
62
		global $pagenow;
63
64
		if ( ! isset( $wp_customize ) && 'widgets.php' !== $pagenow ) {
65
			return;
66
		}
67
	?>
68
		<script type="text/html" id="tmpl-jetpack-widget-social-icons-template">
69
			<?php self::render_icons_template(); ?>
70
		</script>
71
	<?php
72
	}
73
74
	/**
75
	 * Add SVG definitions to the footer.
76
	 */
77
	public function include_svg_icons() {
78
		if ( ! is_active_widget( false, $this->id, $this->id_base, true ) ) {
79
			return;
80
		}
81
82
		// Define SVG sprite file in Jetpack
83
		$svg_icons = dirname( dirname( __FILE__ ) ) . '/theme-tools/social-menu/social-menu.svg';
84
85
		// Define SVG sprite file in WPCOM
86
		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
87
			$svg_icons = dirname( dirname( __FILE__ ) ) . '/social-menu/social-menu.svg';
88
		}
89
90
		// If it exists, include it.
91
		if ( is_file( $svg_icons ) ) {
92
			require_once( $svg_icons );
93
		}
94
	}
95
96
	/**
97
	 * Front-end display of widget.
98
	 *
99
	 * @see WP_Widget::widget()
100
	 *
101
	 * @param array $args Widget arguments.
102
	 * @param array $instance Saved values from database.
103
	 */
104
	public function widget( $args, $instance ) {
105
		$instance = wp_parse_args( $instance, $this->defaults );
106
107
		/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
108
		$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
109
110
		echo $args['before_widget'];
111
112
		if ( ! empty( $title ) ) {
113
			echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
114
		}
115
116
		if ( ! empty( $instance['icons'] ) ) :
117
118
			// Get supported social icons.
119
			$social_icons = $this->get_supported_icons();
120
			$default_icon = $this->get_svg_icon( array( 'icon' => 'chain' ) );
121
122
			// Set target attribute for the link
123
			if ( true === $instance['new-tab'] ) {
124
				$target = '_blank';
125
			} else {
126
				$target = '_self';
127
			}
128
		?>
129
130
			<ul class="jetpack-social-widget-list size-<?php echo esc_attr( $instance['icon-size'] ); ?>">
131
132
				<?php foreach ( $instance['icons'] as $icon ) : ?>
133
134
					<?php if ( ! empty( $icon['url'] ) ) : ?>
135
						<li class="jetpack-social-widget-item">
136
							<a href="<?php echo esc_url( $icon['url'], array( 'http', 'https', 'mailto', 'skype' ) ); ?>" target="<?php echo $target; ?>">
137
								<?php
138
									$found_icon = false;
139
140
								foreach ( $social_icons as $social_icon ) {
141
									if ( false !== stripos( $icon['url'], $social_icon['url'] ) ) {
142
										echo '<span class="screen-reader-text">' . esc_attr( $social_icon['label'] ) . '</span>';
143
										echo $this->get_svg_icon( array( 'icon' => esc_attr( $social_icon['icon'] ) ) );
144
										$found_icon = true;
145
										break;
146
									}
147
148
									if ( preg_match('/https?:\/\/(www\.)?([a-z]{1,})?\.?pinterest\./i', $icon['url'] ) ) {
149
										echo '<span class="screen-reader-text">' . esc_attr( 'Pinterest' ) . '</span>';
150
										echo $this->get_svg_icon( array( 'icon' => esc_attr( 'pinterest' ) ) );
151
										$found_icon = true;
152
										break;
153
									}
154
								}
155
156
								if ( ! $found_icon ) {
157
									echo $default_icon;
158
								}
159
								?>
160
							</a>
161
						</li>
162
					<?php endif; ?>
163
164
				<?php endforeach; ?>
165
166
			</ul>
167
168
		<?php
169
		endif;
170
171
		echo $args['after_widget'];
172
173
		/** This action is documented in modules/widgets/gravatar-profile.php */
174
		do_action( 'jetpack_stats_extra', 'widget_view', 'social_icons' );
175
	}
176
177
	/**
178
	 * Sanitize widget form values as they are saved.
179
	 *
180
	 * @see WP_Widget::update()
181
	 *
182
	 * @param array $new_instance Values just sent to be saved.
183
	 * @param array $old_instance Previously saved values from database.
184
	 *
185
	 * @return array Updated safe values to be saved.
186
	 */
187
	public function update( $new_instance, $old_instance ) {
188
		$instance['title']     = sanitize_text_field( $new_instance['title'] );
0 ignored issues
show
Coding Style Comprehensibility introduced by
$instance was never initialized. Although not strictly required by PHP, it is generally a good practice to add $instance = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
189
		$instance['icon-size'] = $this->defaults['icon-size'];
190
191
		if ( in_array( $new_instance['icon-size'], array( 'small', 'medium', 'large' ) ) ) {
192
			$instance['icon-size'] = $new_instance['icon-size'];
193
		}
194
195
		$instance['new-tab'] = isset( $new_instance['new-tab'] ) ? (bool) $new_instance['new-tab'] : false;
196
		$icon_count          = count( $new_instance['url-icons'] );
0 ignored issues
show
Unused Code introduced by
$icon_count is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
197
		$instance['icons']   = array();
198
199
		foreach ( $new_instance['url-icons'] as $url ) {
200
			$url = filter_var( $url, FILTER_SANITIZE_URL );
201
202
			if ( ! empty( $url ) ) {
203
				$instance['icons'][] = array(
204
					'url' => $url,
205
				);
206
			}
207
		}
208
209
		return $instance;
210
	}
211
212
	/**
213
	 * Back-end widget form.
214
	 *
215
	 * @see WP_Widget::form()
216
	 *
217
	 * @param array $instance Previously saved values from database.
218
	 *
219
	 * @return string|void
220
	 */
221
	public function form( $instance ) {
222
		$instance = wp_parse_args( $instance, $this->defaults );
223
		$title    = sanitize_text_field( $instance['title'] );
224
		$sizes    = array(
225
			'small'  => __( 'Small', 'jetpack' ),
226
			'medium' => __( 'Medium', 'jetpack' ),
227
			'large'  => __( 'Large', 'jetpack' ),
228
		);
229
		$new_tab  = isset( $instance['new-tab'] ) ? (bool) $instance['new-tab'] : false;
230
		?>
231
232
		<p>
233
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
234
			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
235
		</p>
236
237
		<p>
238
			<label for="<?php echo $this->get_field_id( 'icon-size' ); ?>"><?php esc_html_e( 'Size:', 'jetpack' ); ?></label>
239
			<select class="widefat" name="<?php echo $this->get_field_name( 'icon-size' ); ?>">
240
				<?php foreach ( $sizes as $value => $label ) : ?>
241
					<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $instance['icon-size'] ); ?>><?php echo esc_attr( $label ); ?></option>
242
				<?php endforeach; ?>
243
			</select>
244
		</p>
245
246
		<div class="jetpack-social-icons-widget-list"
247
			data-url-icon-id="<?php echo $this->get_field_id( 'url-icons' ); ?>"
248
			data-url-icon-name="<?php echo $this->get_field_name( 'url-icons' ); ?>"
249
		>
250
251
			<?php
252
			foreach ( $instance['icons'] as $icon ) {
253
				self::render_icons_template(
254
					array(
255
						'url-icon-id'   => $this->get_field_id( 'url-icons' ),
256
						'url-icon-name' => $this->get_field_name( 'url-icons' ),
257
						'url-value'     => $icon['url'],
258
					)
259
				);
260
			}
261
			?>
262
263
		</div>
264
265
		<p class="jetpack-social-icons-widget add-button">
266
			<button type="button" class="button jetpack-social-icons-add-button">
267
				<?php esc_html_e( 'Add an icon', 'jetpack' ); ?>
268
			</button>
269
		</p>
270
271
		<?php
272
		switch ( get_locale() ) {
273
			case 'es':
274
				$support = 'https://es.support.wordpress.com/social-media-icons-widget/#iconos-disponibles';
275
				break;
276
277
			case 'pt-br':
278
				$support = 'https://br.support.wordpress.com/widgets/widget-de-icones-sociais/#ícones-disponíveis';
279
				break;
280
281
			default:
282
				$support = 'https://en.support.wordpress.com/widgets/social-media-icons-widget/#available-icons';
283
		}
284
		?>
285
286
		<p>
287
			<em><a href="<?php echo esc_url( $support ); ?>" target="_blank">
288
				<?php esc_html_e( 'View available icons', 'jetpack' ); ?>
289
			</a></em>
290
		</p>
291
292
		<p>
293
			<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'new-tab' ); ?>" name="<?php echo $this->get_field_name( 'new-tab' ); ?>" <?php checked( $new_tab ); ?> />
294
			<label for="<?php echo $this->get_field_id( 'new-tab' ); ?>"><?php esc_html_e( 'Open link in a new tab', 'jetpack' ); ?></label>
295
		</p>
296
297
	<?php
298
	}
299
300
	/**
301
	 * Generates template to add icons.
302
	 *
303
	 * @param array $args Template arguments
304
	 */
305
	static function render_icons_template( $args = array() ) {
306
		$defaults = array(
307
			'url-icon-id'   => '',
308
			'url-icon-name' => '',
309
			'url-value'     => '',
310
		);
311
312
		$args = wp_parse_args( $args, $defaults );
313
		?>
314
315
		<div class="jetpack-social-icons-widget-item">
316
			<div class="jetpack-social-icons-widget-item-wrapper">
317
				<div class="handle"></div>
318
319
				<p class="jetpack-widget-social-icons-url">
320
					<?php
321
						printf(
322
							'<input class="widefat id="%1$s" name="%2$s[]" type="text" placeholder="%3$s" value="%4$s"/>',
323
							esc_attr( $args['url-icon-id'] ),
324
							esc_attr( $args['url-icon-name'] ),
325
							esc_attr__( 'Account URL', 'jetpack' ),
326
							esc_url( $args['url-value'], array( 'http', 'https', 'mailto', 'skype' ) )
327
						);
328
					?>
329
				</p>
330
331
				<p class="jetpack-widget-social-icons-remove-item">
332
					<a class="jetpack-widget-social-icons-remove-item-button" href="javascript:;">
333
						<?php esc_html_e( 'Remove', 'jetpack' ); ?>
334
					</a>
335
				</p>
336
			</div>
337
		</div>
338
339
		<?php
340
	}
341
342
	/**
343
	 * Return SVG markup.
344
	 *
345
	 * @param array $args {
346
	 *     Parameters needed to display an SVG.
347
	 *
348
	 *     @type string $icon  Required SVG icon filename.
349
	 * }
350
	 * @return string SVG markup.
351
	 */
352
	public function get_svg_icon( $args = array() ) {
353
		// Make sure $args are an array.
354
		if ( empty( $args ) ) {
355
			return esc_html__( 'Please define default parameters in the form of an array.', 'jetpack' );
356
		}
357
358
		// Set defaults.
359
		$defaults = array(
360
			'icon' => '',
361
		);
362
363
		// Parse args.
364
		$args = wp_parse_args( $args, $defaults );
365
366
		// Define an icon.
367
		if ( false === array_key_exists( 'icon', $args ) ) {
368
			return esc_html__( 'Please define an SVG icon filename.', 'jetpack' );
369
		}
370
371
		// Set aria hidden.
372
		$aria_hidden = ' aria-hidden="true"';
373
374
		// Begin SVG markup.
375
		$svg = '<svg class="icon icon-' . esc_attr( $args['icon'] ) . '"' . $aria_hidden . ' role="img">';
376
377
		/*
378
		 * Display the icon.
379
		 *
380
		 * The whitespace around `<use>` is intentional - it is a work around to a keyboard navigation bug in Safari 10.
381
		 *
382
		 * See https://core.trac.wordpress.org/ticket/38387.
383
		 */
384
		$svg .= ' <use href="#icon-' . esc_html( $args['icon'] ) . '" xlink:href="#icon-' . esc_html( $args['icon'] ) . '"></use> ';
385
386
		$svg .= '</svg>';
387
388
		return $svg;
389
	}
390
391
	/**
392
	 * Returns an array of supported social links (URL, icon, and label).
393
	 *
394
	 * @return array $social_links_icons
395
	 */
396
	public function get_supported_icons() {
397
		$social_links_icons = array(
398
			array(
399
				'url'   => '500px.com',
400
				'icon'  => '500px',
401
				'label' => '500px',
402
			),
403
			array(
404
				'url'   => 'amazon.cn',
405
				'icon'  => 'amazon',
406
				'label' => 'Amazon',
407
			),
408
			array(
409
				'url'   => 'amazon.in',
410
				'icon'  => 'amazon',
411
				'label' => 'Amazon',
412
			),
413
			array(
414
				'url'   => 'amazon.fr',
415
				'icon'  => 'amazon',
416
				'label' => 'Amazon',
417
			),
418
			array(
419
				'url'   => 'amazon.de',
420
				'icon'  => 'amazon',
421
				'label' => 'Amazon',
422
			),
423
			array(
424
				'url'   => 'amazon.it',
425
				'icon'  => 'amazon',
426
				'label' => 'Amazon',
427
			),
428
			array(
429
				'url'   => 'amazon.nl',
430
				'icon'  => 'amazon',
431
				'label' => 'Amazon',
432
			),
433
			array(
434
				'url'   => 'amazon.es',
435
				'icon'  => 'amazon',
436
				'label' => 'Amazon',
437
			),
438
			array(
439
				'url'   => 'amazon.co',
440
				'icon'  => 'amazon',
441
				'label' => 'Amazon',
442
			),
443
			array(
444
				'url'   => 'amazon.ca',
445
				'icon'  => 'amazon',
446
				'label' => 'Amazon',
447
			),
448
			array(
449
				'url'   => 'amazon.com',
450
				'icon'  => 'amazon',
451
				'label' => 'Amazon',
452
			),
453
			array(
454
				'url'   => 'apple.com',
455
				'icon'  => 'apple',
456
				'label' => 'Apple',
457
			),
458
			array(
459
				'url'   => 'itunes.com',
460
				'icon'  => 'apple',
461
				'label' => 'iTunes',
462
			),
463
			array(
464
				'url'   => 'bandcamp.com',
465
				'icon'  => 'bandcamp',
466
				'label' => 'Bandcamp',
467
			),
468
			array(
469
				'url'   => 'behance.net',
470
				'icon'  => 'behance',
471
				'label' => 'Behance',
472
			),
473
			array(
474
				'url'   => 'codepen.io',
475
				'icon'  => 'codepen',
476
				'label' => 'CodePen',
477
			),
478
			array(
479
				'url'   => 'deviantart.com',
480
				'icon'  => 'deviantart',
481
				'label' => 'DeviantArt',
482
			),
483
			array(
484
				'url'   => 'digg.com',
485
				'icon'  => 'digg',
486
				'label' => 'Digg',
487
			),
488
			array(
489
				'url'   => 'dribbble.com',
490
				'icon'  => 'dribbble',
491
				'label' => 'Dribbble',
492
			),
493
			array(
494
				'url'   => 'dropbox.com',
495
				'icon'  => 'dropbox',
496
				'label' => 'Dropbox',
497
			),
498
			array(
499
				'url'   => 'etsy.com',
500
				'icon'  => 'etsy',
501
				'label' => 'Etsy',
502
			),
503
			array(
504
				'url'   => 'facebook.com',
505
				'icon'  => 'facebook',
506
				'label' => 'Facebook',
507
			),
508
			array(
509
				'url'   => '/feed/',
510
				'icon'  => 'feed',
511
				'label' => __( 'RSS Feed', 'jetpack' ),
512
			),
513
			array(
514
				'url'   => 'flickr.com',
515
				'icon'  => 'flickr',
516
				'label' => 'Flickr',
517
			),
518
			array(
519
				'url'   => 'foursquare.com',
520
				'icon'  => 'foursquare',
521
				'label' => 'Foursquare',
522
			),
523
			array(
524
				'url'   => 'goodreads.com',
525
				'icon'  => 'goodreads',
526
				'label' => 'Goodreads',
527
			),
528
			array(
529
				'url'   => 'google.com/+',
530
				'icon'  => 'google-plus',
531
				'label' => 'Google +',
532
			),
533
			array(
534
				'url'   => 'plus.google.com',
535
				'icon'  => 'google-plus',
536
				'label' => 'Google +',
537
			),
538
			array(
539
				'url'   => 'google.com',
540
				'icon'  => 'google',
541
				'label' => 'Google',
542
			),
543
			array(
544
				'url'   => 'github.com',
545
				'icon'  => 'github',
546
				'label' => 'GitHub',
547
			),
548
			array(
549
				'url'   => 'instagram.com',
550
				'icon'  => 'instagram',
551
				'label' => 'Instagram',
552
			),
553
			array(
554
				'url'   => 'linkedin.com',
555
				'icon'  => 'linkedin',
556
				'label' => 'LinkedIn',
557
			),
558
			array(
559
				'url'   => 'mailto:',
560
				'icon'  => 'mail',
561
				'label' => __( 'Email', 'jetpack' ),
562
			),
563
			array(
564
				'url'   => 'meetup.com',
565
				'icon'  => 'meetup',
566
				'label' => 'Meetup',
567
			),
568
			array(
569
				'url'   => 'medium.com',
570
				'icon'  => 'medium',
571
				'label' => 'Medium',
572
			),
573
			array(
574
				'url'   => 'getpocket.com',
575
				'icon'  => 'pocket',
576
				'label' => 'Pocket',
577
			),
578
			array(
579
				'url'   => 'reddit.com',
580
				'icon'  => 'reddit',
581
				'label' => 'Reddit',
582
			),
583
			array(
584
				'url'   => 'skype.com',
585
				'icon'  => 'skype',
586
				'label' => 'Skype',
587
			),
588
			array(
589
				'url'   => 'skype:',
590
				'icon'  => 'skype',
591
				'label' => 'Skype',
592
			),
593
			array(
594
				'url'   => 'slideshare.net',
595
				'icon'  => 'slideshare',
596
				'label' => 'SlideShare',
597
			),
598
			array(
599
				'url'   => 'snapchat.com',
600
				'icon'  => 'snapchat',
601
				'label' => 'Snapchat',
602
			),
603
			array(
604
				'url'   => 'soundcloud.com',
605
				'icon'  => 'soundcloud',
606
				'label' => 'SoundCloud',
607
			),
608
			array(
609
				'url'   => 'spotify.com',
610
				'icon'  => 'spotify',
611
				'label' => 'Spotify',
612
			),
613
			array(
614
				'url'   => 'stumbleupon.com',
615
				'icon'  => 'stumbleupon',
616
				'label' => 'StumbleUpon',
617
			),
618
			array(
619
				'url'   => 'tumblr.com',
620
				'icon'  => 'tumblr',
621
				'label' => 'Tumblr',
622
			),
623
			array(
624
				'url'   => 'twitch.tv',
625
				'icon'  => 'twitch',
626
				'label' => 'Twitch',
627
			),
628
			array(
629
				'url'   => 'twitter.com',
630
				'icon'  => 'twitter',
631
				'label' => 'Twitter',
632
			),
633
			array(
634
				'url'   => 'vimeo.com',
635
				'icon'  => 'vimeo',
636
				'label' => 'Vimeo',
637
			),
638
			array(
639
				'url'   => 'vk.com',
640
				'icon'  => 'vk',
641
				'label' => 'VK',
642
			),
643
			array(
644
				'url'   => 'wordpress.com',
645
				'icon'  => 'wordpress',
646
				'label' => 'WordPress.com',
647
			),
648
			array(
649
				'url'   => 'wordpress.org',
650
				'icon'  => 'wordpress',
651
				'label' => 'WordPress',
652
			),
653
			array(
654
				'url'   => 'yelp.com',
655
				'icon'  => 'yelp',
656
				'label' => 'Yelp',
657
			),
658
			array(
659
				'url'   => 'youtube.com',
660
				'icon'  => 'youtube',
661
				'label' => 'YouTube',
662
			),
663
		);
664
665
		return $social_links_icons;
666
	}
667
} // Jetpack_Widget_Social_Icons
668
669
/**
670
 * Register and load the widget.
671
 *
672
 * @access public
673
 * @return void
674
 */
675
function jetpack_widget_social_icons_load() {
676
	register_widget( 'Jetpack_Widget_Social_Icons' );
677
}
678
add_action( 'widgets_init', 'jetpack_widget_social_icons_load' );
679