Plugin Directory

Changeset 382285


Ignore:
Timestamp:
05/07/2011 11:31:23 PM (15 years ago)
Author:
0xTC
Message:
 
Location:
wp-tweet-button/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-tweet-button/trunk/inc/settings.frame.inc.php

    r356478 r382285  
    66            <div id="<?php echo $this->pluginslug; ?>-mbox-general" class="wrap">
    77                <?php screen_icon('options-general'); ?>
    8                 <h2><? echo $this->pluginlabel; ?></h2>
     8                <h2><?php echo $this->pluginlabel; ?></h2>
    99                <?php
    1010                wp_nonce_field($this->pluginslug.'-mbox-general');
  • wp-tweet-button/trunk/inc/settings.inc.php

    r375255 r382285  
    2424            if ($thisobj->tw_get_option('tw_url_shortener_google_token') !=''){
    2525                echo '<p><a href="'.$thisobj->settingsuri.'&goauth=delete" class="button">'.__ ('Remove authorization data',$thisobj->txtdom).'</a></p>';
    26                 ?><input type="hidden" value="<?php echo $thisobj->tw_get_option('tw_url_shortener_google_token');?>" name="tw_url_shortener_google_token" /><?
     26                ?><input type="hidden" value="<?php echo $thisobj->tw_get_option('tw_url_shortener_google_token');?>" name="tw_url_shortener_google_token" /><?php
    2727            } else {
    2828                $gsparams = http_build_query(
     
    3333                    )
    3434                );
     35                ?><input type="button" class="button" value="Authorize goo.gl tracking" onclick="window.location = '<?php echo $google_auth_url;?>';"/><br /><?php
    3536                $google_auth_url = 'https://www.google.com/accounts/AuthSubRequest' . '?' . $gsparams;
    36                 ?><input type="button" class="button" value="Authorize goo.gl tracking" onclick="window.location = '<?php echo $google_auth_url;?>';"/><br /><?
    3737            }
    3838        }
     
    118118                            <div class="floatleft180" style="clear:left;">
    119119                                <?php echo tw_checkbox_input($this, 'tw_display_front','Front page (home)'); ?>
    120 
    121120                            </div>
    122121                            <div class="floatleft100">
     
    135134                            if (function_exists("bnc_wptouch_is_mobile")) {
    136135                            ?>
    137                             <div class="floatleft180">
     136                            <div class="floatleft100">
    138137                                <?php echo tw_checkbox_input($this, 'tw_display_mobile','Mobile (WPTouch)'); ?>
    139138                            </div>
     
    141140                            }
    142141                            ?>
     142                            <div class="floatleft180" style="clear:left;">
     143                                <?php echo tw_checkbox_input($this, 'tw_ex_after_archive','No After in Archives'); ?>
     144                            </div>
    143145                            <div class="floatleft180" style="clear:left;">
    144146                                <?php echo tw_checkbox_input($this, 'tw_ex_after_home','No After on Front page'); ?>
     
    247249                            <p>
    248250                                <code>%POSTTITLE%</code> - <?php _e('The post\'s title.',$this->txtdom);?><br />
     251                                <code>%POSTCONTENT%</code> - <?php _e('The post\'s content.',$this->txtdom);?><br />
    249252                                <code>%BLOGTITLE%</code> - <?php _e('The blog\'s name.',$this->txtdom);?>
    250253                                <code>%BLOGHASHTAGS%</code> - <?php _e('#Hash tags generated using blog tags.',$this->txtdom);?>
     
    269272                                <input type="hidden" value="<?php echo $this->tw_get_option('tw_auto_tweet_token_secret');?>" name="tw_auto_tweet_token_secret" />
    270273                                <p><?php _e('When posts are:',$this->txtdom); ?><br />
    271                                     <!-- input type="checkbox" value="1" <?php
    272                                         if ($this->tw_get_option('tw_auto_tweet_token') == '' || $this->tw_get_option('tw_auto_tweet_token_secret') == '') echo 'disabled="disabled"';
    273                                         if ($this->tw_get_option('tw_auto_tweet_posts') == '1') echo 'checked="checked"';
    274                                     ?> name="tw_auto_tweet_posts" id="tw_auto_tweet_posts" />
    275                                     <label for="tw_auto_tweet_posts"><?php _e('Created',$this->txtdom); ?></label -->
    276274                                    <?php echo tw_checkbox_input($this, 'tw_auto_tweet_posts','Created'); ?><br />
    277275                                    <?php echo tw_checkbox_input($this, 'tw_auto_tweet_posts_onsave','Saved'); ?><br />
    278 
    279                                     <!-- input type="checkbox" value="1" <?php
    280                                         if ($this->tw_get_option('tw_auto_tweet_token') == '' || $this->tw_get_option('tw_auto_tweet_token_secret') == '') echo 'disabled="disabled"';
    281                                         if ($this->tw_get_option('tw_auto_tweet_posts_onsave') == '1') echo 'checked="checked"';
    282                                     ?> name="tw_auto_tweet_posts_onsave" id="tw_auto_tweet_posts_onsave" />
    283                                     <label for="tw_auto_tweet_posts_onsave"><?php _e('Saved',$this->txtdom); ?></label --><br />
    284276                                </p>
    285277                                <p><?php _e('When pages are:',$this->txtdom); ?><br />
    286278                                    <?php echo tw_checkbox_input($this, 'tw_auto_tweet_pages','Created'); ?><br />
    287279                                    <?php echo tw_checkbox_input($this, 'tw_auto_tweet_pages_onsave','Saved'); ?><br />
    288 
    289                                     <!-- input type="checkbox" value="1" <?php
    290                                         if ($this->tw_get_option('tw_auto_tweet_token') == '' || $this->tw_get_option('tw_auto_tweet_token_secret') == '') echo 'disabled="disabled"';
    291                                         if ($this->tw_get_option('tw_auto_tweet_pages') == '1') echo 'checked="checked"';
    292                                     ?> name="tw_auto_tweet_pages" id="tw_auto_tweet_pages" />
    293                                     <label for="tw_auto_tweet_pages"><?php _e('Created',$this->txtdom); ?></label><br />                               
    294 
    295                                     <input type="checkbox" value="1" <?php
    296                                         if ($this->tw_get_option('tw_auto_tweet_token') == '' || $this->tw_get_option('tw_auto_tweet_token_secret') == '') echo 'disabled="disabled"';
    297                                         if ($this->tw_get_option('tw_auto_tweet_pages_onsave') == '1') echo 'checked="checked"';
    298                                     ?> name="tw_auto_tweet_pages_onsave" id="tw_auto_tweet_pages_onsave" />
    299                                     <label for="tw_auto_tweet_pages_onsave"><?php _e('Saved',$this->txtdom); ?></label><br / -->
    300280                                </p>
    301281                                <p>
    302                                 <?php _e('If the tweet text + url is too long ',$this->txtdom);?>
    303                                     <select name="tw_auto_tweet_strip" id="tw_auto_tweet_strip">
    304                                         <option value="url" <?php if ($this->tw_get_option('tw_auto_tweet_strip') == 'url') echo 'selected="selected"'; ?>><?php _e('remove the URL',$this->txtdom);?></option>
    305                                         <option value="text" <?php if ($this->tw_get_option('tw_auto_tweet_strip') == 'text') echo 'selected="selected"'; ?>><?php _e('remove the text',$this->txtdom);?></option>
    306                                         <option value="stext" <?php if ($this->tw_get_option('tw_auto_tweet_strip') == 'stext') echo 'selected="selected"'; ?>><?php _e('shorten the text',$this->txtdom);?></option>
    307                                         <option value="tryall" <?php if ($this->tw_get_option('tw_auto_tweet_strip') == 'tryall') echo 'selected="selected"'; ?>><?php _e('try anything that works',$this->txtdom);?></option>
    308                                         <option value="notweet" <?php if ($this->tw_get_option('tw_auto_tweet_strip') == 'notweet') echo 'selected="selected"'; ?>><?php _e('do not auto-tweet',$this->txtdom);?></option>
    309                                     </select>
    310                                 </p><?php
     282                                    <?php echo tw_checkbox_input($this, 'tw_auto_long_tweet_mode','Long Tweet Mode'); ?><br />
     283                                    <?php _e('When enabled, automatically generated tweets will consist of the first part of your entry followed by a link. Use this option to override the "Default Tweet text" setting.',$this->txtdom);?>
     284                                </p>
     285<?php
    311286                            } ?>
    312287                           
     
    474449                            <select name="tw_hook_prio" id="tw_hook_prio" title="<?php echo $this->tw_get_option('tw_hook_prio');?>" class="w99c29c">
    475450                            <option value="75">75 (Default)</option>
    476                             <option <?=($this->tw_get_option('tw_hook_prio')=='101')?'selected="selected"':'';?> value="101">101</option>
    477                             <option <?=($this->tw_get_option('tw_hook_prio')=='501')?'selected="selected"':'';?> value="501">501</option>
    478                             <option <?=($this->tw_get_option('tw_hook_prio')=='1001')?'selected="selected"':'';?> value="1001">1001</option>
     451                            <option <?php echo ($this->tw_get_option('tw_hook_prio')=='101')?'selected="selected"':'';?> value="101">101</option>
     452                            <option <?php echo ($this->tw_get_option('tw_hook_prio')=='501')?'selected="selected"':'';?> value="501">501</option>
     453                            <option <?php echo ($this->tw_get_option('tw_hook_prio')=='1001')?'selected="selected"':'';?> value="1001">1001</option>
    479454                            </select>
    480455                            <script type="text/javascript">
     
    557532        </div>
    558533        <p style="margin-left:20px;">
    559             <?php echo sprintf(__("<a href='%1\$s' class='button'>Show settings for diagnostics</a>"), $this->settingsuri.'&amp;showdiag=1');?> 
     534            <?php echo sprintf(__("<a href='%1\$s' class='button'>Show settings for diagnostics</a>"), $this->settingsuri.'&amp;showdiag=1');?>
    560535            <?php echo sprintf(__("<a href='%1\$s' target='_blank' class='button'>Report a bug</a>"), 'http://0xtc.com/plugins/wp-tweet-button');?>
    561             <?php echo sprintf(__("<a href='%1\$s' target='_blank' class='button'>Hire the author</a>"), 'http://0xtc.com/contact');?>
    562536        </p>
    563537        <p style="margin-left:20px;margin-top:20px;">
  • wp-tweet-button/trunk/readme.txt

    r375255 r382285  
    33Tags: twitter, tweet button, retweet, tweet, autotweet, WP Tweet Button, advanced, tweeting, social media, button, SEO, share, shortener, goo.gl, awe.sm, b2l.me, bit.ly, cli.gs, sl.ly, snipr, su.pr, tinyurl, analytics, google analytics, campaign, campaign tracking, auto tweeting, auto posts, auto tweet, android
    44Requires at least: 3.0
    5 Tested up to: 3.1.1
     5Tested up to: 3.1.2
    66Stable tag: trunk
    77Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6331357
     
    2121* Can be set to vertical, horizontal or no counter.
    2222* Authors can configure their own Twitter accounts on their profile pages. (WP3.x only)
    23 * Supports **Auto-Tweeting** posts.
     23* Supports customizable **Auto-Tweeting**.
    2424* Supports all Tweet Button languages.
    2525* Supports exclusion by custom post type
     
    2727* **Google Analytics** support for campaign tracking.
    2828* Option to switch between '{text} {link} via {@user}' and 'RT {@user} {text} {link}' formats.
    29 * Templatable Tweet texts using tags (`%POSTTITLE%`, `%BLOGTITLE%`, `%BLOGHASHTAGS%`, `%BLOGHASHCATS%`).
     29* Templatable Tweet texts using tags (`%POSTCONTENT%`, `%POSTTITLE%`, `%BLOGTITLE%`, `%BLOGHASHTAGS%`, `%BLOGHASHCATS%`).
    3030* Supports data tag output.
    3131* Includes hooks for 3rd party developers.
     
    130130== Changelog ==
    131131
     132= 2.1.0 =
     133* Added option to exclude button blow posts in the archives (No After in Archives)
     134* Optimized code resulting in cleaner text cuts
     135* Added support for %POSTCONTENT% variable in tweet customizations
     136* Added "Long Tweet Mode" (In case you don't want to use %POSTCONTENT% as your "Custom text"). This allows you to auto-tweet the first part of your content followed by a link that takes the reader to the entry on your site.
     137* Links are included in all Autotweets by default. Options to decide action has been removed.
     138
    132139= 2.0.9 =
    133140* Added support for # Analytics query delimiter (for people that use setAllowAnchor). Enabling this option may require clearing your shortlink cache by using the "Delete all previously saved shortlinks when I save." option.
  • wp-tweet-button/trunk/wp-tweet-button.php

    r375255 r382285  
    22/*
    33Plugin Name: WP Tweet Button
    4 Version: 2.0.9
     4Version: 2.1.0
    55Plugin URI: http://0xtc.com/plugins/wp-tweet-button
    66Description: The WordPress implementation of the official Twitter Tweet Button.
     
    102102        'tw_display_mobile'=>'',
    103103        'tw_ex_after_home'=>'',
     104        'tw_ex_after_archive'=>'',
    104105        'tw_bwdata_attr'=> '',
    105106        'tw_use_rel_me'=> '',
     
    116117        'tw_auto_tweet_pages_onsave'=>'',
    117118        'tw_auto_tweet_strip'=>'stext',
     119        'tw_auto_long_tweet_mode'=>'',
    118120        'tw_script_infooter'=>'0',
    119121        'tw_prev_content_dup'=>'1'
     
    130132        'tw_display_search',
    131133        'tw_ex_after_home',
     134        'tw_ex_after_archive',
    132135        'tw_display_archive',
    133136        'tw_display_page',
     
    148151        'tw_auto_tweet_posts_onsave'=>'',
    149152        'tw_auto_tweet_pages_onsave'=>'',
     153        'tw_auto_long_tweet_mode'=>'',
    150154        'tw_no_https_shortlinks',
    151155        'tw_prev_content_dup',
     
    470474    * This function decides the format of the tweet text based on preferences and limitations.
    471475    */
    472     function tw_get_text($entitydecode=false){
     476    function tw_get_text($entitydecode=false,$dots=true){
    473477        $activepost = $this->tw_get_activepost();
    474478        if (get_post_meta($activepost->ID, '_twitterrelated_custom_text', true)){
     
    480484        } else {
    481485            $tw_text = $this->tw_get_option('tw_text');
    482             // if ($tw_text=='entry_title') { $button_data_text = $activepost->post_title;}
    483486            if ($tw_text=='entry_title') { $button_data_text = get_the_title($activepost->ID);}
    484             // if ($tw_text=='page_title') { $button_data_text = $activepost->post_title .' - '. get_bloginfo('name');}
    485487            if ($tw_text=='page_title') { $button_data_text = get_the_title($activepost->ID) .' - '. get_bloginfo('name');}
    486488            if ($tw_text=='blog_title')  { $button_data_text = get_bloginfo('name');}
    487489            if ($tw_text=='custom_title') { $button_data_text = $this->tw_preptext(stripslashes($this->tw_get_option('tw_text_custom')));}
     490            $button_data_text = trim ($button_data_text);
     491            $maxlen = 140;
     492            $maxlen = $maxlen - strlen($this->tw_get_option('tw_via'));     // username
     493            $maxlen = $maxlen - 1;                                          // @
     494            $maxlen = $maxlen - 1;                                          // [space]         
     495            if ($this->tw_get_option('tw_text_format')=='VIA') $maxlen = $maxlen - 3;
     496            if ($this->tw_get_option('tw_text_format')=='RT') $maxlen = $maxlen - 2;
     497            $maxlen = $maxlen - 1;                                          // [space]
     498            if ($dots) $maxlen = $maxlen - 19;                              // link
     499            if ($dots) $maxlen = $maxlen - 1;                               // [space]
     500            $n_button_data_text = $this->tw_clean_trim ($button_data_text,$maxlen, $dots);
     501            $button_data_text = $n_button_data_text;
    488502        }
    489503        return $button_data_text;
    490504    }
    491505   
     506   
     507   
     508    /**
     509    * Applies formatting and transformations to texts.
     510    */ 
     511    function tw_clean_trim($text,$len,$dots=true){
     512            if (strlen($text)<=$len){return $text;}
     513            if ($dots) {$spacing = 4;}else{$spacing=0;}
     514            $string = wordwrap(trim($text), $len - $spacing);
     515            $string = substr($string, 0, strpos($string, "\n"));           
     516            if ($dots && (strlen($string)<=(strlen($text)+$spacing))){
     517                $string .= '... ';
     518            }
     519            return $string;
     520
     521    }
    492522    /**
    493523    * Applies formatting and transformations to texts.
     
    496526        $activepost = $this->tw_get_activepost();
    497527        $tmptxt = null;
    498 //      $tmptxt= str_replace('%POSTTITLE%', $activepost->post_title, $text);
    499         $tmptxt= str_replace('%POSTTITLE%', get_the_title($activepost->ID), $text);
     528        $tmptxt= str_replace('%POSTCONTENT%', strip_tags($activepost->post_content), $text);
     529        $tmptxt= str_replace('%POSTTITLE%', get_the_title($activepost->ID), $tmptxt);
    500530        $tmptxt= str_replace('%BLOGTITLE%', get_bloginfo('name'), $tmptxt);
    501531        $tmptxt= str_replace('%BLOGHASHTAGS%', $this->tw_get_hash_tags(), $tmptxt);
     
    546576
    547577            if ($this->tw_get_option('tw_auto_tweet_posts_onsave')=='1' || $this->tw_get_option('tw_auto_tweet_pages_onsave')=='1'){
    548                 add_action('publish_post',      array(&$this, 'tw_send_auto_tweet'),100,1);
     578                add_action('publish_post',              array(&$this, 'tw_send_auto_tweet'),100,1);
    549579                add_action('xmlrpc_publish_post',       array(&$this, 'tw_send_auto_tweet'),100,1);
    550                 add_action('publish_page',      array(&$this, 'tw_send_auto_tweet'),100,1);
     580                add_action('publish_page',              array(&$this, 'tw_send_auto_tweet'),100,1);
    551581            }
    552582
     
    830860        $button_data_via=null;
    831861        $button_data_status_id = null;
    832         $button_data_url = 'data-url="' . $this->tw_get_the_url(true) . '"';
     862        $theurl = $this->tw_get_the_url(true);
     863        $button_data_url = 'data-url="' . $theurl . '"';
    833864        $viauser = $this->tw_get_twitter_name();
    834865        if ($viauser){
     
    847878//          $button_data_status_id = 'data-status-id="'.$tid.'"';
    848879        }
    849         $button_data_text = 'data-text="'.$textprefix . htmlspecialchars($this->tw_get_text()).'"';
     880        $button_data_text = 'data-text="'.$textprefix . htmlspecialchars($this->tw_get_text(null)).'"';
    850881        $button_data_related = 'data-related="'.$this->tw_get_related_text().'"';
    851882        $button_data_count = 'data-count="'.$this->tw_get_option('tw_count').'"';
     
    872903        if ($bwdata==true && !is_feed()){return false;}
    873904        $viauser = $this->tw_get_twitter_name();
    874         $button = '?url=' . urlencode($this->tw_get_the_url(true));
     905        $theurl = $this->tw_get_the_url(true);
     906        $button = '?url=' . urlencode($theurl);
    875907        if ($viauser){
    876908            if ($this->tw_get_option('tw_text_format')=='VIA' || $this->tw_get_option('tw_use_rel_me')=='1') {
     
    944976    function tw_get_long_url($addtrack=false, $addlang=true) {
    945977        global $my_transposh_plugin;
    946         if (!in_the_loop() && is_home()){return home_url();}   
     978        if (!in_the_loop() && is_home()){return home_url();}
    947979        $activepost = $this->tw_get_activepost();
    948980        $perms=null;
     
    11411173        $alignment = $this->tw_get_option('tw_align');
    11421174        if ($alignment!='none' && $this->tw_get_option('tw_align')!=null && $alignment!=''){
    1143             if ($alignment=='right') $alignstr = ';float:right;margin-left:10px;';
    1144             if ($alignment=='left') $alignstr = ';float:left;margin-right:10px;';
    1145             if ($alignment=='center') $alignstr = ';float:none;margin:0 auto;text-align:center;';
    1146         }
    1147 
    1148         if ($this->tw_get_option('tw_nostyle_feed') == ''){
    1149             $StyleStrDiv = ' style="' . $this->tw_get_option('tw_style_c') . $alignstr . '"';
     1175            if ($alignment=='right') $alignstr = 'float:right;margin-left:10px;';
     1176            if ($alignment=='left') $alignstr = 'float:left;margin-right:10px;';
     1177            if ($alignment=='center') $alignstr = 'float:none;margin:0 auto;text-align:center;';
     1178        }
     1179        $dssep = null;
     1180        $userstyle = $this->tw_get_option('tw_style_c');
     1181        if ($userstyle!=''){
     1182            if (substr($userstyle, -1)==';'){$dssep='';}else{$dssep=';';}
     1183        }
     1184        if (($this->tw_get_option('tw_nostyle_feed') == '1') && (is_feed()=='1')){
     1185            $StyleStrDiv = '';
     1186            $StyleStrBtn = '';
     1187        } else {
     1188            $StyleStrDiv = ' style="' . $this->tw_get_option('tw_style_c') .$dssep. $alignstr . '"';
    11501189            $StyleStrBtn = ' style="width:55px;height:22px;background:transparent url(\''. WP_PLUGIN_URL.'/wp-tweet-button/tweetn.png\') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;"';
    1151         } else {
    1152             $StyleStrDiv = '';
    1153             $StyleStrBtn = ''; 
    11541190        }
    11551191        if ($this->ismanual){$btnidattr='m';}else{$btnidattr='';}
     
    12071243            return str_replace('[tweetbutton]', $button, $content);
    12081244        } else if ($where == 'beforeandafter') {
    1209             if ($this->tw_get_option('tw_ex_after_home') && (is_home() || is_front_page())){
     1245            if (
     1246                    ($this->tw_get_option('tw_ex_after_home') && (is_home() || is_front_page())) ||
     1247                    ($this->tw_get_option('tw_ex_after_archive') && (is_archive()))
     1248            ) {
    12101249                $this->hasbutton[$post->ID] = 1;
    12111250                return $button . $content;
    1212             } else {
    1213                 $this->hasbutton[$post->ID] = 1;
    1214                 return $button . $content . $button;           
    1215             }
     1251            }
     1252            $this->hasbutton[$post->ID] = 1;
     1253            return $button . $content . $button;
    12161254        } else if ($where == 'before') {
    12171255            $this->hasbutton[$post->ID] = 1;
     
    13551393            $this->postid = $thepost->ID;
    13561394        }               
    1357         if ($thepost->post_type == 'revision' || ($thepost->post_status != 'publish' && $thepost->post_status != 'future') || $thepost->post_password != '' ) return false;
     1395        if ($thepost->post_type == 'revision' || ($thepost->post_status != 'publish' && $thepost->post_status != 'future') || $thepost->post_password != '' ) return false;    
    13581396        if (
    13591397                (
    1360                     (($this->tw_get_option('tw_auto_tweet_posts') == '1' || $this->tw_get_option('tw_auto_tweet_posts_onsave') == '1') && $post_type_object->hierarchical=='') || 
    1361                     (($this->tw_get_option('tw_auto_tweet_pages') == '1' || $this->tw_get_option('tw_auto_tweet_pages_onsave') == '1') && $post_type_object->hierarchical=='1')
     1398                    (($this->tw_get_option('tw_auto_tweet_posts') == '1' || $this->tw_get_option('tw_auto_tweet_posts_onsave') == '1') && $post_type_object->hierarchical=='') ||       // posts
     1399                    (($this->tw_get_option('tw_auto_tweet_pages') == '1' || $this->tw_get_option('tw_auto_tweet_pages_onsave') == '1') && $post_type_object->hierarchical=='1')         // pages
    13621400                ) &&
    1363         $this->tw_get_option('tw_auto_tweet_token') != '' &&
    1364         $this->tw_get_option('tw_auto_tweet_token_secret') != '' &&
    1365         (get_post_meta($thepost->ID, '_tw_do_not_send_auto_tweet',true) == '') &&
    1366         ($_POST['tw_do_not_send_auto_tweet'] == '') &&
    1367         (get_post_meta($thepost->ID, '_tw_autotweeted',true) == '' || $_POST['tw_send_auto_tweet_again']==1)
     1401            $this->tw_get_option('tw_auto_tweet_token') != '' &&
     1402            $this->tw_get_option('tw_auto_tweet_token_secret') != '' &&
     1403            (get_post_meta($thepost->ID, '_tw_do_not_send_auto_tweet',true) == '') &&
     1404            ($_POST['tw_do_not_send_auto_tweet'] == '') &&
     1405            (get_post_meta($thepost->ID, '_tw_autotweeted',true) == '' || $_POST['tw_send_auto_tweet_again']==1)
    13681406        ){
    13691407            $Post_data = array();
    13701408            $Post_data['r_oauth_token']         =   $this->tw_get_option('tw_auto_tweet_token');
    13711409            $Post_data['r_oauth_token_secret']  =   $this->tw_get_option('tw_auto_tweet_token_secret');
    1372             $tweet_text                         =   $this->tw_validate_tweet($this->tw_get_text(),$this->tw_get_the_url());
     1410            if ($this->tw_get_option('tw_auto_long_tweet_mode')=='1'){
     1411                $tweet_text                         =   $this->tw_validate_tweet(trim(strip_tags($thepost->post_content)),$this->tw_get_the_url());
     1412            } else {
     1413                $tweet_text                         =   $this->tw_validate_tweet($this->tw_get_text(null,false),$this->tw_get_the_url());
     1414            }
    13731415            if ($tweet_text==false){return false;}
     1416
    13741417            $ctypes = array("ASCII", "UTF-8", "ISO-8859-15", "ISO-8859-1", "JIS", "EUC-JP");
    13751418            $enc = mb_detect_encoding($tweet_text,$ctypes);
     
    13801423            if (strstr($content,'error')==false && $content != '' && strstr($content,'<') == false) {
    13811424                add_post_meta($thepost->ID, '_tw_autotweeted', $content, TRUE) or update_post_meta($thepost->ID, '_tw_autotweeted', $content);
     1425            } else {
     1426                add_post_meta($thepost->ID, '_tw_autotweeted_errors', $content, TRUE) or update_post_meta($thepost->ID, '_tw_autotweeted_errors', $content);
    13821427            }
    13831428            return $content;
     
    13901435    */
    13911436    function tw_validate_tweet($text, $url){
    1392         $max    = 134;
     1437        // $tw_auto_tweet_strip = $this->tw_get_option('tw_auto_tweet_strip');
    13931438        if (strstr($url,admin_url())){return false;}
    1394         if ($url==false){return false;}
     1439        if ($url==false){
     1440            return false;
     1441        }
     1442        $max    = 140;
    13951443        $lurl   = strlen($url);
    1396         $ltext  = strlen(trim($text))+1;
    1397         if ($lurl+$ltext>$max){
    1398             if ($this->tw_get_option('tw_auto_tweet_strip')=='notweet'){
     1444        $ltext  = strlen(trim($text));
     1445        $maxtextlen = $max - 1 - $lurl;
     1446        if (($lurl+4+$ltext) > $max){
     1447            // The URL is longer than the maximum allowed tweet length.
     1448            if ($lurl>$max ){
    13991449                return false;
    14001450            }
    1401             if ($this->tw_get_option('tw_auto_tweet_strip')=='url'){
    1402                 if (strlen(trim($text))<=$max){
    1403                     return trim($text);
    1404                 } else {
    1405                     return false;
    1406                 }
    1407             }
    1408             if ($this->tw_get_option('tw_auto_tweet_strip')=='text'){
    1409                 if ($lurl<=$max){
    1410                     return $url;
    1411                 } else return false;
    1412             }
    1413             if ($this->tw_get_option('tw_auto_tweet_strip')=='stext'){
    1414                 $strmaxlen = $max - $lurl - 4;
    1415                 if (0 <= $strmaxlen){
    1416                     $string = wordwrap($text, $strmaxlen);
    1417                     $string = substr($string, 0, strpos($string, "\n"));
    1418                     $stext = $string.'... ';
    1419                 } else {
    1420                     return false;
    1421                 }
    1422                 if (strlen($stext.$url)<=$max) {
    1423                     return $stext.$url;
    1424                 } else return false;
    1425             }
    1426             if ($this->tw_get_option('tw_auto_tweet_strip')=='tryall'){
    1427                 $strmaxlen = $max - $lurl - 4;
    1428                 if (0 <= $strmaxlen){
    1429                     $string = wordwrap($text, $strmaxlen);
    1430                     $string = substr($string, 0, strpos($string, "\n"));
    1431                     $stext = $string.'... ';
    1432                     if (strlen($stext.$url)<=$max) {
    1433                         return $stext.$url;
    1434                     } else {
    1435                         if (strlen(trim($text))<=$max){
    1436                             return trim($text);
    1437                         } else {
    1438                             if ($lurl<=$max){
    1439                                 return $url;
    1440                             } else {
    1441                                 $string = wordwrap($text, $max-4);
    1442                                 $string = substr($string, 0, strpos($string, "\n"));
    1443                                 $stext = $string.'... ';
    1444                                 return $stext;
    1445                             }
    1446                         }
    1447                     }
    1448                 } else {
    1449                     if ($lurl<=$max){
    1450                         return $url;
    1451                     } else {
    1452                         return substr($text, 0, $max-2).'
    1453  ';
    1454                     }
    1455                 }
    1456             }
    1457         } else {
    1458             return $text.' '.$url;
     1451
     1452            // The length of the URL is between 138 and 140 characters. We can't add a title, but we can use the URL.
     1453            if (
     1454                ($lurl==$max ) ||
     1455                ( ($lurl>=$max-4) && ($lurl<=$max))
     1456                ){
     1457                return $url;
     1458            }
     1459
     1460            $strmaxlen = $max - $lurl;
     1461            $stext = $this->tw_clean_trim($text, $strmaxlen);
     1462           
     1463            // We shrunk the text and tries to fit it along with the URL but alas, the text disappeared in the shrinking process. We can still use the URL.
     1464            if (strlen($stext)<=4){
     1465                return $url;
     1466            }
     1467
     1468            // Yey! We can return the shrunk text AND the URL, no problem.
     1469            if (strlen($stext.' '.$url)<=$max) {
     1470                return $stext.' '. $url;
     1471            }
     1472            return false;
     1473        } else {
     1474            return $text.'... '.$url;
    14591475        }
    14601476    }
Note: See TracChangeset for help on using the changeset viewer.