jetpack-likes-master-iframe.php 1.3 KB

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