WordPress.org

Plugin Directory

Changeset 617491


Ignore:
Timestamp:
10/25/12 19:03:16 (18 months ago)
Author:
alexkingorg
Message:

3.0.2, full history is in GitHub

Location:
twitter-tools/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • twitter-tools/trunk/README.txt

    r613060 r617491  
    44Requires at least: 3.4 
    55Tested up to: 3.4.2 
    6 Stable tag: 3.0.1 
     6Stable tag: 3.0.2 
    77License: GPLv2 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    125125== Upgrade Notice == 
    126126 
    127 Version 3.0 is a complete rewrite that utilizes <a href="http://wordpress.org/extend/plugins/social/">Social</a> to make connecting your Twitter account easy. It is compatibile with the latest Twitter API changes as of October 11, 2012. 
     127Version 3.0.2 is a recommended bug fix release. 
     128 
     129Version 3.0 is a complete rewrite that utilizes <a href="http://wordpress.org/extend/plugins/social/">Social</a> to make connecting your Twitter account easy. It is compatibile with the latest Twitter API changes as of October 11, 2012. Please see the <a href="http://alexking.org/blog/2012/10/12/twitter-tools-3-0-faq">FAQ</a> for more details. 
    128130 
    129131== Changelog == 
     132 
     133= 3.0.2 = 
     134 
     135* Add `aktt_tweet_create_blog_post` filter to allow other plugins/code to make programatic decisions about when to create blog posts from tweets 
     136* Add `aktt_tweet_create_blog_post_format` filter to allow post format to changed or omitted 
     137* Properly apply title prefix when creating blog posts 
     138* Address misc. multi-byte string issues 
     139* Fix GMT/local time issues and set time properly for tweets and posts 
     140* Properly enable featured image for tweet post type by merging with existing enabled post types 
     141 
    130142 
    131143= 3.0.1 = 
     
    133145* Set categories and post tags properly on posts created from tweets 
    134146* Set GMT date explicitly for blog posts created from tweets (fixes time offset issue) 
    135 * Make enabled/disabled accounts more explicit 
     147* Make enabled/disabled accounts more explicit visually 
    136148 
    137149 
  • twitter-tools/trunk/classes/aktt.php

    r613060 r617491  
    3030        $thumbnails = get_theme_support('post-thumbnails'); 
    3131        if (is_array($thumbnails)) { 
    32             add_theme_support('post-thumbnails', array_merge($thumbnails, array(self::$post_type))); 
     32            add_theme_support('post-thumbnails', array_merge($thumbnails[0], array(self::$post_type))); 
    3333        } 
    3434        else if (!$thumbnails) { 
     
    10531053 
    10541054    static function profile_prefix($username, $prefix = '@') { 
    1055         if (substr($username, 0, 1) != '#') { 
     1055        if (AKTT::substr($username, 0, 1) != '#') { 
    10561056            $username = '@'.$username; 
    10571057        } 
     
    10701070     
    10711071    static function hashtag_prefix($hashtag, $prefix = '#') { 
    1072         if (substr($hashtag, 0, 1) != '#') { 
     1072        if (AKTT::substr($hashtag, 0, 1) != '#') { 
    10731073            $hashtag = '#'.$hashtag; 
    10741074        } 
     
    11161116    } 
    11171117 
     1118    static function gmt_to_wp_time($gmt_time) { 
     1119        $timezone_string = get_option('timezone_string'); 
     1120        if (!empty($timezone_string)) { 
     1121            // Not using get_option('gmt_offset') because it gets the offset for the 
     1122            // current date/time which doesn't work for timezones with daylight savings time. 
     1123            $gmt_date = date('Y-m-d H:i:s', $gmt_time); 
     1124            $datetime = new DateTime($gmt_date); 
     1125            $datetime->setTimezone(new DateTimeZone(get_option('timezone_string'))); 
     1126            $offset_in_secs = $datetime->getOffset(); 
     1127             
     1128            return $gmt_time + $offset_in_secs; 
     1129        } 
     1130        else { 
     1131            return $gmt_time + (get_option('gmt_offset') * 3600); 
     1132        } 
     1133    } 
     1134 
     1135    static function substr_replace($string, $replacement, $start, $length = null, $encoding = null) { 
     1136        // from http://www.php.net/manual/en/function.substr-replace.php#90146 
     1137        // via https://github.com/ruanyf/wp-twitter-tools/commit/56d1a4497483b2b39f434fdfab4797d8574088e5 
     1138        if (extension_loaded('mbstring') === true) { 
     1139            $string_length = (is_null($encoding) === true) ? mb_strlen($string) : mb_strlen($string, $encoding); 
     1140             
     1141            if ($start < 0) { 
     1142                $start = max(0, $string_length + $start); 
     1143            } 
     1144            else if ($start > $string_length) { 
     1145                $start = $string_length; 
     1146            } 
     1147            if ($length < 0) { 
     1148                $length = max(0, $string_length - $start + $length); 
     1149            } 
     1150            else if ((is_null($length) === true) || ($length > $string_length)) { 
     1151                $length = $string_length; 
     1152            } 
     1153            if (($start + $length) > $string_length) { 
     1154                $length = $string_length - $start; 
     1155            } 
     1156            if (is_null($encoding) === true) { 
     1157                return mb_substr($string, 0, $start) . $replacement  
     1158                    . mb_substr($string, $start + $length, $string_length - $start - $length); 
     1159            } 
     1160            return mb_substr($string, 0, $start, $encoding) . $replacement  
     1161                . mb_substr($string, $start + $length, $string_length - $start - $length, $encoding); 
     1162        } 
     1163        else { 
     1164            return (is_null($length) === true) ? substr_replace($string, $replacement, $start) : substr_replace($string, $replacement, $start, $length); 
     1165        } 
     1166    } 
     1167 
     1168    static function strlen($str, $encoding = null) { 
     1169        if (function_exists('mb_strlen')) { 
     1170            if (is_null($encoding) === true) { 
     1171                return mb_strlen($str); 
     1172            } 
     1173            else { 
     1174                return mb_strlen($str, $encoding); 
     1175            } 
     1176        } 
     1177        else { 
     1178            return strlen($str); 
     1179        } 
     1180    } 
     1181 
     1182    static function substr($str, $start, $length) { 
     1183        if (function_exists('mb_substr')) { 
     1184            return mb_substr($str, $start, $length); 
     1185        } 
     1186        else { 
     1187            return substr($str, $start, $length); 
     1188        } 
     1189    } 
     1190 
    11181191} 
    11191192 
  • twitter-tools/trunk/classes/aktt_account.php

    r611071 r617491  
    167167            'post_category' => $this->option('post_category'), 
    168168            'post_tags' => $this->option('post_tags'), 
    169             'title_prefix' => $this->option('blog_post_title_prefix'), 
     169            'title_prefix' => $this->option('blog_post_title'), 
    170170        ); 
    171171         
  • twitter-tools/trunk/classes/aktt_tweet.php

    r613060 r617491  
    7474    public function title() { 
    7575        if (isset($this->data)) { 
    76             $title = trim(substr($this->data->text, 0, 50)); 
    77             if (strlen($this->data->text) > 50) { 
     76            $title = trim(AKTT::substr($this->data->text, 0, 50)); 
     77            if (AKTT::strlen($this->data->text) > 50) { 
    7878                $title = $title.'...'; 
    7979            } 
     
    283283     */ 
    284284    function is_reply() { 
    285         return (bool) (substr($this->content(), 0, 1) == '@' || !empty($this->data->in_reply_to_screen_name)); 
     285        return (bool) (AKTT::substr($this->content(), 0, 1) == '@' || !empty($this->data->in_reply_to_screen_name)); 
    286286    } 
    287287     
     
    293293     */ 
    294294    function is_retweet() { 
    295         return (bool) (substr($this->content(), 0, 2) == 'RT' || !empty($this->data->retweeted_status)); 
     295        return (bool) (AKTT::substr($this->content(), 0, 2) == 'RT' || !empty($this->data->retweeted_status)); 
    296296    } 
    297297     
     
    354354// $log[] = 'diff: '.$diff; 
    355355// $log[] = 'entity start: '.$entity['start']; 
    356 // $log[] = 'entity start chars: '.substr($this->content(), $entity['start'], 3); 
     356// $log[] = 'entity start chars: '.AKTT::substr($this->content(), $entity['start'], 3); 
    357357// $log[] = 'diff start: '.$start; 
    358 // $log[] = 'diff start chars: '.substr($str, $start, 3); 
     358// $log[] = 'diff start chars: '.AKTT::substr($str, $start, 3); 
    359359// $log[] = 'entity end: '.$entity['end']; 
    360360// $log[] = 'diff end: '.$end; 
    361 // $log[] = 'find len: '.strlen($entity['find']); 
     361// $log[] = 'find len: '.AKTT::strlen($entity['find']); 
    362362// $log[] = 'find: '.htmlspecialchars($entity['find']); 
    363 // $log[] = 'replace len: '.strlen($entity['replace']); 
     363// $log[] = 'replace len: '.AKTT::strlen($entity['replace']); 
    364364// $log[] = 'replace: '.htmlspecialchars($entity['replace']); 
    365365// echo '<p>'.implode('<br>', $log).'</p>'; 
    366             $str = substr_replace($str, $entity['replace'], $start, ($end - $start)); 
    367             $diff += strlen($entity['replace']) - ($end - $start); 
     366            $str = AKTT::substr_replace($str, $entity['replace'], $start, ($end - $start)); 
     367            $diff += AKTT::strlen($entity['replace']) - ($end - $start); 
    368368        } 
    369369        return $str; 
     
    464464     */ 
    465465    function add() { 
     466        $gmt_time = self::twdate_to_time($this->date()); 
    466467        // Build the post data 
    467468        $data = apply_filters('aktt_tweet_add', array( 
     
    471472            'post_status' => 'publish', 
    472473            'post_type' => AKTT::$post_type, 
    473             'post_date_gmt' => date('Y-m-d H:i:s', self::twdate_to_time($this->date())), 
     474            'post_date' => date('Y-m-d H:i:s', AKTT::gmt_to_wp_time($gmt_time)), 
     475            'post_date_gmt' => date('Y-m-d H:i:s', $gmt_time), 
    474476            'guid' => $this->guid(), 
    475477//          'tax_input' => $tax_input, // see below... 
     
    533535         
    534536        // Add a space if we have a prefix 
    535         $title_prefix = empty($title_prefix) ? '' : $title_prefix.' '; 
     537        $title_prefix = empty($title_prefix) ? '' : trim($title_prefix).' '; 
    536538 
    537539        $post_content = $this->link_entities(false); 
     
    541543            $post_content .= "\n\n".wp_get_attachment_image($this->featured_image_id, $size); 
    542544        } 
     545         
     546        $gmt_time = self::twdate_to_time($this->date()); 
    543547         
    544548        // Build the post data 
     
    554558            'post_status' => 'publish', 
    555559            'post_type' => 'post', 
    556             'post_date_gmt' => date('Y-m-d H:i:s', self::twdate_to_time($this->meta['created_at'])), 
     560            'post_date' => date('Y-m-d H:i:s', AKTT::gmt_to_wp_time($gmt_time)), 
     561            'post_date_gmt' => date('Y-m-d H:i:s', $gmt_time), 
    557562            'guid' => $this->guid().'-post' 
    558563        ); 
    559564        $data = apply_filters('aktt_tweet_create_blog_post_data', $data); 
     565 
     566        // hook in here if you want to conditionally skip blog post creation 
     567        if (!apply_filters('aktt_tweet_create_blog_post', true, $data, $this)) { 
     568            return false; 
     569        } 
    560570 
    561571        $this->blog_post_id = wp_insert_post($data, true); 
     
    571581        wp_set_object_terms($this->blog_post_id, array_map('trim', explode(',', $post_tags)), 'post_tag'); 
    572582 
    573         set_post_format($this->blog_post_id, 'status'); 
     583        // hook in here and return false to not set the format to "status",  
     584        // or return another format to use that format instead of status 
     585        if ($post_format = apply_filters('aktt_tweet_create_blog_post_format', 'status', $data, $this)) { 
     586            set_post_format($this->blog_post_id, $post_format); 
     587        } 
    574588         
    575589        if (!empty($this->featured_image_id)) { 
  • twitter-tools/trunk/twitter-tools.php

    r613060 r617491  
    44Plugin URI: http://crowdfavorite.com/wordpress/plugins/twitter-tools/ 
    55Description: An integration between your WordPress site and Twitter. Create posts from your tweets. Show your tweets in your sidebar. Relies on <a href="http://wordpress.org/extend/plugins/social/">Social</a>. 
    6 Version: 3.0.1 
     6Version: 3.0.2 
    77Author: Crowd Favorite 
    88Author URI: http://crowdfavorite.com 
Note: See TracChangeset for help on using the changeset viewer.