kollapsminoriteten/wp-content/plugins/jetpack/modules/likes/jetpack-likes-master-iframe...

49 lines
1.8 KiB
PHP
Raw Normal View History

2019-11-15 23:26:29 +01:00
<?php
2022-06-16 14:01:47 +02:00
/**
* Jetpack likes iframe.
*
* @package jetpack
*/
2019-11-15 23:26:29 +01:00
/**
* This function needs to get loaded after the like scripts get added to the page.
*/
function jetpack_likes_master_iframe() {
2022-12-15 17:41:53 +01:00
$version = gmdate( 'YW' );
2019-11-15 23:26:29 +01:00
$_locale = get_locale();
2022-12-15 17:41:53 +01:00
if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
return false;
}
2019-11-15 23:26:29 +01:00
2022-12-15 17:41:53 +01:00
require_once JETPACK__GLOTPRESS_LOCALES_PATH;
2019-11-15 23:26:29 +01:00
2022-12-15 17:41:53 +01:00
$gp_locale = GP_Locales::by_field( 'wp_locale', $_locale );
$_locale = isset( $gp_locale->slug ) ? $gp_locale->slug : '';
2019-11-15 23:26:29 +01:00
2022-06-16 14:01:47 +02:00
$likes_locale = ( '' === $_locale || 'en' === $_locale ) ? '' : '&amp;lang=' . strtolower( $_locale );
2023-12-07 09:44:11 +01:00
/** This filter is documented in projects/plugins/jetpack/modules/likes.php */
$new_layout = apply_filters( 'likes_new_layout', true ) ? '&amp;n=1' : '';
$new_layout_class = $new_layout ? 'wpl-new-layout' : '';
2019-11-15 23:26:29 +01:00
$src = sprintf(
2023-12-07 09:44:11 +01:00
'https://widgets.wp.com/likes/master.html?ver=%1$s#ver=%1$s%2$s%3$s',
2019-11-15 23:26:29 +01:00
$version,
2023-12-07 09:44:11 +01:00
$likes_locale,
$new_layout
2019-11-15 23:26:29 +01:00
);
2023-12-07 09:44:11 +01:00
if ( $new_layout ) {
// The span content is replaced by queuehandler when showOtherGravatars is called.
$likers_text = wp_kses( '<span>%d</span>', array( 'span' => array() ) );
} else {
/* translators: The value of %d is not available at the time of output */
$likers_text = wp_kses( __( '<span>%d</span> bloggers like this:', 'jetpack' ), array( 'span' => array() ) );
}
2019-11-15 23:26:29 +01:00
?>
2022-06-16 14:01:47 +02:00
<iframe src='<?php echo esc_url( $src ); ?>' scrolling='no' id='likes-master' name='likes-master' style='display:none;'></iframe>
2023-12-07 09:44:11 +01:00
<div id='likes-other-gravatars' class='<?php echo esc_attr( $new_layout_class ); ?>'><div class="likes-text"><?php echo $likers_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div><ul class="wpl-avatars sd-like-gravatars"></ul></div>
2019-11-15 23:26:29 +01:00
<?php
}