Backtype Tweetcount plugin. Version: 0.9.2 Author: FBShare.Me Author URI: http://www.fbshare.me/ */ /* Copyright 2009 Snowball Factory, Inc (email : info@snowballfactory.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ if (is_admin()) { add_action('admin_menu', 'fbsc_options'); add_action('admin_init', 'fbsc_init'); register_activation_hook(__FILE__, 'fbsc_activate'); } add_filter('the_content', 'fbsc_update'); add_filter('get_the_excerpt', 'fbsc_remove_filter', 9); function fbsc_options() { add_options_page('FB Sharecount Settings', 'Sharecount for Facebook', 8, 'facebook-sharecount', 'fbsc_options_page'); } // Register these variables (WP 2.7 & newer) function fbsc_init() { if (function_exists('register_setting')) { register_setting('fbsc-options', 'fbsc_size'); register_setting('fbsc-options', 'fbsc_location'); register_setting('fbsc-options', 'fbsc_style'); register_setting('fbsc-options', 'fbsc_api_key'); register_setting('fbsc-options', 'fbsc_google_analytics'); register_setting('fbsc-options', 'fbsc_badge_text'); register_setting('fbsc-options', 'fbsc_badge_color'); register_setting('fbsc-options', 'fbsc_pages'); } } // default options function fbsc_activate() { add_option('fbsc_size', 'large'); add_option('fbsc_location', 'top'); add_option('fbsc_style', 'float:left;margin-right:10px;'); add_option('fbsc_api_key', ''); add_option('fbsc_google_analytics', ''); add_option('fbsc_badge_text', ''); add_option('fbsc_badge_color', ''); add_option('fbsc_pages', 'true'); } function fbsc_update($content) { global $post; if (get_option('fbsc_location') == 'manual') { return $content; } if (is_feed()) { return $content; } if (is_page() and (get_option('fbsc_pages') != 'true')) { return $content; } if (get_post_meta($post->ID, 'fbsc', true) == '') { $button = facebook_sharecount(); switch (get_option('fbsc_location')) { case 'topbottom': return $button . $content . $button; break; case 'top': return $button . $content; break; case 'bottom': return $content . $button; break; default: return $button . $content; break; } } else { return $content; } } function fbsc_remove_filter($content) { remove_action('the_content', 'fbsc_update'); return $content; } function fbsc_options_page() { echo '
'; if (function_exists('screen_icon')) { screen_icon(); } echo'

Sharecount for Facebook

'; echo '
'; wp_nonce_field('update-options'); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
Size
Location For manual positioning, echo facebook_sharecount(); where you would like the button to appear
Wrapper Style CSS for positioning, margins, etc
Badge Color Color of the badge background in large button (use standard CSS RGB hex codes, *do not* include a leading #)
Badge Text Color of the badge text in large button (use standard CSS RGB hex codes, *do not* include a leading #)
Show Button on Pages Show the button on Pages as well as Posts

The button will generate fbshare.me links by default unless you have an awe.sm account

'; echo ''; echo ''; echo '
awe.sm API Key Optional: will use your awe.sm account settings if specified
Google Analytics Parameters Adds Google Analytics parameters to fbshare.me links (if no awe.sm API Key specified)
'; echo '

'; } function facebook_sharecount($size=null, $style=null, $api_key=null, $google_analytics=null, $badge_color=null, $badge_text=null) { global $post; $url = ''; $cnt = null; // let users override these vars when calling manually $size = ($size === null) ? get_option('fbsc_size') : $size; $style = ($style === null) ? get_option('fbsc_style') : $style; $api_key = ($api_key === null) ? get_option('fbsc_api_key') : $api_key; $google_analytics = ($google_analytics === null) ? get_option('fbsc_google_analytics') : $google_analytics; $badge_color = ($badge_color === null) ? get_option('fbsc_badge_color') : $badge_color; $badge_text = ($badge_text === null) ? get_option('fbsc_badge_text') : $badge_text; if (get_post_status($post->ID) == 'publish') { $url = get_permalink(); $title = $post->post_title; if ((function_exists('curl_init') || function_exists('file_get_contents')) && function_exists('unserialize')) { $meta = get_post_meta($post->ID, 'fbsc_cache', true); if ($meta != '') { $pieces = explode(':', $meta); $timestamp = (int)$pieces[0]; $cnt = (int)$pieces[1]; } } } if ($style !== '') { $button = '
'; } else { $button = ''; } if ($size == 'small') { $button .= ''; if ($style !== '') { $button .= '
'; } return $button; } function fbsc_urlopen($url) { if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); $result = curl_exec($ch); curl_close($ch); return $result; } else { return file_get_contents($url); } } ?>