plugins.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. global $post, $posts;
  24. $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '', '' );
  25. if ( has_post_thumbnail($post->ID) ) {
  26. $socialimg = $src[0];
  27. } else {
  28. $socialimg = '';
  29. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  30. if (array_key_exists(1, $matches))
  31. if (array_key_exists(0, $matches[1]))
  32. $socialimg = $matches [1] [0];
  33. }
  34. if(empty($socialimg))
  35. $socialimg = get_template_directory_uri() . '/library/images/nothumb.gif';
  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. ?>