Advertisement
mwcavender

Twitget Change Proposal

Jun 13th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.76 KB | None | 0 0
  1. --- twitget.php 2013-05-27 18:27:32.000000000 -0400
  2. +++ twitget_proposed.php    2013-06-13 10:58:44.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,
  8.         'show_avatar' => true,
  9.         'time_format' => 'D jS M y H:i',
  10.         'show_powered_by' => false,
  11. @@ -131,7 +132,10 @@
  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
  17. +       ob_start();
  18. +       show_recent_tweets();
  19. +       return ob_get_clean();
  20.     }
  21.  
  22.     function twitter_status_11() {
  23. @@ -261,6 +265,10 @@
  24.             $tweet_date_array = array();
  25.             foreach($tweets as $tweet) {
  26.                 $tweet_text = $tweet['text'];
  27. +              
  28. +               if ($options['tweet_max_length'] && strlen($tweet_text) > $options['tweet_max_length']) {
  29. +                   $tweet_text = substr($tweet_text, 0, $options['tweet_max_length']) . '...';
  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']);
  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'];
  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>
  56. +                       <td>
  57. +                           <input type="text" name="twitget_max_length" id="twitget_max_length" value="<?php echo $twitget_options['tweet_max_length']; ?>" />
  58. +                           <br />
  59. +                           <span class="description">Maximum length of a tweet in characters.</span>
  60. +                       </td>
  61. +                   </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']); ?>" />
  66. @@ -761,5 +778,3 @@
  67.         }
  68.  
  69.     }
  70. -  
  71. -?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement