Completed
Push — try/move-comment-likes-to-pack... ( 10f739...a53827 )
by
unknown
08:10
created

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

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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