Нет описания

googleplus.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Google+ embeds
  4. * Google+ has shut down. Output the link for history's sake.
  5. * Other than that, there's not much we can do.
  6. *
  7. * @package automattic/jetpack
  8. */
  9. define( 'JETPACK_GOOGLEPLUS_EMBED_REGEX', '#^https?://plus\.(sandbox\.)?google\.com/(u/\d+/)?([^/]+)/posts/([^/]+)$#' );
  10. /*
  11. * Example URL: https://plus.google.com/114986219448604314131/posts/LgHkesWCmJo
  12. * Alternate example: https://plus.google.com/u/0/100004581596612508203/posts/2UKwN67MBQs (note the /u/0/)
  13. */
  14. wp_embed_register_handler( 'googleplus', JETPACK_GOOGLEPLUS_EMBED_REGEX, 'jetpack_deprecated_embed_handler' );
  15. add_shortcode( 'googleplus', 'jetpack_googleplus_shortcode_handler' );
  16. /**
  17. * Display the Google+ shortcode.
  18. *
  19. * @param array $atts Shortcode attributes.
  20. */
  21. function jetpack_googleplus_shortcode_handler( $atts ) {
  22. global $wp_embed;
  23. if ( empty( $atts['url'] ) ) {
  24. return;
  25. }
  26. if ( ! preg_match( JETPACK_GOOGLEPLUS_EMBED_REGEX, $atts['url'] ) ) {
  27. return;
  28. }
  29. return sprintf( '<p>%s</p>', $wp_embed->shortcode( $atts, $atts['url'] ) );
  30. }