Changeset 230793
- Timestamp:
- 04/19/2010 09:40:45 PM (16 years ago)
- File:
-
- 1 edited
-
wordpress-tweeter/trunk/wptweeter.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wordpress-tweeter/trunk/wptweeter.php
r222403 r230793 4 4 Plugin URI: http://fusionswift.com/wordpress-tweeter/ 5 5 Description: WordPress Tweeter tweets every time you make a new post on your blog. Make sure you read the <a href="http://fusionswift.com/wordpress-tweeter/" title="WordPress Tweeter">documentations</a> before using this plugin. The changelog, installation instructions, and any other plugin related information is there. 6 Version: 0.4. 26 Version: 0.4.3 7 7 Author: Tech163 8 8 Author URI: http://fusionwift.com/ … … 27 27 if(!empty($parameter)) 28 28 $parameter = '?' . $parameter; 29 $status = str_replace('%blogtitle%', get_bloginfo('name'), $tpl);30 $status = str_replace('%posttitle%', $_POST['post_title'], $status);31 29 $services = array(); 32 30 $services['tinyurl'] = 'http://tinyurl.com/api-create.php?url=%url%'; … … 43 41 curl_setopt($ch, CURLOPT_URL, $serviceurl); 44 42 $posturl = curl_exec($ch); 45 $status = str_replace('%url%', $homeurl, $ status);43 $status = str_replace('%url%', $homeurl, $tpl); 46 44 $status = str_replace('%posturl%', $posturl, $status); 45 $status = str_replace('%date%', date(get_option('date_format')), $status); 46 $status = str_replace('%time%', date(get_option('time_format')), $status); 47 $status = str_replace('%blogtitle%', get_bloginfo('name'), $status); 48 $maxlen = 137 - strlen(preg_replace('/%(.*)%/', '', $status)); 49 $status = str_replace('%posttitle%', (strlen($_POST['post_title']) > $maxlen ? substr($_POST['post_title'], 0, $maxlen) . '...' : $_POST['post_title']), $status); 47 50 curl_setopt($ch, CURLOPT_URL, 'http' . $protocal . '://api.twitter.com/1/statuses/update.xml'); 48 51 curl_setopt($ch, CURLOPT_HEADER, false); … … 57 60 global $options, $wptweeterstatus; 58 61 $options = get_option('wp_tweeter'); 59 if($options['postupdate'] != 'true') { 60 if($wptweeterstatus != 'publish') { 61 wp_tweeter_tweet($options['tpl']); 62 } 63 } else { 62 if($wptweeterstatus != 'publish') { 63 wp_tweeter_tweet($options['tpl']); 64 } elseif($options['postupdate'] == 'true') { 64 65 wp_tweeter_tweet($options['updatetpl']); 65 66 } … … 123 124 'tpl' => '%blogtitle% New Post - %posttitle%. Read it now at %posturl%', 124 125 'postupdate' => '', 125 'updatetpl' => ' %blogtitle% Post updated- %posttitle%. Read it now at %posturl%');126 'updatetpl' => 'Post updated %date% - %posttitle%. Read it now at %posturl%'); 126 127 } 127 128 update_option('wp_tweeter', $default); … … 214 215 } 215 216 217 function wp_tweeter_notice() { 218 if(function_exists('admin_url') && !is_array(get_option('wp_tweeter'))) 219 echo '<div class="error"><p>WordPress Tweeter is NOT configured yet! Please <a href="' . admin_url('options-general.php?page=wptweeter.php') . '">configure</a> it now! <strong><a href="http://fusionswift.com/wordpress-tweeter/" target="_blank">Documentations</a></strong></p></div>'; 220 } 221 216 222 add_action('admin_menu', 'wp_tweeter_menu'); 217 223 add_action('pre_post_update', 'wp_tweeter_checkstatus'); 218 224 add_action('publish_post', 'wp_tweeter_update'); 225 add_action('admin_notices', 'wp_tweeter_notice'); 219 226 ?>
Note: See TracChangeset
for help on using the changeset viewer.