plugins.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. Social Integration
  15. This is a collection of snippets I edited or reused from
  16. social plugins. No need to use a plugin when you can
  17. replicate it in only a few lines I say, so here we go.
  18. For more info, or to add more open graph stuff, check
  19. out: http://yoast.com/facebook-open-graph-protocol/
  20. */
  21. // get the image for the google + and facebook integration
  22. function bones_get_socialimage() {
  23. $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '', '' );
  24. if ( has_post_thumbnail($post->ID) ) {
  25. $socialimg = $src[0];
  26. } else {
  27. global $post, $posts;
  28. $socialimg = '';
  29. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',
  30. $post->post_content, $matches);
  31. $socialimg = $matches [1] [0];
  32. }
  33. if(empty($socialimg)) {
  34. $socialimg = get_template_directory_uri() . '/library/images/nothumb.gif';
  35. }
  36. return $socialimg;
  37. }
  38. // facebook share correct image fix (thanks to yoast)
  39. function bones_facebook_connect() {
  40. echo "\n" . '<!-- facebook open graph stuff -->' . "\n";
  41. echo '<!-- place your facebook app id below -->';
  42. echo '<meta property="fb:app_id" content="1234567890"/>' . "\n";
  43. global $post;
  44. echo '<meta property="og:site_name" content="'. get_bloginfo("name") .'"/>' . "\n";
  45. echo '<meta property="og:url" content="'. get_permalink() .'"/>' . "\n";
  46. echo '<meta property="og:title" content="'.get_the_title().'" />' . "\n";
  47. if (is_singular()) {
  48. echo '<meta property="og:type" content="article"/>' . "\n";
  49. echo '<meta property="og:description" content="' .strip_tags( get_the_excerpt() ).'" />' . "\n";
  50. }
  51. echo '<meta property="og:image" content="'. bones_get_socialimage() .'"/>' . "\n";
  52. echo '<!-- end facebook open graph -->' . "\n";
  53. }
  54. // google +1 meta info
  55. function bones_google_header() {
  56. if (is_singular()) {
  57. echo '<!-- google +1 tags -->' . "\n";
  58. global $post;
  59. echo '<meta itemprop="name" content="'.get_the_title().'">' . "\n";
  60. echo '<meta itemprop="description" content="' .strip_tags( get_the_excerpt() ).'">' . "\n";
  61. echo '<meta itemprop="image" content="'. bones_get_socialimage() .'">' . "\n";
  62. echo '<!-- end google +1 tags -->' . "\n";
  63. }
  64. }
  65. // add this in the header
  66. add_action('wp_head', 'bones_facebook_connect');
  67. add_action('wp_head', 'bones_google_header');
  68. // adding the rel=me thanks to yoast
  69. function yoast_allow_rel() {
  70. global $allowedtags;
  71. $allowedtags['a']['rel'] = array ();
  72. }
  73. add_action( 'wp_loaded', 'yoast_allow_rel' );
  74. // adding facebook, twitter, & google+ links to the user profile
  75. function bones_add_user_fields( $contactmethods ) {
  76. // Add Facebook
  77. $contactmethods['user_fb'] = 'Facebook';
  78. // Add Twitter
  79. $contactmethods['user_tw'] = 'Twitter';
  80. // Add Google+
  81. $contactmethods['google_profile'] = 'Google Profile URL';
  82. // Save 'Em
  83. return $contactmethods;
  84. }
  85. add_filter('user_contactmethods','bones_add_user_fields',10,1);
  86. ?>