--- twitget.php 2013-05-27 18:27:32.000000000 -0400
+++ twitget_proposed.php 2013-06-13 10:58:44.000000000 -0400
@@ -37,6 +37,7 @@
'last_access' => time(),
'time_limit' => 5,
'number_of_tweets' => 5,
+ 'tweet_max_length' => 0,
'show_avatar' => true,
'time_format' => 'D jS M y H:i',
'show_powered_by' => false,
@@ -131,7 +132,10 @@
// Shortcode function
function twitget_shortcode_handler($attributes, $content = null) {
- return show_recent_tweets();
+ // show_recent_tweets() echo's, but we need to return a string
+ ob_start();
+ show_recent_tweets();
+ return ob_get_clean();
}
function twitter_status_11() {
@@ -261,6 +265,10 @@
$tweet_date_array = array();
foreach($tweets as $tweet) {
$tweet_text = $tweet['text'];
+
+ if ($options['tweet_max_length'] && strlen($tweet_text) > $options['tweet_max_length']) {
+ $tweet_text = substr($tweet_text, 0, $options['tweet_max_length']) . '...';
+ }
$tweet_location = $tweet['place']['full_name'];
$link_processed = "";
if(isset($tweet['retweeted_status'])) {
@@ -270,7 +278,7 @@
$link_processed = process_links($whole_tweet, $options['links_new_window']);
}
else {
- $link_processed = process_links($tweet['text'], $options['links_new_window']);
+ $link_processed = process_links($tweet_text, $options['links_new_window']);
}
$tweet_time = strtotime($tweet['created_at']);
if($options['show_local_time']) {
@@ -456,6 +464,7 @@
$twitget_settings['twitter_username'] = stripslashes($_POST['twitget_username']);
$twitget_settings['time_limit'] = (int) $_POST['twitget_refresh'];
$twitget_settings['number_of_tweets'] = (int) $_POST['twitget_number'];
+ $twitget_settings['tweet_max_length'] = (int) $_POST['twitget_max_length'];
$twitget_settings['time_format'] = stripslashes($_POST['twitget_time']);
$twitget_settings['show_powered_by'] = (isset($show_powered)) ? true : false;
$twitget_settings['consumer_key'] = stripslashes($_POST['twitget_consumer_key']);
@@ -600,6 +609,14 @@
</td>
</tr>
<tr>
+ <th scope="row"><label for="twitget_max_length">Max Length of tweets</label></th>
+ <td>
+ <input type="text" name="twitget_max_length" id="twitget_max_length" value="<?php echo $twitget_options['tweet_max_length']; ?>" />
+ <br />
+ <span class="description">Maximum length of a tweet in characters.</span>
+ </td>
+ </tr>
+ <tr>
<th scope="row"><label for="twitget_time">Time format</label></th>
<td>
<input type="text" name="twitget_time" id="twitget_time" value="<?php echo esc_html($twitget_options['time_format']); ?>" />
@@ -761,5 +778,3 @@
}
}
-
-?>