Completed
Push — add/jetpack-start-reconnect-us... ( 7f1fbb )
by
unknown
10:36
created

jetpack-likes-master-iframe.php ➔ jetpack_likes_master_iframe()   D

Complexity

Conditions 9
Paths 52

Size

Total Lines 33
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 20
nc 52
nop 0
dl 0
loc 33
rs 4.909
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This function needs to get loaded after the like scripts get added to the page.
5
 */
6
function jetpack_likes_master_iframe() {
7
	$version = '20170629';
8
	$in_jetpack = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? false : true;
9
10
	$_locale = get_locale();
11
12
	// We have to account for w.org vs WP.com locale divergence
13
	if ( $in_jetpack ) {
14
		if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
15
			return false;
16
		}
17
18
		require_once JETPACK__GLOTPRESS_LOCALES_PATH;
19
20
		$gp_locale = GP_Locales::by_field( 'wp_locale', $_locale );
21
		$_locale = isset( $gp_locale->slug ) ? $gp_locale->slug : '';
22
	}
23
24
	$likes_locale = ( '' == $_locale || 'en' == $_locale ) ? '' : '&amp;lang=' . strtolower( $_locale );
25
26
	$src = sprintf(
27
		'https://widgets.wp.com/likes/master.html?ver=%1$s#ver=%1$s%2$s',
28
		$version,
29
		$likes_locale
30
	);
31
32
	/* translators: The value of %d is not available at the time of output */
33
	$likersText = wp_kses( __( '<span>%d</span> bloggers like this:', 'jetpack' ), array( 'span' => array() ) );
34
	?>
35
	<iframe src='<?php echo $src; ?>' scrolling='no' id='likes-master' name='likes-master' style='display:none;'></iframe>
36
	<div id='likes-other-gravatars'><div class="likes-text"><?php echo $likersText; ?></div><ul class="wpl-avatars sd-like-gravatars"></ul></div>
37
	<?php
38
}
39