| @@ -8,9 +8,9 @@ | ||
| 8 | 8 | /** |
| 9 | 9 | * This function needs to get loaded after the like scripts get added to the page. |
| 10 | 10 | */ |
| 11 | 11 | function jetpack_likes_master_iframe() { |
| 12 | - $version = gmdate( 'YW' ); | |
| 12 | + $version = gmdate( 'Ymd' ); | |
| 13 | 13 | |
| 14 | 14 | $_locale = get_locale(); |
| 15 | 15 | |
| 16 | 16 | if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) { |
| @@ -19,21 +19,31 @@ | ||
| 19 | 19 | |
| 20 | 20 | require_once JETPACK__GLOTPRESS_LOCALES_PATH; |
| 21 | 21 | |
| 22 | 22 | $gp_locale = GP_Locales::by_field( 'wp_locale', $_locale ); |
| 23 | - $_locale = isset( $gp_locale->slug ) ? $gp_locale->slug : ''; | |
| 23 | + if ( ! $gp_locale ) { | |
| 24 | + $gp_locale = GP_Locales::by_slug( $_locale ); | |
| 25 | + } | |
| 26 | + $_locale = $gp_locale->slug ?? ''; | |
| 24 | 27 | |
| 25 | 28 | $likes_locale = ( '' === $_locale || 'en' === $_locale ) ? '' : '&lang=' . strtolower( $_locale ); |
| 26 | 29 | |
| 27 | - $src = sprintf( | |
| 28 | - 'https://widgets.wp.com/likes/master.html?ver=%1$s#ver=%1$s%2$s', | |
| 29 | - $version, | |
| 30 | - $likes_locale | |
| 31 | - ); | |
| 30 | + $src = sprintf( 'https://widgets.wp.com/likes/master.html?ver=%1$s#ver=%1$s%2$s', $version, $likes_locale ); | |
| 32 | 31 | |
| 33 | - /* translators: The value of %d is not available at the time of output */ | |
| 34 | - $likers_text = wp_kses( __( '<span>%d</span> bloggers like this:', 'jetpack' ), array( 'span' => array() ) ); | |
| 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() ) ); | |
| 35 | 45 | ?> |
| 36 | 46 | <iframe src='<?php echo esc_url( $src ); ?>' scrolling='no' id='likes-master' name='likes-master' style='display:none;'></iframe> |
| 37 | - <div id='likes-other-gravatars'><div class="likes-text"><?php echo $likers_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div><ul class="wpl-avatars sd-like-gravatars"></ul></div> | |
| 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> | |
| 38 | 48 | <?php |
| 39 | 49 | } |