Changeset 535305
- Timestamp:
- 04/24/2012 04:06:54 AM (14 years ago)
- File:
-
- 1 edited
-
easy-social-media/trunk/easy-social-media.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-social-media/trunk/easy-social-media.php
r503037 r535305 4 4 Plugin URI: http://www.alexthorpe.com 5 5 Description: This plug in gives you all the social media you need with none of the bloat. Easily add facebbok, google+, pintrest and twitter to each post and a widget with custom icons. 6 Version: 1. 2.26 Version: 1.3 7 7 Author: Alex Thorpe 8 8 Author URI: http://www.alexthorpe.com/ … … 42 42 //facebook JS SDK 43 43 (function(d, s, id) { 44 var js, fjs = d.getElementsByTagName(s)[0];45 if (d.getElementById(id)) return;46 js = d.createElement(s); js.id = id;47 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";48 fjs.parentNode.insertBefore(js, fjs);44 var js, fjs = d.getElementsByTagName(s)[0]; 45 if (d.getElementById(id)) return; 46 js = d.createElement(s); js.id = id; 47 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; 48 fjs.parentNode.insertBefore(js, fjs); 49 49 }(document, 'script', 'facebook-jssdk')); 50 50 … … 119 119 add_action("wp", "load_social"); 120 120 121 //Facebook opengraph 122 add_filter('language_attributes', 'add_og_xml_ns'); 123 function add_og_xml_ns($content) { 124 return ' xmlns:og="http://ogp.me/ns#" ' . $content; 125 } 126 127 add_filter('language_attributes', 'add_fb_xml_ns'); 128 function add_fb_xml_ns($content) { 129 return ' xmlns:fb="https://www.facebook.com/2008/fbml" ' . $content; 130 } 131 132 function get_fbimage() { 133 $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '', '' ); 134 if ( has_post_thumbnail($post->ID) ) { 135 $fbimage = $src[0]; 136 } else { 137 global $post, $posts; 138 $fbimage = ''; 139 $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', 140 $post->post_content, $matches); 141 $fbimage = $matches [1] [0]; 142 } 143 if(empty($fbimage)) { 144 $fbimage = ""; 145 } 146 return $fbimage; 147 } 148 149 function add_facebook_meta() { ?> 150 <meta property="og:title" content="<?php the_title(); ?>"/> 151 <meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>" /> 152 <meta property="og:url" content="<?php the_permalink(); ?>"/> 153 <meta property="og:image" content="<?php echo get_fbimage(); ?>"/> 154 <meta property="og:type" content="<?php if (is_single() || is_page()) { echo "article"; } else { echo "website";} ?>"/> 155 <meta property="og:site_name" content="<?php bloginfo('name'); ?>"/> 156 <?php } 157 121 158 function load_social() { 122 159 if(is_single() && !is_admin()) { 160 add_action('wp_head', 'add_facebook_meta'); 123 161 add_action('wp_footer','add_social_js'); 124 162 add_filter('the_content','add_social_buttons');
Note: See TracChangeset
for help on using the changeset viewer.