bitly.php 924 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /*
  3. * Fixes issues with the Official Bitly for WordPress
  4. * https://wordpress.org/plugins/bitly/
  5. */
  6. if( class_exists( 'Bitly' ) ) {
  7. if( isset( $GLOBALS['bitly'] ) ) {
  8. if ( method_exists( $GLOBALS['bitly'], 'og_tags' ) ) {
  9. remove_action( 'wp_head', array( $GLOBALS['bitly'], 'og_tags' ) );
  10. }
  11. add_action( 'wp_head', 'jetpack_bitly_og_tag', 100 );
  12. }
  13. }
  14. /**
  15. * jetpack_bitly_og_tag
  16. *
  17. * @return null
  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. }