SHOW:
|
|
- or go back to the newest paste.
1 | - | --- twitget.php 2013-05-27 18:27:32.000000000 -0400 |
1 | + | --- twitget.php 2013-05-27 18:27:04.000000000 -0400 |
2 | - | +++ twitget_proposed.php 2013-06-13 10:58:44.000000000 -0400 |
2 | + | +++ twitget_proposed.php 2013-06-19 13:22:47.000000000 -0400 |
3 | @@ -37,6 +37,7 @@ | |
4 | 'last_access' => time(), | |
5 | 'time_limit' => 5, | |
6 | 'number_of_tweets' => 5, | |
7 | - | + 'tweet_max_length' => 0, |
7 | + | + 'tweet_max_length' => 0, |
8 | 'show_avatar' => true, | |
9 | 'time_format' => 'D jS M y H:i', | |
10 | 'show_powered_by' => false, | |
11 | - | @@ -131,7 +132,10 @@ |
11 | + | @@ -131,7 +132,9 @@ |
12 | ||
13 | // Shortcode function | |
14 | function twitget_shortcode_handler($attributes, $content = null) { | |
15 | - return show_recent_tweets(); | |
16 | - | + // show_recent_tweets() echo's, but we need to return a string |
16 | + | + ob_start(); |
17 | - | + ob_start(); |
17 | + | + show_recent_tweets(); |
18 | - | + show_recent_tweets(); |
18 | + | + return ob_get_clean(); |
19 | - | + return ob_get_clean(); |
19 | + | |
20 | ||
21 | function twitter_status_11() { | |
22 | @@ -261,6 +264,11 @@ | |
23 | - | @@ -261,6 +265,10 @@ |
23 | + | |
24 | foreach($tweets as $tweet) { | |
25 | $tweet_text = $tweet['text']; | |
26 | + | |
27 | - | + |
27 | + | + if ($options['tweet_max_length'] && strlen($tweet_text) > $options['tweet_max_length']) { |
28 | - | + if ($options['tweet_max_length'] && strlen($tweet_text) > $options['tweet_max_length']) { |
28 | + | + $tweet_text = substr($tweet_text, 0, $options['tweet_max_length']) . '...'; |
29 | - | + $tweet_text = substr($tweet_text, 0, $options['tweet_max_length']) . '...'; |
29 | + | + $tweet_text = preg_replace('/\s(?:@\w+|#\w+|http\S+)\.{3}/', '...', $tweet_text); |
30 | - | + } |
30 | + | + } |
31 | $tweet_location = $tweet['place']['full_name']; | |
32 | $link_processed = ""; | |
33 | if(isset($tweet['retweeted_status'])) { | |
34 | @@ -270,7 +278,7 @@ | |
35 | $link_processed = process_links($whole_tweet, $options['links_new_window']); | |
36 | } | |
37 | else { | |
38 | - $link_processed = process_links($tweet['text'], $options['links_new_window']); | |
39 | - | + $link_processed = process_links($tweet_text, $options['links_new_window']); |
39 | + | + $link_processed = process_links($tweet_text, $options['links_new_window']); |
40 | } | |
41 | $tweet_time = strtotime($tweet['created_at']); | |
42 | if($options['show_local_time']) { | |
43 | @@ -456,6 +464,7 @@ | |
44 | $twitget_settings['twitter_username'] = stripslashes($_POST['twitget_username']); | |
45 | $twitget_settings['time_limit'] = (int) $_POST['twitget_refresh']; | |
46 | $twitget_settings['number_of_tweets'] = (int) $_POST['twitget_number']; | |
47 | - | + $twitget_settings['tweet_max_length'] = (int) $_POST['twitget_max_length']; |
47 | + | + $twitget_settings['tweet_max_length'] = (int) $_POST['twitget_max_length']; |
48 | $twitget_settings['time_format'] = stripslashes($_POST['twitget_time']); | |
49 | $twitget_settings['show_powered_by'] = (isset($show_powered)) ? true : false; | |
50 | $twitget_settings['consumer_key'] = stripslashes($_POST['twitget_consumer_key']); | |
51 | @@ -600,6 +609,14 @@ | |
52 | </td> | |
53 | </tr> | |
54 | <tr> | |
55 | - | + <th scope="row"><label for="twitget_max_length">Max Length of tweets</label></th> |
55 | + | + <th scope="row"><label for="twitget_max_length">Max Length of tweets</label></th> |
56 | - | + <td> |
56 | + | + <td> |
57 | - | + <input type="text" name="twitget_max_length" id="twitget_max_length" value="<?php echo $twitget_options['tweet_max_length']; ?>" /> |
57 | + | + <input type="text" name="twitget_max_length" id="twitget_max_length" value="<?php echo $twitget_options['tweet_max_length']; ?>" /> |
58 | - | + <br /> |
58 | + | + <br /> |
59 | - | + <span class="description">Maximum length of a tweet in characters.</span> |
59 | + | + <span class="description">Maximum length of a tweet in characters.</span> |
60 | - | + </td> |
60 | + | + </td> |
61 | - | + </tr> |
61 | + | + </tr> |
62 | - | + <tr> |
62 | + | + <tr> |
63 | <th scope="row"><label for="twitget_time">Time format</label></th> | |
64 | <td> | |
65 | - | <input type="text" name="twitget_time" id="twitget_time" value="<?php echo esc_html($twitget_options['time_format']); ?>" /> |
65 | + | <input type="text" name="twitget_time" id="twitget_time" value="<?php echo esc_html($twitget_options['time_format']); ?>" /> |