Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
jetpack_likes_master_iframe
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
42
1<?php
2/**
3 * Jetpack likes iframe.
4 *
5 * @package jetpack
6 */
7
8/**
9 * This function needs to get loaded after the like scripts get added to the page.
10 */
11function jetpack_likes_master_iframe() {
12    $version = gmdate( 'Ymd' );
13
14    $_locale = get_locale();
15
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    if ( ! $gp_locale ) {
24        $gp_locale = GP_Locales::by_slug( $_locale );
25    }
26    $_locale = $gp_locale->slug ?? '';
27
28    $likes_locale = ( '' === $_locale || 'en' === $_locale ) ? '' : '&amp;lang=' . strtolower( $_locale );
29
30    $src = sprintf( 'https://widgets.wp.com/likes/master.html?ver=%1$s#ver=%1$s%2$s', $version, $likes_locale );
31
32    /**
33     * Filters the Likes iframe src, if any parameters need to be overridden or tracked.
34     *
35     * @module likes
36     *
37     * @since 14.1
38     *
39     * @param string URL to https://widgets.wp.com/ with various arguments appended to the get string and fragment.
40     */
41    $src = apply_filters( 'jetpack_likes_iframe_src', $src );
42
43    // The span content is replaced by queuehandler when showOtherGravatars is called.
44    $likers_text = wp_kses( '<span>%d</span>', array( 'span' => array() ) );
45    ?>
46    <iframe src='<?php echo esc_url( $src ); ?>' scrolling='no' id='likes-master' name='likes-master' style='display:none;'></iframe>
47    <div id='likes-other-gravatars' role="dialog" aria-hidden="true" tabindex="-1"><div class="likes-text"><?php echo $likers_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div><ul class="wpl-avatars sd-like-gravatars"></ul></div>
48    <?php
49}