Nessuna descrizione

bitly.php 942B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Fixes issues with the Official Bitly for WordPress
  4. * https://wordpress.org/plugins/bitly/
  5. *
  6. * @package automattic/jetpack
  7. */
  8. if ( class_exists( 'Bitly' ) ) {
  9. if ( isset( $GLOBALS['bitly'] ) ) {
  10. if ( method_exists( $GLOBALS['bitly'], 'og_tags' ) ) {
  11. remove_action( 'wp_head', array( $GLOBALS['bitly'], 'og_tags' ) );
  12. }
  13. add_action( 'wp_head', 'jetpack_bitly_og_tag', 100 );
  14. }
  15. }
  16. /**
  17. * Adds bitly OG tags.
  18. */
  19. function jetpack_bitly_og_tag() {
  20. if ( has_filter( 'wp_head', 'jetpack_og_tags' ) === false ) {
  21. // Add the bitly part again back if we don't have any jetpack_og_tags added.
  22. if ( method_exists( $GLOBALS['bitly'], 'og_tags' ) ) {
  23. $GLOBALS['bitly']->og_tags();
  24. }
  25. } elseif ( isset( $GLOBALS['posts'] ) && $GLOBALS['posts'][0]->ID > 0 ) {
  26. printf( "<meta property=\"bitly:url\" content=\"%s\" /> \n", esc_attr( $GLOBALS['bitly']->get_bitly_link_for_post_id( $GLOBALS['posts'][0]->ID ) ) );
  27. }
  28. }