rxtt = $table_prefix . 'tweet_this_scheduled'; define('TT_FILE_LOC', '?page=' . TT_DIR . '/' . basename(__FILE__));} else { global $wpdb; $wpdb->rxtt = $wpdb->prefix . 'tweet_this_scheduled'; define('TT_FILE_LOC', '?page=' . basename(__FILE__));} if(file_exists(TT_CONFIG)) require_once(TT_CONFIG); /** * Do not edit these here, but rather, in the tt-config.php file. */ if(!defined('TT_PREFIX')) define('TT_PREFIX', '

'); if(!defined('TT_SUFFIX')) define('TT_SUFFIX', '

'); if(!defined('TT_SEPARATOR')) define('TT_SEPARATOR', ' '); if(!defined('TT_OVERRIDE_OPTIONS')) define('TT_OVERRIDE_OPTIONS', true); if(!defined('TT_HIDE_MENU')) define('TT_HIDE_MENU', false); if(!defined('TT_SPECIAL_OPTIONS')) define('TT_SPECIAL_OPTIONS', ''); /** * JSON functions. * @package tweet-this * @since 1.7 */ if(!function_exists('json_encode')) { function json_encode($data) { $json = new Services_JSON(); return($json->encode($data));}} if(!function_exists('json_decode')) { function json_decode($data) { $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); return($json->decode($data));}} /** * Backward compatible version of mb_substr uses substr on PHP 4.0.0 - 4.0.5. * @package tweet-this * @since 1.8 */ function tt_mb_substr($str = '', $start = 0, $length = 70) { if(function_exists('mb_substr')) return mb_substr($str, $start, $length); else return substr($str, $start, $length); } /** * Access to serialized Tweet This options with mapping. * @package tweet-this * @since 1.3 */ function tt_option($key) { if(defined('TT_OVERRIDE_OPTIONS') && defined('TT_SPECIAL_OPTIONS') && TT_OVERRIDE_OPTIONS == true && TT_SPECIAL_OPTIONS != '' && unserialize(TT_SPECIAL_OPTIONS) != false) $options = unserialize(TT_SPECIAL_OPTIONS); else $options = get_option('tweet_this_settings'); if($key == 'nw') { if($options['tt_new_window'] == 'true') return 'target="_blank" '; else return '';} elseif($key == 'nf') { if($options['tt_nofollow'] == 'true') return 'rel="nofollow" '; else return '';} elseif($key == 'tt_alignment') { if($options['tt_alignment'] == '' || ($options['tt_alignment'] != 'left' && $options['tt_alignment'] != 'right' && $options['tt_alignment'] != 'center')) return 'left'; else return $options['tt_alignment'];} elseif($key == 'tt_twitter') return stripslashes(htmlentities($options['tt_auto_display'])); elseif($key == 'tt_twitter_text') return stripslashes(htmlentities($options['tt_tweet_text'])); elseif($key == 'tt_twitter_link_text') return stripslashes(htmlentities($options['tt_link_text'])); elseif($key == 'tt_twitter_title_text') return stripslashes(htmlentities($options['tt_title_text'])); elseif($key == 'tt_css' && ($options['tt_css'] == 'img.[IMG_CLASS]{border:0;}' || $options['tt_css'] == 'a.[LINK_CLASS]{text-decoration:none;border:0;}')) return 'img.[IMG_CLASS]{border:0;margin:0 0 0 2px ' . '!important;}'; elseif($key == 'tt_textbox_size' && strlen($options[$key]) > 4) return '60'; elseif($key == 'tt_service_order' && strlen($options[$key]) < 4) return 'twitter, plurk, bebo, buzz, delicious, digg, ' . 'diigo, facebook, ff, gbuzz, gmail, linkedin, ' . 'mixx, myspace, ping, reddit, slashdot, squidoo, ' . 'su, technorati'; // Voodoo to convert pre-1.8 icon paths to 1.8 paths on the fly. elseif(substr($key, -5) == '_icon' && (substr($options[$key], 0, 3) == 'tt-' || substr($options[$key], 0, 6) == 'de/tt-')) return str_replace('tt-', 'en/', substr($options[$key], 0, 3)) . substr($key, 3, -5) . '/' . str_replace('-de.png', '.png', $options[$key]); else return stripslashes(htmlentities($options[$key])); } /** * Same as tt_option($key). * @package tweet-this * @since 1.7 */ function get_tt_option($key) { return tt_option($key); } /** * Reads an external URL by file_get_contents($url) or Curl. * @package tweet-this * @since 1.3.5 */ function tt_read_file($url) { if(ini_get('allow_url_fopen') == 1 || strtolower(ini_get('allow_url_fopen')) == 'on') { $file = @file_get_contents($url); if($file == false) { $handle = @fopen($url, 'r'); $file = @fread($handle, 4096); @fclose($handle);}} else { if(function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $file = curl_exec($ch); curl_close($ch);}} if($file != false && $file != '') return $file; } /** * Same as tt_read_file($url). * @package tweet-this * @since 1.7.6 */ function get_tt_read_file($url) { return tt_read_file($url); } /** * Creates the shortened URL for the current post within the loop. * @package tweet-this * @since 1.1 */ function get_tweet_this_short_url($longurl = '', $post_id = '', $return = true, $admin = false, $service = '', $force = false) { if($admin != true) { global $id, $post; if($post_id == '') $post_id = $id; $cached_url = get_post_meta($post_id, 'tweet_this_url', true); $post_status = $post->post_status;} if($longurl != '') $purl = str_replace('t9WGb5', '_', $longurl); else $purl = get_permalink(); $purl = str_replace('https://', 'http://', $purl); $sn_purl = rawurlencode($purl); $purl = urlencode($purl); if($cached_url && $cached_url != 'getnew' && $admin != true) return $cached_url; elseif($post_status && $post_status != 'publish' && tt_option('tt_url_service') != 'local' && tt_option('tt_url_service') != '' && $force == false) return; else { if($admin == true) { $get_service = tt_option('tt_admin_url_service'); if($get_service == 'same') $get_service = tt_option('tt_url_service');} else $get_service = tt_option('tt_url_service'); if($service != '') $u = $service; else $u = str_replace('snurl', 'snipurl', $get_service); if((ini_get('allow_url_fopen') != 1 && strtolower(ini_get('allow_url_fopen')) != 'on' && !function_exists('curl_init')) || ($u == 'adjix' && tt_option('tt_adjix_api_key') == '') || ($u == 'snipurl' && (!function_exists('curl_init') || tt_option('tt_snipurl_username') == '' || tt_option('tt_snipurl_api_key') == '')) || ($u == 'tweetburner' && !function_exists('curl_init'))) $u = 'local'; if(($u == '' || $u == 'same' || $u == 'local') && $admin == true) $u = 'bit.ly'; switch($u) { case 'adjix': { if(tt_option('tt_ad_vu') != 'false') $ad_vu = '&ultraShort=y'; $url = tt_read_file('http://api.adjix.com/shrinkLink' . '?url=' . $purl . '&partnerID=' . tt_option('tt_adjix_api_key') . $ad_vu);} break; case 'b2l.me': $url = tt_read_file('http://b2l.me/api.php?alias=' . '&url=' . $purl); break; case 'bit.ly': { if(tt_option('tt_bitly_username') != '' && tt_option('tt_bitly_api_key') != '') { $decoded = json_decode(tt_read_file('http://' . 'api.bit.ly/v3/shorten?longUrl=' . $purl . '&login=' . tt_option('tt_bitly_username') . '&apiKey=' . tt_option('tt_bitly_api_key') . '&format=json'), 'true'); if($decoded['status_code'] == '200') $url = $decoded['data']['url']; else $url = tt_read_file('http://bit.ly/' . 'api?url=' . $purl);} else $url = tt_read_file('http://bit.ly/api?url=' . $purl); if(tt_option('tt_j_mp') == 'true') $url = str_replace('http://bit.ly/', 'http://j.mp/', $url);} break; case 'is.gd': $url = tt_read_file('http://is.gd/api.php?longurl=' . $purl); break; case 'metamark': $url = tt_read_file('http://metamark.net/api/rest/' . 'simple?long_url=' . $purl); break; case 'snipurl': { $sn_api = 'http://snipurl.com/site/getsnip'; $sn_post = 'sniplink=' . $sn_purl . '&snipuser=' . tt_option('tt_snipurl_username') . '&snipapi=' . tt_option('tt_snipurl_api_key') . '&snipformat=simple'; $ch = curl_init($sn_api); curl_setopt($ch, CURLOPT_URL, $sn_api); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $sn_post); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $url = curl_exec($ch); curl_close($ch); if(tt_option('tt_snipurl_domain') == 'snipr.com') $url = str_replace('http://snipurl.com/', 'http://snipr.com/', $url); elseif(tt_option('tt_snipurl_domain') == 'snurl.com') $url = str_replace('http://snipurl.com/', 'http://snurl.com/', $url); elseif(tt_option('tt_snipurl_domain') == 'sn.im') $url = str_replace('http://snipurl.com/', 'http://sn.im/', $url); elseif(tt_option('tt_snipurl_domain') == 'cl.lk') $url = str_replace('http://snipurl.com/', 'http://cl.lk/', $url);} break; case 'su.pr': { if(tt_option('tt_supr_username') != '' && tt_option('tt_supr_api_key') != '') $supr_api = '&login=' . tt_option('tt_supr_username') . '&apiKey=' . tt_option('tt_supr_api_key'); $url = tt_read_file('http://su.pr/api/simpleshorten?' . 'url=' . $purl . $supr_api);} break; case 'tinyurl': $url = tt_read_file('http://tinyurl.com/' . 'api-create.php?url=' . $purl); break; case 'tweetburner': { $tw_post = 'link[url]=' . $purl; $ch = curl_init('http://tweetburner.com/links'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $tw_post); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $url = curl_exec($ch); curl_close($ch);} break; case 'local': default: $url = TT_BLOG_URL . '/?p=' . $post_id; break; case 'custom': $url = tt_read_file(str_replace('[LONGURL]', $purl, tt_option('tt_custom_url_service'))); break;} // Tweetburner URLs cannot be accessed with the www subdomain. // It's not safe to replace http:// with www. outright because if // the blog already has the www subdomain you will get www.www. if(tt_option('tt_url_www') == 'true' && $u != 'tweetburner') { $url = str_replace('http://', 'www.', str_replace('http://www.', 'www.', $url));} // If short URL > 30 characters, is error, or is malformed, discard. if($u != 'local' && $u != 'custom' && $admin != true && (strlen($url) > 30 || strtolower($url) == 'error' || $url == 'www.' || $url == 'http://' || $url == '')) $url = TT_BLOG_URL . '/?p=' . $post_id; if($admin != true) { if($cached_url == 'getnew') update_post_meta($post_id, 'tweet_this_url', $url, 'getnew'); else add_post_meta($post_id, 'tweet_this_url', $url, true);} if($return != false) return $url;} } /** * Echoes the above function for convenience. * @package tweet-this * @since 1.1 */ function tweet_this_short_url($longurl = '', $post_id = '', $return = true, $admin = false, $service = '', $force = false) { echo get_tweet_this_short_url($longurl, $post_id, $return, $admin, $service, $force); } /** * Gets a post by ID with backward compatibility for WP 1.5. * Always returns an associative array. * @package tweet-this * @since 1.7.7 */ function tt_get_post($post_id = '') { if($post_id == '') {global $id; $post_id = $id;} $postdata = null; if(function_exists('get_post')) $postdata = get_post($post_id, ARRAY_A); else { $postdata = get_postdata($post_id); $postdata['post_author'] = $postdata['Author_ID']; $postdata['post_date'] = $postdata['Date']; $postdata['post_content'] = $postdata['Content']; $postdata['post_excerpt'] = $postdata['Excerpt']; $postdata['post_title'] = $postdata['Title']; $postdata['post_category'] = $postdata['Category'];} return $postdata; } /** * Backward compatible function to get the author nickname in the loop. * @package tweet-this * @since 1.8 */ function tt_get_the_author($post_id = '') { if($post_id == '') {global $id; $post_id = $id;} // tt_get_post($post_id) will not work here, for unknown reasons. if(function_exists('get_post')) { $gp = get_post($post_id); $author_id = $gp->post_author;} else { $gp = get_postdata($post_id); $author_id = $gp['Author_ID'];} if(function_exists('get_the_author_meta')) return get_the_author_meta('display_name', $author_id); else return get_the_author_nickname(); } /** * Returns the first category of the current post in the loop. * @package tweet-this * @since 1.8 */ function tt_get_the_category($post_id = '') { if($post_id == '') {global $id; $post_id = $id;} $category = null; $categories = get_the_category($post_id); if($categories > 0) $category = $categories[0]->cat_name; return $category; } /** * Backward compatible function to strip shortcodes. * @package tweet-this * @since 1.8 */ function tt_strip_shortcodes($text) { if(function_exists('strip_shortcodes')) return strip_shortcodes($text); else return $text; } /** * Returns the post excerpt, truncated with "..." if it exceeds $chars. * @package tweet-this * @since 1.8 */ function tt_get_the_excerpt($post_id = '', $chars = 70) { if($post_id == '') {global $id; $post_id = $id;} // tt_get_post($post_id) will not work here, for unknown reasons. if(function_exists('get_post')) { $gp = get_post($post_id); $content = $gp->post_content; $excerpt = $gp->post_excerpt;} else { $gp = get_postdata($post_id); $content = $gp['Content']; $excerpt = $gp['Excerpt'];} if(trim($excerpt) != '') $pxcr = strip_tags(tt_strip_shortcodes($excerpt)); else $pxcr = strip_tags(tt_strip_shortcodes($content)); if(strlen($pxcr) > $chars) $pxcr = tt_mb_substr($pxcr, 0, ($chars - 3)) . '...'; return $pxcr; } /** * Truncates the post title with "..." if we are over 140 characters. * @package tweet-this * @since 1.1 */ function get_tweet_this_trim_title($title = '', $tweet_text = '', $service = 'twitter', $encode = true) { if($title == '') $title = get_the_title(); if($tweet_text == '') { if($service == 'twitter-share') $tweet_text = tt_option('tt_twitter_share_text'); else $tweet_text = tt_option('tt_tweet_text');} $tweet_text = str_replace(array('[AUTHOR]', '[CATEGORY]', '[DATE]', '[TIME]', '[EXCERPT]', '[BLOG_TITLE]'), array('', '', '', '', '', ''), $tweet_text); $tweet_text = preg_replace("/(\040)+/", " ", $tweet_text); $title = @html_entity_decode($title, ENT_COMPAT, 'UTF-8'); if($service == 'twitter-share') { if(tt_option('tt_twitter_share_via') == '[BLANK]') $via_len = 0; else $via_len = strlen(tt_option('tt_twitter_share_via')); if($via_len != 0) $via_len += 6;} else $via_len = 0; $tt_len = max((strlen($tweet_text) - 12), 1); if($service == 'twitter-share') $url_len = constant('TT_TCO_LEN'); else $url_len = get_tt_url_service_len(); $lens = $tt_len + $url_len + $via_len; if(strlen($title) > (140 - $lens)) $title = tt_mb_substr($title, 0, (137 - $lens)) . '...'; if($encode == true) $title = urlencode($title); return $title; } /** * Echoes the above function for convenience. * @package tweet-this * @since 1.1 */ function tweet_this_trim_title($title = '', $tweet_text = '', $service = 'twitter', $encode = true) { echo get_tweet_this_trim_title($title, $tweet_text, $service, $encode); } /** * Performs replacements on a string for the current post in the loop. * @package tweet-this * @since 1.7.7 */ function get_tt_parse_string($text = '', $url = '', $space = ' ', $service = 'twitter', $title = '') { if($url == '') $url = get_tweet_this_short_url(); if($title == '') $title = get_the_title(); $matches = array('[TITLE]', '[TITLE_SHARE]', '[AUTHOR]', '[CATEGORY]', '[DATE]', '[TIME]', '[EXCERPT]', '[BLOG_TITLE]', ' '); $replacements = array(get_tweet_this_trim_title($title, $text, 'twitter', false), get_tweet_this_trim_title($title, $text, 'twitter-share', false), tt_get_the_author(), tt_get_the_category(), get_the_time(get_option('date_format')), get_the_time(get_option('time_format')), tt_get_the_excerpt(), get_bloginfo('name'), ' '); $final_text = str_replace($matches, $replacements, $text); if($service != 'twitter-share' && strpos($final_text, '[URL]') !== false && (strlen($final_text) > (145 - get_tt_url_service_len()))) { if(strpos($final_text, '[URL]') > (135 - get_tt_url_service_len())) $final_text = tt_mb_substr(preg_replace("/(\040)+/", " ", str_replace('[URL]', '', $final_text)), 0, (136 - get_tt_url_service_len())) . '... ' . $url; else $final_text = tt_mb_substr(preg_replace("/(\040)+/", " ", $final_text), 0, (142 - get_tt_url_service_len())) . '...';} elseif($service != 'twitter-share' && strpos($final_text, '[URL]') === false && strlen($final_text) > 140) $final_text = tt_mb_substr($final_text, 0, 137) . '...'; $final_text = str_replace('[URL]', $url, $final_text); return str_replace(' ', $space, $final_text); } /** * Echoes the above function for convenience. * @package tweet-this * @since 1.7.7 */ function tt_parse_string($text = '', $url = '', $space = ' ', $service = 'twitter', $title = '') { echo get_tt_parse_string($text, $url, $space, $service, $title); } /** * Returns the link text array or the title/alt text array. * @package tweet-this * @since 1.7.7 */ function tt_service_array($array = 'link') { $services = array('twitter' => __('Tweet This Post', 'tweet-this'), 'plurk' => __('Plurk This Post', 'tweet-this'), 'bebo' => __('Post to Bebo', 'tweet-this'), 'buzz' => __('Buzz This Post', 'tweet-this'), 'delicious' => __('Post to Delicious', 'tweet-this'), 'digg' => __('Digg This Post', 'tweet-this'), 'diigo' => __('Post to Diigo', 'tweet-this'), 'facebook' => __('Post to Facebook', 'tweet-this'), 'ff' => __('Post to FriendFeed', 'tweet-this'), 'gbuzz' => __('Post to Google Buzz', 'tweet-this'), 'gmail' => __('Send Gmail', 'tweet-this'), 'linkedin' => __('Post to LinkedIn', 'tweet-this'), 'mixx' => __('Mixx This Post', 'tweet-this'), 'myspace' => __('Post to MySpace', 'tweet-this'), 'ping' => __('Ping This Post', 'tweet-this'), 'reddit' => __('Post to Reddit', 'tweet-this'), 'slashdot' => __('Post to Slashdot', 'tweet-this'), 'squidoo' => __('Post to Squidoo', 'tweet-this'), 'su' => __('Stumble This Post', 'tweet-this'), 'technorati' => __('Post to Technorati', 'tweet-this')); if($array == 'link' || $array == '') return $services; elseif($array == 'title' || $array == 'alt') { $services['twitter'] = __('Post to Twitter', 'tweet-this'); $services['plurk'] = __('Post to Plurk', 'tweet-this'); $services['buzz'] = __('Post to Yahoo Buzz', 'tweet-this'); $services['digg'] = __('Post to Digg', 'tweet-this'); $services['mixx'] = __('Post to Mixx', 'tweet-this'); $services['ping'] = __('Post to Ping.fm', 'tweet-this'); $services['su'] = __('Post to StumbleUpon', 'tweet-this'); return $services;} else return false; } /** * Same as tt_service_array($array). * @package tweet-this * @since 1.7.7 */ function get_tt_service_array($array) { return tt_service_array($array); } /** * Returns the link text, which can be set in Settings > Tweet This. * @package tweet-this * @since 1.7.6 */ function get_tweet_this_link_text($link_text = '', $service = 'twitter') { if($link_text == '') { if($service == 'twitter-share' || $service == '') $service = 'twitter'; $services = tt_service_array('link'); foreach($services as $name => $display) { if($service == $name) { if(tt_option('tt_' . $name . '_link_text') == '') $link_text = $display; else $link_text = tt_option('tt_' . $name . '_link_text');}}} return get_tt_parse_string($link_text, '', ' ', 'twitter-share'); } /** * Echoes the above function for convenience. * @package tweet-this * @since 1.2 * @notes 1.7.6: Behavior changed from return to echo. */ function tweet_this_link_text($link_text = '', $service = 'twitter') { echo get_tweet_this_link_text($link_text, $service); } /** * Returns the popup title text, which can be set in Settings > Tweet This. * @package tweet-this * @since 1.7.6 */ function get_tweet_this_title_text($title_text = '', $service = 'twitter') { if($title_text == '') { if($service == 'twitter-share' || $service == '') $service = 'twitter'; $services = tt_service_array('title'); foreach($services as $name => $display) { if($service == $name) { if(tt_option('tt_' . $name . '_title_text') == '') $title_text = $display; else $title_text = tt_option('tt_' . $name . '_title_text');}}} return get_tt_parse_string($title_text, '', ' ', 'twitter-share'); } /** * Echoes the above function for convenience. * @package tweet-this * @since 1.2 * @notes 1.7.6: Behavior changed from return to echo. */ function tweet_this_title_text($title_text = '', $service = 'twitter') { echo get_tweet_this_title_text($title_text, $service); } /** * Determines whether the Tweet This link can be displayed on the current post. * If true, this function returns $item. If false, it returns blank. * @package tweet-this * @since 1.3 */ function tt_display_limits($item) { global $preview, $post; if((!$preview && $post->post_status != 'draft') || tt_option('tt_url_service') == 'local') { if(tt_option('tt_limit_to_posts') == 'true') { if(tt_option('tt_limit_to_single') == 'true') { if(is_single()) return $item;} else { if(!is_page()) return $item;}} if(tt_option('tt_limit_to_single') == 'true') { if(tt_option('tt_limit_to_posts') == 'true') { if(is_single()) return $item;} else { if(is_singular()) return $item;}} if(tt_option('tt_limit_to_posts') != 'true' && tt_option('tt_limit_to_single') != 'true') return $item;} } /** * Same as tt_display_limits($item). * @package tweet-this * @since 1.7.6 */ function get_tt_display_limits($item) { return tt_display_limits($item); } /** * Generates the direct URL to tweet a post to Twitter or Plurk. * @package tweet-this * @since 1.1 */ function get_tweet_this_url($tweet_text = '', $service = '', $longurl = '', $title = '', $post_id = '', $auto = false) { if($service == 'twitter') $path = 'http://twitter.com/intent/tweet?text='; elseif($service == 'twitter-share') $path = 'http://twitter.com/share?url='; elseif($service == 'plurk') $path = 'http://plurk.com/?status='; else $path = 'http://twitter.com/intent/tweet?text='; if($tweet_text == '') { if($service == 'twitter') { if(tt_option('tt_tweet_text') == '') $tweet_text = '[TITLE] [URL]'; else $tweet_text = tt_option('tt_tweet_text');} elseif($service == 'twitter-share') { if(tt_option('tt_twitter_share_text') == '') $tweet_text = '[TITLE_SHARE]'; else $tweet_text = tt_option('tt_twitter_share_text');} elseif($service == 'plurk') { if(tt_option('tt_plurk_text') == '') $tweet_text = '[TITLE] [URL]'; else $tweet_text = tt_option('tt_plurk_text');} else { if(tt_option('tt_tweet_text') == '') $tweet_text = '[TITLE] [URL]'; else $tweet_text = tt_option('tt_tweet_text');}} if($auto == true) $force = true; else $force = false; $title_trim = get_tweet_this_trim_title($title, $tweet_text, $service, false); if($service == 'twitter-share' || (tt_option('tt_30') == 'true' && $auto == false && (strlen(get_permalink()) < (139 - strlen(get_tt_parse_string($tweet_text, '1', ' ', $service, $title_trim)))))) $url = get_permalink(); else $url = get_tweet_this_short_url($longurl, $post_id, true, false, '', $force); $tweet_text = urlencode(get_tt_parse_string($tweet_text, $url, ' ', $service, $title_trim)); if($service == 'twitter-share') { $getvia = tt_option('tt_twitter_share_via'); $getrel = tt_option('tt_twitter_share_rel'); if($getvia == '[BLANK]') {$via = ''; $vialen = 0;} elseif($getvia != '') {$via = '&via=' . $getvia; $vialen = strlen($getvia) + 6;} else {$via = '&via=tweetthisplugin'; $vialen = 21;} if($getrel == '[BLANK]') $rel = ''; elseif($getrel != '') $rel = '&related=' . str_replace( array(' ', ','), array('%20', '%2C'), $getrel); else $rel = '&related=richardxthripp%2Ctweetthisplugin'; if(strlen($tweet_text) > (144 - TT_TCO_LEN - $vialen)) $tweet_text = tt_mb_substr($tweet_text, 0, (141 - TT_TCO_LEN - $vialen)) . '...'; if($tweet_text == '[BLANK]' || $tweet_text == false) $text = ''; elseif($tweet_text != '') $text = '&text=' . $tweet_text; else $text = ''; $final = $path . $url . $text . $via . $rel;} else $final = $path . $tweet_text; if($auto == true) return $tweet_text; else return tt_display_limits(str_replace('#', '%23', $final)); } /** * Echoes the above function for convenience. * @package tweet-this * @since 1.1 */ function tweet_this_url($tweet_text = '', $service = '', $longurl = '', $title = '', $post_id = '', $auto = false) { echo get_tweet_this_url($tweet_text, $service, $longurl, $title, $post_id, $auto); } /** * Core function returns the complete link to a service. * @package tweet-this * @since 1.2 */ function get_tweet_this($service = 'twitter', $tweet_text = '', $link_text = '', $title_text = '', $icon_file = '', $a_class = '', $img_class = '', $img_alt = '') { if($a_class == '') { if(tt_option('tt_link_css_class') == '') $a_class = 'tt'; else $a_class = tt_option('tt_link_css_class');} if($img_class == '') { if(tt_option('tt_img_css_class') == '') $img_class = 'nothumb'; else $img_class = tt_option('tt_img_css_class');} $url = get_tweet_this_url($tweet_text, $service); $get_title = get_tweet_this_title_text($title_text, $service); $pttl = urlencode(@html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')); $purl = get_permalink(); $pbtl = get_bloginfo('name'); $pxcr = urlencode(tt_get_the_excerpt('', 150)); if($service == 'twitter-share' || $service == '') $service = 'twitter'; if($get_title == '[BLANK]') $title = ''; else $title = ' title="' . $get_title . '"'; $link = get_tweet_this_link_text($link_text, $service); // TODO: Use a loop here. if($service == 'twitter') { if($img_alt == '') $img_alt = __('Post to Twitter', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_twitter_icon') == '') $icon_file = 'en/twitter/tt-twitter.png'; else $icon_file = tt_option('tt_twitter_icon');}} if($service == 'plurk') { if($img_alt == '') $img_alt = __('Post to Plurk', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_plurk_icon') == '') $icon_file = 'en/plurk/tt-plurk.png'; else $icon_file = tt_option('tt_plurk_icon');}} if($service == 'bebo') { if($img_alt == '') $img_alt = __('Post to Bebo', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_bebo_icon') == '') $icon_file = 'en/bebo/tt-bebo.png'; else $icon_file = tt_option('tt_bebo_icon');} $url = 'http://www.bebo.com/c/share?Url=' . $purl . '&Title=' . $pttl;} if($service == 'buzz') { if($img_alt == '') $img_alt = __('Post to Yahoo Buzz', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_buzz_icon') == '') $icon_file = 'en/buzz/tt-buzz.png'; else $icon_file = tt_option('tt_buzz_icon');} $url = 'http://buzz.yahoo.com/buzz?targetUrl=' . $purl . '&headline=' . str_pad($pttl, 10, '.');} if($service == 'delicious') { if($img_alt == '') $img_alt = __('Post to Delicious', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_delicious_icon') == '') $icon_file = 'en/delicious/tt-delicious.png'; else $icon_file = tt_option('tt_delicious_icon');} $url = 'http://delicious.com/post?url=' . $purl . '&title=' . $pttl;} if($service == 'digg') { if($img_alt == '') $img_alt = __('Post to Digg', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_digg_icon') == '') $icon_file = 'en/digg/tt-digg.png'; else $icon_file = tt_option('tt_digg_icon');} $url = 'http://digg.com/submit?url=' . $purl . '&title=' . $pttl;} if($service == 'diigo') { if($img_alt == '') $img_alt = __('Post to Diigo', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_diigo_icon') == '') $icon_file = 'en/diigo/tt-diigo.png'; else $icon_file = tt_option('tt_diigo_icon');} $url = 'http://www.diigo.com/post?url=' . $purl . '&title=' . $pttl . '&desc=' . $pttl;} if($service == 'facebook') { if($img_alt == '') $img_alt = __('Post to Facebook', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_facebook_icon') == '') $icon_file = 'en/facebook/tt-facebook.png'; else $icon_file = tt_option('tt_facebook_icon');} $url = 'http://www.facebook.com/share.php?u=' . $purl . '&t=' . $pttl;} if($service == 'ff') { if($img_alt == '') $img_alt = __('Post to FriendFeed', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_ff_icon') == '') $icon_file = 'en/ff/tt-ff.png'; else $icon_file = tt_option('tt_ff_icon');} $url = 'http://www.friendfeed.com/share?title=' . $pttl . '&link=' . $purl;} if($service == 'gbuzz') { if($img_alt == '') $img_alt = __('Post to Google Buzz', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_gbuzz_icon') == '') $icon_file = 'en/gbuzz/tt-gbuzz.png'; else $icon_file = tt_option('tt_gbuzz_icon');} $url = 'http://www.google.com/buzz/post?url=' . $purl . '&imageurl=';} if($service == 'gmail') { if($img_alt == '') $img_alt = __('Send Gmail', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_gmail_icon') == '') $icon_file = 'en/gmail/tt-gmail.png'; else $icon_file = tt_option('tt_gmail_icon');} $url = 'https://mail.google.com/mail/?ui=2&view=cm&' . 'fs=1&tf=1&su=' . $pttl . '&body=Link:+' . $purl . '%0D%0A%0D%0A----%0D%0A+' . $pxcr;} if($service == 'linkedin') { if($img_alt == '') $img_alt = __('Post to LinkedIn', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_linkedin_icon') == '') $icon_file = 'en/linkedin/tt-linkedin.png'; else $icon_file = tt_option('tt_linkedin_icon');} $url = 'http://www.linkedin.com/shareArticle?mini=true&' . 'url=' . $purl . '&title=' . $pttl . '&summary=' . $pxcr . '&source=' . $pbtl;} if($service == 'mixx') { if($img_alt == '') $img_alt = __('Mixx This Post', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_mixx_icon') == '') $icon_file = 'en/mixx/tt-mixx.png'; else $icon_file = tt_option('tt_mixx_icon');} $url = 'http://www.mixx.com/submit?page_url=' . $purl . '&title=' . $pttl;} if($service == 'myspace') { if($img_alt == '') $img_alt = __('Post to MySpace', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_myspace_icon') == '') $icon_file = 'en/myspace/tt-myspace.png'; else $icon_file = tt_option('tt_myspace_icon');} $url = 'http://www.myspace.com/Modules/PostTo/Pages/' . '?l=3&u=' . $purl . '&t=' . $pttl;} if($service == 'ping') { if($img_alt == '') $img_alt = __('Post to Ping.fm', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_ping_icon') == '') $icon_file = 'en/ping/tt-ping.png'; else $icon_file = tt_option('tt_ping_icon');} $url = 'http://ping.fm/ref/?method=microblog&title=' . $pttl . '&link=' . $purl;} if($service == 'reddit') { if($img_alt == '') $img_alt = __('Post to Reddit', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_reddit_icon') == '') $icon_file = 'en/reddit/tt-reddit.png'; else $icon_file = tt_option('tt_reddit_icon');} $url = 'http://reddit.com/submit?url=' . $purl . '&title=' . $pttl;} if($service == 'slashdot') { if($img_alt == '') $img_alt = __('Post to Slashdot', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_slashdot_icon') == '') $icon_file = 'en/slashdot/tt-slashdot.png'; else $icon_file = tt_option('tt_slashdot_icon');} $url = 'http://slashdot.org/bookmark.pl?url=' . $purl . '&title=' . $pttl;} if($service == 'squidoo') { if($img_alt == '') $img_alt = __('Post to Squidoo', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_squidoo_icon') == '') $icon_file = 'en/squidoo/tt-squidoo.png'; else $icon_file = tt_option('tt_squidoo_icon');} $url = 'http://www.squidoo.com/lensmaster/bookmark?' . $purl;} if($service == 'su') { if($img_alt == '') $img_alt = __('Post to StumbleUpon', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_su_icon') == '') $icon_file = 'en/su/tt-su.png'; else $icon_file = tt_option('tt_su_icon');} $url = 'http://stumbleupon.com/submit?url=' . $purl . '&title=' . $pttl;} if($service == 'technorati') { if($img_alt == '') $img_alt = __('Post to Technorati', 'tweet-this'); if($icon_file == '') { if(tt_option('tt_technorati_icon') == '') $icon_file = 'en/technorati/tt-technorati.png'; else $icon_file = tt_option('tt_technorati_icon');} $url = 'http://technorati.com/faves?add=' . $purl;} $icon = TT_URLPATH . 'icons/' . $icon_file; if($icon_file != 'noicon') $item = '' .
			$img_alt . ''; if($link != '[BLANK]') $item .= ' ' . $link . ''; if($service == 'twitter' && $icon_file == 'textbox') { global $id; $textbox = tt_option('tt_textbox_size'); if($textbox == '') $textbox = '60'; if($link == '[BLANK]') $link = __('Tweet This Post', 'tweet-this'); $item = '
' . '
' . '
';} return tt_display_limits($item); } /** * Echoes the above function for convenience. * @package tweet-this * @since 1.1 */ function tweet_this($service = 'twitter', $tweet_text = '', $link_text = '', $title_text = '', $icon_file = '', $a_class = '', $img_class = '', $img_alt = '') { echo get_tweet_this($service, $tweet_text, $link_text, $title_text, $icon_file, $a_class, $img_class, $img_alt); } /** * Tweet This options on post edit screen. Requires WP 2.7 or newer. * @package tweet-this * @since 1.6 */ function tt_post_options() { global $post; $tt_auto = get_post_meta($post->ID, 'tt_auto_tweet', true); $tt_auto_text = get_post_meta($post->ID, 'tt_auto_tweet_text', true); $tt_http_code = get_post_meta($post->ID, 'tt_http_code', true); $tt_tweeted = get_post_meta($post->ID, 'tt_tweeted', true); $tt_tweeted_date = get_post_meta($post->ID, 'tt_tweeted_date', true); if(version_compare($GLOBALS['wp_version'], '3.0', '<')) echo '

' . __('Tweet This', 'tweet-this') . '

'; echo '

'; if(tt_option('tt_app_consumer_key') == '' || tt_option('tt_app_consumer_secret') == '' || tt_option('tt_oauth_token') == '' || tt_option('tt_oauth_token_secret') == '') { echo ''; printf(__('Please enter your Twitter OAuth ' . 'keys under Settings > Tweet This > Automatic ' . 'Tweeting, or uncheck "Enable automatic tweeting on ' . 'posts" and "Enable automatic tweeting on pages" to remove ' . 'this box.', 'tweet-this'), get_bloginfo('url'), constant('TT_FILE_LOC')); echo '';} elseif($post->post_status == 'private') echo '' . __('Cannot tweet a private post.', 'tweet-this') . ''; else { if($tt_tweeted != 'false' && $tt_tweeted != '') $is_tweeted = true; else $is_tweeted = false; if($is_tweeted == true) { if(substr($tt_tweeted, 0, 7) == 'http://' && strpos(strrchr($tt_tweeted, '/'), '+') === false) $link = ': ' . str_replace('/', '', strrchr($tt_tweeted, '/')) . '.'; else $link = '.'; if(strlen($tt_tweeted_date) > 8) $link .= ' ' . __('Date:', 'tweet-this') . ' ' . str_replace(' ', ' ', $tt_tweeted_date); echo '' . __('Tweet published', 'tweet-this') . $link . '

';} if(trim($tt_http_code) != '' && trim($tt_http_code) != '200') { echo ''; printf(__('Tweet failed. Twitter returned HTTP %1$s. Check your OAuth ' . 'settings and re-save this post to try again.', 'tweet-this'), $tt_http_code); echo '

';} echo '' . '

' . '

';} if(version_compare($GLOBALS['wp_version'], '3.0', '<')) echo '
'; } /** * Saves options on post edit screen. Requires WP 2.7 or newer. * @package tweet-this * @since 1.6 */ function tt_store_post_options($post_id, $post = false) { $postdata = tt_get_post($post_id); if(!$postdata || ($postdata['post_type'] != 'page' && tt_option('tt_auto_tweet_display') == 'false') || ($postdata['post_type'] == 'page' && tt_option('tt_auto_tweet_display_pages') == 'false') || tt_option('tt_app_consumer_key') == '' || tt_option('tt_app_consumer_secret') == '' || tt_option('tt_oauth_token') == '' || tt_option('tt_oauth_token_secret' == '')) return false; $tt_auto_save = get_post_meta($post_id, 'tt_auto_tweet', true); if($tt_auto_save == '' && $postdata['post_type'] != 'page') $tt_auto_save = tt_option('tt_auto_tweet'); elseif($tt_auto_save == '' && $postdata['post_type'] == 'page') $tt_auto_save = tt_option('tt_auto_tweet_pages'); if($tt_auto_save == '') $tt_auto_save = 'false'; if($_POST['tt_auto_tweet'] == 'true') $tt_auto_post = 'true'; elseif($_POST['tt_auto_tweet'] == 'false') $tt_auto_post = 'false'; else $tt_auto_post = $tt_auto_save; update_post_meta($post_id, 'tt_auto_tweet', $tt_auto_post); $tt_auto_text_post = $_POST['tt_auto_tweet_text']; $tt_auto_text_save = get_post_meta($post_id, 'tt_auto_tweet_text', true); if($tt_auto_text_post == $tt_auto_text_save && $tt_auto_text_post != '' && $tt_auto_text_save != '') $save_text = false; elseif($tt_auto_text_post == '') { if($tt_auto_text_save == '') $tt_auto_text_save = tt_option('tt_auto_tweet_text'); $tt_auto_text_post = $tt_auto_text_save; $save_text = true;} elseif($tt_auto_text_save == '') $save_text = true; if($tt_auto_text_post == '') $tt_auto_text_post = __('New blog post', 'tweet-this') . ': [TITLE] [URL]'; update_post_meta($post_id, 'tt_auto_tweet_text', $tt_auto_text_post); } /** * Handles automatic tweeting of posts. Requires WP 2.7 or newer. * @package tweet-this * @since 1.6 */ function tt_auto_tweet($post_id) { $postdata = tt_get_post($post_id); $tt_auto = get_post_meta($post_id, 'tt_auto_tweet', true); $tt_auto_text = get_post_meta($post_id, 'tt_auto_tweet_text', true); $tt_tweeted = get_post_meta($post_id, 'tt_tweeted', true); if($tt_auto == 'true' || $tt_auto == 'false') $tweet_auto = $tt_auto; elseif(tt_option('tt_auto_tweet') != '') $tweet_auto = tt_option('tt_auto_tweet'); else $tweet_auto = 'false'; if($_POST['tt_auto_tweet'] == 'true') $tweet_auto = 'true'; if($tt_auto_text != '') $tweet_text = $tt_auto_text; elseif(tt_option('tt_auto_tweet_text') != '') $tweet_text = tt_option('tt_auto_tweet_text'); else $tweet_text = __('New blog post', 'tweet-this') . ': [TITLE] [URL]'; if(trim($_POST['tt_auto_tweet_text']) != '') $tweet_text = $_POST['tt_auto_tweet_text']; if($tweet_auto == 'false' || !$postdata || tt_option('tt_app_consumer_key') == '' || tt_option('tt_app_consumer_secret') == '' || tt_option('tt_oauth_token') == '' || tt_option('tt_oauth_token_secret') == '' || ($postdata['post_type'] != 'page' && tt_option('tt_auto_tweet_display') == 'false') || ($postdata['post_type'] == 'page' && tt_option('tt_auto_tweet_display_pages') == 'false')) return false; else { if(tt_option('tt_app_consumer_key') != '' && tt_option('tt_app_consumer_secret') != '' && tt_option('tt_oauth_token') != '' && tt_option('tt_oauth_token_secret') != '') { $status = urldecode(get_tweet_this_url($tweet_text, 'twitter', get_permalink($post_id), $postdata['post_title'], $post_id, true)); $connection = tt_oauth_connection(); $connection->decode_json = true; $data = $connection->post(TT_API_POST_STATUS, array('status' => stripslashes(trim($status)), 'source' => 'tweetthis')); if($connection->http_code == '200') { update_post_meta($post_id, 'tt_tweeted', 'http://twitter.com/' . $data->user->screen_name . '/status/' . $data->id_str); update_post_meta($post_id, 'tt_tweeted_date', date("Y-m-d H:i:s")); update_post_meta($post_id, 'tt_auto_tweet', 'false'); delete_post_meta($post_id, 'tt_http_code');} else { update_post_meta($post_id, 'tt_tweeted', 'false'); update_post_meta($post_id, 'tt_http_code', $connection->http_code);}}} } /** * Inserts all links. * @package tweet-this * @since 1.1 */ function insert_tweet_this($content = '', $force = false) { global $id, $preview, $post; $tweet_this_hide = get_post_meta($id, 'tweet_this_hide', true); if($force == false && ((is_feed() && tt_option('tt_hide_on_feeds') == 'true') || ($tweet_this_hide && $tweet_this_hide != 'false') || (tt_option('tt_url_service') != 'local' && ($preview || $post->post_status == 'draft')))) $content = $content; // TODO: Use a loop here. else { $insert = ''; $prefix = constant('TT_PREFIX'); if(tt_option('tt_auto_display') == 'true' && tt_option('tt_twitter_icon') == 'textbox') $prefix = str_replace('

', '', $prefix); if( tt_option('tt_plurk') == 'true' || tt_option('tt_bebo') == 'true' || tt_option('tt_buzz') == 'true' || tt_option('tt_delicious') == 'true' || tt_option('tt_digg') == 'true' || tt_option('tt_diigo') == 'true' || tt_option('tt_facebook') == 'true' || tt_option('tt_ff') == 'true' || tt_option('tt_gbuzz') == 'true' || tt_option('tt_gmail') == 'true' || tt_option('tt_linkedin') == 'true' || tt_option('tt_mixx') == 'true' || tt_option('tt_myspace') == 'true' || tt_option('tt_ping') == 'true' || tt_option('tt_reddit') == 'true' || tt_option('tt_slashdot') == 'true' || tt_option('tt_squidoo') == 'true' || tt_option('tt_su') == 'true' || tt_option('tt_technorati') == 'true') $extended = true; else $extended = false; if(tt_option('tt_auto_display') == 'true' || $extended == true) $insert .= tt_display_limits($prefix); $order = explode(' ', preg_replace("/(\040)+/", " ", str_replace(',', ' ', trim(tt_option('tt_service_order'))))); foreach($order as $s) {if(tt_option('tt_' . $s) == 'true') { if($s == 'twitter' && tt_option('tt_twitter_share') == 'true') $s = 'twitter-share'; $insert .= TT_SEPARATOR . get_tweet_this($s);}} if(tt_option('tt_auto_display') == 'true' || $extended == true) $insert .= tt_display_limits(TT_SUFFIX); if(tt_option('tt_insert_before') == 'true') $content = $insert . $content; if(tt_option('tt_insert_after') != 'false') $content .= $insert;} return $content; } /** * Handles [tweet_this] shortcode replacement in content areas. * @package tweet-this * @since 1.8 */ function tt_shortcode_handler() { return insert_tweet_this('', true); } /** * Echo this to insert all links into your theme manually. * @package tweet-this * @since 1.7 */ function get_tweet_this_manual() { remove_filter('the_content', 'insert_tweet_this'); return insert_tweet_this(); } /** * Use this to insert all links into your theme manually. * @package tweet-this * @since 1.7 */ function tweet_this_manual() { remove_filter('the_content', 'insert_tweet_this'); echo insert_tweet_this(); } /** * CSS inserted using the wp_head hook. * @package tweet-this * @since 1.7.6 */ function get_tweet_this_css() { if(tt_option('tt_css') == '') return ''; else return ''; } /** * Echoes the above function for convenience. * @package tweet-this * @since 1.1 * @notes 1.7.6: Behavior changed from return to echo. */ function tweet_this_css() { echo get_tweet_this_css() . "\n"; } /** * Updates the database options when saved. * @package tweet-this * @since 1.1 */ function update_tt_options() { if(isset($_REQUEST['tt'])) $new_options = $_REQUEST['tt']; $booleans = array('tt_30', 'tt_insert_before', 'tt_insert_after', 'tt_limit_to_single', 'tt_limit_to_posts', 'tt_hide_on_feeds', 'tt_url_www', 'tt_shortlink_filter', 'tt_auto_display', 'tt_plurk', 'tt_bebo', 'tt_buzz', 'tt_delicious', 'tt_digg', 'tt_diigo', 'tt_facebook', 'tt_ff', 'tt_gbuzz', 'tt_gmail', 'tt_linkedin', 'tt_mixx', 'tt_myspace', 'tt_ping', 'tt_reddit', 'tt_slashdot', 'tt_squidoo', 'tt_su', 'tt_technorati', 'tt_ad_vu', 'tt_j_mp', 'tt_footer', 'tt_new_window', 'tt_nofollow', 'tt_auto_tweet_display', 'tt_auto_tweet_display_pages', 'tt_auto_tweet', 'tt_auto_tweet_pages'); $oauths = array('tt_app_consumer_key', 'tt_app_consumer_secret', 'tt_oauth_token', 'tt_oauth_token_secret'); $urlkeys = array('tt_adjix_api_key', 'tt_bitly_username', 'tt_bitly_api_key', 'tt_snipurl_username', 'tt_snipurl_api_key', 'tt_supr_username', 'tt_supr_api_key'); $triggers = array('tt_url_service', 'tt_url_www', 'tt_ad_vu', 'tt_j_mp', 'tt_adjix_api_key', 'tt_bitly_username', 'tt_bitly_api_key', 'tt_snipurl_username', 'tt_snipurl_api_key', 'tt_snipurl_domain', 'tt_supr_username', 'tt_supr_api_key', 'tt_custom_url_service'); foreach($booleans as $boolean) $new_options[$boolean] = $new_options[$boolean] ? 'true' : 'false'; foreach($oauths as $oauth) $new_options[$oauth] = trim($_REQUEST[$oauth]); foreach($urlkeys as $urlkey) $new_options[$urlkey] = trim($new_options[$urlkey]); foreach($triggers as $trigger) { if(tt_option($trigger) != $new_options[$trigger]) { global $wpdb; $fcount = number_format($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = 'tweet_this_url' AND meta_value != 'getnew'")); global_flush_tt_cache(); $flush = ' ' . __("$fcount cached " . "URL(s) flushed.", 'tweet-this'); break;}} if($new_options['tt_twitter_share'] == 'share') $new_options['tt_twitter_share'] = 'true'; else $new_options['tt_twitter_share'] = 'false'; // TODO: Use a loop here. if($new_options['tt_link_text'] == __('Tweet This Post', 'tweet-this') && tt_option('tt_link_text') == __('Tweet This Post', 'tweet-this') && $new_options['tt_twitter_icon'] != tt_option('tt_twitter_icon') && $new_options['tt_twitter_icon'] != 'en/twitter/tt-twitter.png' && $new_options['tt_twitter_icon'] != 'en/twitter/tt-twitter2.png' && $new_options['tt_twitter_icon'] != 'en/twitter/tt-twitter3.png' && $new_options['tt_twitter_icon'] != 'en/twitter/tt-twitter4.png' && $new_options['tt_twitter_icon'] != 'noicon' && $new_options['tt_twitter_icon'] != 'textbox') $new_options['tt_link_text'] = '[BLANK]'; if($new_options['tt_plurk_link_text'] == __('Plurk This Post', 'tweet-this') && tt_option('tt_plurk_link_text') == __('Plurk This Post', 'tweet-this') && $new_options['tt_plurk_icon'] != tt_option('tt_plurk_icon') && $new_options['tt_plurk_icon'] != 'en/plurk/tt-plurk.png' && $new_options['tt_plurk_icon'] != 'noicon') $new_options['tt_plurk_link_text'] = '[BLANK]'; if($new_options['tt_bebo_link_text'] == __('Post to Bebo', 'tweet-this') && tt_option('tt_bebo_link_text') == __('Post to Bebo', 'tweet-this') && $new_options['tt_bebo_icon'] != tt_option('tt_bebo_icon') && $new_options['tt_bebo_icon'] != 'en/bebo/tt-bebo.png' && $new_options['tt_bebo_icon'] != 'noicon') $new_options['tt_bebo_link_text'] = '[BLANK]'; if($new_options['tt_buzz_link_text'] == __('Buzz This Post', 'tweet-this') && tt_option('tt_buzz_link_text') == __('Buzz This Post', 'tweet-this') && $new_options['tt_buzz_icon'] != tt_option('tt_buzz_icon') && $new_options['tt_buzz_icon'] != 'en/buzz/tt-buzz.png' && $new_options['tt_buzz_icon'] != 'noicon') $new_options['tt_buzz_link_text'] = '[BLANK]'; if($new_options['tt_delicious_link_text'] == __('Post to Delicious', 'tweet-this') && tt_option('tt_delicious_link_text') == __('Post to Delicious', 'tweet-this') && $new_options['tt_delicious_icon'] != tt_option('tt_delicious_icon') && $new_options['tt_delicious_icon'] != 'en/delicious/tt-delicious.png' && $new_options['tt_delicious_icon'] != 'noicon') $new_options['tt_delicious_link_text'] = '[BLANK]'; if($new_options['tt_digg_link_text'] == __('Digg This Post', 'tweet-this') && tt_option('tt_digg_link_text') == __('Digg This Post', 'tweet-this') && $new_options['tt_digg_icon'] != tt_option('tt_digg_icon') && $new_options['tt_digg_icon'] != 'en/digg/tt-digg.png' && $new_options['tt_digg_icon'] != 'noicon') $new_options['tt_digg_link_text'] = '[BLANK]'; if($new_options['tt_diigo_link_text'] == __('Post to Diigo', 'tweet-this') && tt_option('tt_diigo_link_text') == __('Post to Diigo', 'tweet-this') && $new_options['tt_diigo_icon'] != tt_option('tt_diigo_icon') && $new_options['tt_diigo_icon'] != 'en/diigo/tt-diigo.png' && $new_options['tt_diigo_icon'] != 'noicon') $new_options['tt_diigo_link_text'] = '[BLANK]'; if($new_options['tt_facebook_link_text'] == __('Post to Facebook', 'tweet-this') && tt_option('tt_facebook_link_text') == __('Post to Facebook', 'tweet-this') && $new_options['tt_facebook_icon'] != tt_option('tt_facebook_icon') && $new_options['tt_facebook_icon'] != 'en/facebook/tt-facebook.png' && $new_options['tt_facebook_icon'] != 'noicon') $new_options['tt_facebook_link_text'] = '[BLANK]'; if($new_options['tt_ff_link_text'] == __('Post to FriendFeed', 'tweet-this') && tt_option('tt_ff_link_text') == __('Post to FriendFeed', 'tweet-this') && $new_options['tt_ff_icon'] != tt_option('tt_ff_icon') && $new_options['tt_ff_icon'] != 'en/ff/tt-ff.png' && $new_options['tt_ff_icon'] != 'noicon') $new_options['tt_ff_link_text'] = '[BLANK]'; if($new_options['tt_gbuzz_link_text'] == __('Post to Google Buzz', 'tweet-this') && tt_option('tt_gbuzz_link_text') == __('Post to Google Buzz', 'tweet-this') && $new_options['tt_gbuzz_icon'] != tt_option('tt_gbuzz_icon') && $new_options['tt_gbuzz_icon'] != 'en/gbuzz/tt-gbuzz.png' && $new_options['tt_gbuzz_icon'] != 'noicon') $new_options['tt_gbuzz_link_text'] = '[BLANK]'; if($new_options['tt_gmail_link_text'] == __('Send Gmail', 'tweet-this') && tt_option('tt_gmail_link_text') == __('Send Gmail', 'tweet-this') && $new_options['tt_gmail_icon'] != tt_option('tt_gmail_icon') && $new_options['tt_gmail_icon'] != 'en/gmail/tt-gmail.png' && $new_options['tt_gmail_icon'] != 'noicon') $new_options['tt_gmail_link_text'] = '[BLANK]'; if($new_options['tt_linkedin_link_text'] == __('Post to LinkedIn', 'tweet-this') && tt_option('tt_linkedin_link_text') == __('Post to LinkedIn', 'tweet-this') && $new_options['tt_linkedin_icon'] != tt_option('tt_linkedin_icon') && $new_options['tt_linkedin_icon'] != 'en/linkedin/tt-linkedin.png' && $new_options['tt_linkedin_icon'] != 'noicon') $new_options['tt_linkedin_link_text'] = '[BLANK]'; if($new_options['tt_mixx_link_text'] == __('Mixx This Post', 'tweet-this') && tt_option('tt_mixx_link_text') == __('Mixx This Post', 'tweet-this') && $new_options['tt_mixx_icon'] != tt_option('tt_mixx_icon') && $new_options['tt_mixx_icon'] != 'en/mixx/tt-mixx.png' && $new_options['tt_mixx_icon'] != 'noicon') $new_options['tt_mixx_link_text'] = '[BLANK]'; if($new_options['tt_myspace_link_text'] == __('Post to MySpace', 'tweet-this') && tt_option('tt_myspace_link_text') == __('Post to MySpace', 'tweet-this') && $new_options['tt_myspace_icon'] != tt_option('tt_myspace_icon') && $new_options['tt_myspace_icon'] != 'en/myspace/tt-myspace.png' && $new_options['tt_myspace_icon'] != 'noicon') $new_options['tt_myspace_link_text'] = '[BLANK]'; if($new_options['tt_ping_link_text'] == __('Ping This Post', 'tweet-this') && tt_option('tt_ping_link_text') == __('Ping This Post', 'tweet-this') && $new_options['tt_ping_icon'] != tt_option('tt_ping_icon') && $new_options['tt_ping_icon'] != 'en/ping/tt-ping.png' && $new_options['tt_ping_icon'] != 'noicon') $new_options['tt_ping_link_text'] = '[BLANK]'; if($new_options['tt_reddit_link_text'] == __('Post to Reddit', 'tweet-this') && tt_option('tt_reddit_link_text') == __('Post to Reddit', 'tweet-this') && $new_options['tt_reddit_icon'] != tt_option('tt_reddit_icon') && $new_options['tt_reddit_icon'] != 'en/reddit/tt-reddit.png' && $new_options['tt_reddit_icon'] != 'noicon') $new_options['tt_reddit_link_text'] = '[BLANK]'; if($new_options['tt_slashdot_link_text'] == __('Post to Slashdot', 'tweet-this') && tt_option('tt_slashdot_link_text') == __('Post to Slashdot', 'tweet-this') && $new_options['tt_slashdot_icon'] != tt_option('tt_slashdot_icon') && $new_options['tt_slashdot_icon'] != 'en/slashdot/tt-slashdot.png' && $new_options['tt_slashdot_icon'] != 'noicon') $new_options['tt_slashdot_link_text'] = '[BLANK]'; if($new_options['tt_squidoo_link_text'] == __('Post to Squidoo', 'tweet-this') && tt_option('tt_squidoo_link_text') == __('Post to Squidoo', 'tweet-this') && $new_options['tt_squidoo_icon'] != tt_option('tt_squidoo_icon') && $new_options['tt_squidoo_icon'] != 'en/squidoo/tt-squidoo.png' && $new_options['tt_squidoo_icon'] != 'noicon') $new_options['tt_squidoo_link_text'] = '[BLANK]'; if($new_options['tt_su_link_text'] == __('Stumble This Post', 'tweet-this') && tt_option('tt_su_link_text') == __('Stumble This Post', 'tweet-this') && $new_options['tt_su_icon'] != tt_option('tt_su_icon') && $new_options['tt_su_icon'] != 'en/su/tt-su.png' && $new_options['tt_su_icon'] != 'noicon') $new_options['tt_su_link_text'] = '[BLANK]'; if($new_options['tt_technorati_link_text'] == __('Post to Technorati', 'tweet-this') && tt_option('tt_technorati_link_text') == __('Post to Technorati', 'tweet-this') && $new_options['tt_technorati_icon'] != tt_option('tt_technorati_icon') && $new_options['tt_technorati_icon'] != 'en/technorati/tt-technorati.png' && $new_options['tt_technorati_icon'] != 'noicon') $new_options['tt_technorati_link_text'] = '[BLANK]'; $count = 0; foreach($new_options as $option => $value) if(tt_option($option) != $value) $count++; update_option('tweet_this_settings', $new_options); echo '

' . __("$count Tweet This option(s) " . "saved.", 'tweet-this') . $flush . '

'; } /** * Outputs image selection for each service in the options. * @package tweet-this * @since 1.3 */ function tt_image_selection($s) { // TODO: Use a loop here. $l = WP_PLUGIN_URL . '/' . TT_DIR . '/icons/'; $c = ' checked="checked"'; $z = '.png" />