plugins.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /*
  3. Bones Plugins & Extra Functionality
  4. Author: Eddie Machado
  5. URL: http://themble.com/bones/
  6. This file contains extra features not 100% ready to be included
  7. in the core. Feel free to edit anything here or even help us fix
  8. and optimize the code!
  9. IF YOU WANT TO SUBMIT A FIX OR CORRECTION, JOIN US ON GITHUB:
  10. https://github.com/eddiemachado/bones/issues
  11. IF YOU WANT TO DISABLE THIS FILE, REMOVE IT'S CALL IN THE FUNCTIONS.PHP FILE
  12. */
  13. /*
  14. Facebook Connect Image Fix
  15. This was built of a post from Yoast that should
  16. fix the facebook issue when sharing something w/
  17. facebook where it selects a random photo from
  18. your site. This should use a photo from the actual post.
  19. */
  20. // facebook share correct image fix (thanks to yoast)
  21. function bones_facebook_connect() {
  22. if (is_singular()) {
  23. global $post;
  24. if ( current_theme_supports('post-thumbnails')
  25. && has_post_thumbnail( $post->ID ) ) {
  26. $thumbnail = wp_get_attachment_image_src(
  27. get_post_thumbnail_id( $post->ID ), 'thumbnail', false);
  28. echo '<meta property="og:image"
  29. content="'.$thumbnail[0].'" />';
  30. }
  31. echo '<meta property="og:title"
  32. content="'.get_the_title().'" />';
  33. if ( get_the_excerpt() != '' )
  34. echo '<meta property="og:description"
  35. content="'.strip_tags( get_the_excerpt() ).'" />';
  36. }
  37. }
  38. // add this in the header
  39. add_action('wp_head', 'bones_facebook_connect');
  40. // adding the rel=me thanks to yoast
  41. function yoast_allow_rel() {
  42. global $allowedtags;
  43. $allowedtags['a']['rel'] = array ();
  44. }
  45. add_action( 'wp_loaded', 'yoast_allow_rel' );
  46. // adding facebook, twitter, & google+ links to the user profile
  47. function bones_add_user_fields( $contactmethods ) {
  48. // Add Facebook
  49. $contactmethods['user_fb'] = 'Facebook';
  50. // Add Twitter
  51. $contactmethods['user_tw'] = 'Twitter';
  52. // Add Google+
  53. $contactmethods['google_profile'] = 'Google Profile URL';
  54. // Save 'Em
  55. return $contactmethods;
  56. }
  57. add_filter('user_contactmethods','bones_add_user_fields',10,1);
  58. ?>