WordPress.org

Plugin Directory

Changeset 870849


Ignore:
Timestamp:
03/06/14 21:36:10 (17 months ago)
Author:
joedolson
Message:

Pre 2.8.4

Location:
wp-to-twitter/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • wp-to-twitter/trunk/readme.txt

    r855949 r870849  
    33Donate link: http://www.joedolson.com/donate.php 
    44Tags: twitter, microblogging, su.pr, bitly, yourls, redirect, shortener, post, links 
    5 Requires at least: 3.4.2 
     5Requires at least: 3.5.1 
    66Tested up to: 3.8.1 
    77License: GPLv2 or later 
     
    5757 
    5858== Changelog == 
     59 
     60= 2.8.4 = 
     61 
     62* Rewrite Twitter App setup instructions to match re-designed Application Management page at Twitter. 
     63* Change time query address to main Twitter domain to avoid http_query errors. 
     64* Re-vamped error message generation. 
     65* Added notification messages post-publication. 
     66* Added 'last Tweet' status notification in settings. 
     67* Added option to disable feed stylesheet if not in use. 
    5968 
    6069= 2.8.3 = 
     
    955964== Upgrade Notice == 
    956965 
    957 * 2.8.0 - Removed support for WP 3.4.2 
     966* 2.8.4 - Rewritten application setup instructions due to Twitter UI changes. Bug fixes. 
  • wp-to-twitter/trunk/styles.css

    r831968 r870849  
    3737 
    3838.donations * { vertical-align: middle; display: inline-block; } 
     39 
     40.jcd-wide { width: 75%; } 
     41.jcd-narrow { width: 20%; } 
     42 
     43@media (max-width: 782px) { 
     44    .jcd-narrow { width: 100%; } 
     45    .jcd-wide { width: 100%; } 
     46} 
  • wp-to-twitter/trunk/wp-to-twitter-manager.php

    r842022 r870849  
    2626} 
    2727 
     28function wpt_set_log( $data, $id, $message ) { 
     29    if ( $id == 'test' ) { 
     30        $log = update_option( $data, $message ); 
     31    } else { 
     32        $log = update_post_meta( $id,'_'.$data, $message ); 
     33    } 
     34    $last = update_option( $data.'_last', array( $id, $message ) ); 
     35} 
     36 
     37function wpt_log( $data, $id ) { 
     38    if ( $id == 'test' ) { 
     39        $log = get_option( $data ); 
     40    } else if ( $id == 'last' ) { 
     41        $log = get_option( $data.'_last' ); 
     42    } else { 
     43        $log = get_post_meta( $id, '_'.$data, true ); 
     44    } 
     45    return $log; 
     46} 
     47 
    2848function jd_check_functions() { 
    2949    $message = "<div class='update'><ul>"; 
     
    3353    $title = urlencode( 'Your blog home' ); 
    3454    $shrink = apply_filters( 'wptt_shorten_link', $testurl, $title, false, true ); 
    35     if ($shrink == FALSE) { 
    36         if ($shortener == 1) { 
    37             $error = htmlentities( get_option('wp_supr_error') ); 
    38         } else if ( $shortener == 2 ) { 
    39             $error = htmlentities( get_option('wp_bitly_error') ); 
     55    if ( $shrink == false ) { 
     56        $error = htmlentities( get_option('wpt_shortener_status') ); 
     57        $message .= __("<li class=\"error\"><strong>WP to Twitter was unable to contact your selected URL shortening service.</strong></li>",'wp-to-twitter'); 
     58        if ( $error != '' ) { 
     59            $message .= "<li><code>$error</code></li>"; 
    4060        } else { 
    41             $error = __('No error information is available for your shortener.','wp-to-twitter'); 
    42         }    
    43         $message .= __("<li class=\"error\"><strong>WP to Twitter was unable to contact your selected URL shortening service.</strong></li>",'wp-to-twitter'); 
    44         $message .= "<li><code>$error</code></li>"; 
     61            $message .= "<li><code>".__('No error message was returned.','wp-to-twitter' )."</code></li>"; 
     62        } 
    4563    } else { 
    4664        $message .= __("<li><strong>WP to Twitter successfully contacted your selected URL shortening service.</strong>  The following link should point to your blog homepage:",'wp-to-twitter'); 
     
    4967    //check twitter credentials 
    5068    if ( wtt_oauth_test() ) { 
    51         $rand = rand(1000000,9999999); 
     69        $rand = rand( 1000000,9999999 ); 
    5270        $testpost = jd_doTwitterAPIPost( "This is a test of WP to Twitter. $shrink ($rand)" ); 
    53             if ($testpost) { 
     71            if ( $testpost ) { 
    5472                $message .= __("<li><strong>WP to Twitter successfully submitted a status update to Twitter.</strong></li>",'wp-to-twitter');  
    5573            } else { 
    56                 $error = get_option('jd_status_message'); 
     74                $error = wpt_log( 'wpt_status_message', 'test' ); 
    5775                $message .= __("<li class=\"error\"><strong>WP to Twitter failed to submit an update to Twitter.</strong></li>",'wp-to-twitter');  
    5876                $message .= "<li class=\"error\">$error</li>"; 
     
    82100    } 
    83101 
    84     if ( isset($_POST['submit-type']) && $_POST['submit-type'] == 'clear-error' ) { 
    85         update_option( 'wp_twitter_failure','0' ); 
    86         update_option( 'wp_url_failure','0' ); 
    87         update_option( 'jd_status_message',''); 
    88         $message =  __("WP to Twitter Errors Cleared", 'wp-to-twitter'); 
    89     } 
    90      
    91102    if ( isset($_POST['oauth_settings'] ) ) { 
    92103        $oauth_message = jd_update_oauth_settings( false, $_POST ); 
     
    94105 
    95106    $wp_twitter_error = FALSE; 
    96     $wp_supr_error = FALSE; 
    97     $wp_bitly_error = FALSE; 
     107    $wp_shortener_error = FALSE; 
    98108    $message = ""; 
    99109 
     
    164174 
    165175// notifications from oauth connection       
    166     if ( isset($_POST['oauth_settings'] ) ) { 
     176    if ( isset( $_POST['oauth_settings'] ) ) { 
    167177        if ( $oauth_message == "success" ) { 
    168178            print(' 
     
    170180                    <p>'.__('WP to Twitter is now connected with Twitter.', 'wp-to-twitter').'</p> 
    171181                </div> 
    172  
    173182            '); 
    174183        } else if ( $oauth_message == "failed" ) { 
     
    178187                    <p>'.__('Error:','wp-to-twitter').' '.get_option('wpt_error').'</p> 
    179188                </div> 
    180  
    181189            '); 
    182190        } else if ( $oauth_message == "cleared" ) { 
     
    185193                    <p>'.__('OAuth Authentication Data Cleared.', 'wp-to-twitter').'</p> 
    186194                </div> 
    187  
    188195            ');      
    189196        } else  if ( $oauth_message == 'nosync' ) { 
     
    192199                    <p>'.__('OAuth Authentication Failed. Your server time is not in sync with the Twitter servers. Talk to your hosting service to see what can be done.', 'wp-to-twitter').'</p> 
    193200                </div> 
    194  
    195201            '); 
    196202        } else { 
     
    364370        } 
    365371        update_option( 'wpt_can_tweet',$wpt_can_tweet);  
    366         update_option( 'disable_url_failure' , ( isset( $_POST['disable_url_failure'] ) )?$_POST['disable_url_failure']:0 ); 
    367         update_option( 'disable_twitter_failure' , ( isset( $_POST['disable_twitter_failure'] ) )?$_POST['disable_twitter_failure']:0 ); 
    368         update_option( 'disable_oauth_notice' , ( isset( $_POST['disable_oauth_notice'] ) )?$_POST['disable_oauth_notice']:0 ); 
    369         update_option( 'wp_debug_oauth' , ( isset( $_POST['wp_debug_oauth'] ) )?$_POST['wp_debug_oauth']:0 ); 
    370         update_option( 'jd_donations' , ( isset( $_POST['jd_donations'] ) )?$_POST['jd_donations']:0 ); 
     372        update_option( 'wpt_permit_feed_styles', ( isset( $_POST['wpt_permit_feed_styles'] ) ) ? 1 : 0 );        
     373        update_option( 'wp_debug_oauth' , ( isset( $_POST['wp_debug_oauth'] ) )? 1 : 0 ); 
     374        update_option( 'jd_donations' , ( isset( $_POST['jd_donations'] ) )? 1 : 0 ); 
    371375        $wpt_truncation_order = $_POST['wpt_truncation_order']; 
    372376        update_option( 'wpt_truncation_order', $wpt_truncation_order ); 
     
    406410<?php wpt_commments_removed(); ?> 
    407411<?php if ( $message ) { ?> 
    408 <div id="message" class="updated fade"><?php echo $message; ?></div> 
    409 <?php } ?> 
    410 <?php if ( get_option( 'wp_twitter_failure' ) != '0' || get_option( 'wp_url_failure' ) == '1' ) { ?> 
     412<div id="message" class="updated fade"><p><?php echo $message; ?></p></div> 
     413<?php } 
     414    $log = wpt_log( 'wpt_status_message', 'last' ); 
     415    if ( !empty( $log ) && is_array( $log ) ) { 
     416        $post_ID = $log[0]; 
     417        $post = get_post( $post_ID ); 
     418        $title = $post->post_title; 
     419        $notice = $log[1]; 
     420        echo "<div class='updated fade'><p><strong>".__('Last Tweet','wp-to-twitter')."</strong>: <a href='".get_edit_post_link( $post_ID )."'>$title</a> &raquo; $notice</p></div>"; 
     421    } 
     422    if ( get_option( 'wp_twitter_failure' ) != '0' || get_option( 'wp_url_failure' ) == '1' ) { ?> 
    411423        <div class="error"> 
    412424        <?php if ( get_option( 'wp_twitter_failure' ) == '1' ) { 
    413425            _e("<p>One or more of your last posts has failed to send a status update to Twitter. The Tweet has been saved, and you can re-Tweet it at your leisure.</p>", 'wp-to-twitter'); 
    414426        } 
    415         if ( get_option( 'jd_status_message' ) != '' ) { 
    416             echo "<p><strong>".get_option( 'jd_status_message' )."</strong></p>"; 
    417         } 
    418427        if ( get_option( 'wp_twitter_failure' ) == '2') { 
    419             echo "<p>".__("Sorry! I couldn't get in touch with the Twitter servers to post your <strong>new link</strong>! You'll have to post it manually, I'm afraid. ", 'wp-to-twitter')."</p>"; 
     428            echo "<p>".__("Sorry! I couldn't get in touch with the Twitter servers to post your <strong>new link</strong>! You'll have to post it manually.", 'wp-to-twitter')."</p>"; 
    420429        }        
    421430        if ( get_option( 'wp_url_failure' ) == '1' ) { 
    422         _e("<p>The query to the URL shortener API failed, and your URL was not shrunk. The full post URL was attached to your Tweet. Check with your URL shortening provider to see if there are any known issues.</p>", 'wp-to-twitter'); 
    423         } ?> 
    424         <?php $admin_url = ( is_plugin_active('wp-tweets-pro/wpt-pro-functions.php') )?admin_url('admin.php?page=wp-tweets-pro'):admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php'); ?> 
     431            _e("<p>The query to the URL shortener API failed, and your URL was not shrunk. The full post URL was attached to your Tweet. Check with your URL shortening provider to see if there are any known issues.</p>", 'wp-to-twitter'); 
     432        }  
     433        $admin_url = ( is_plugin_active('wp-tweets-pro/wpt-pro-functions.php') )?admin_url('admin.php?page=wp-tweets-pro'):admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php'); ?> 
    425434        <form method="post" action="<?php echo $admin_url; ?>"> 
    426435        <div><input type="hidden" name="submit-type" value="clear-error" /></div> 
     
    433442?>   
    434443<h2><?php _e("WP to Twitter Options", 'wp-to-twitter'); ?></h2> 
    435 <div id="wpt_settings_page" class="postbox-container" style="width: 70%"> 
     444<div id="wpt_settings_page" class="postbox-container jcd-wide"> 
    436445 
    437446<?php  
     
    710719        <legend><?php _e('Error Messages and Debugging','wp-to-twitter'); ?></legend> 
    711720            <ul> 
    712             <li><input type="checkbox" name="disable_url_failure" id="disable_url_failure" value="1" <?php echo jd_checkCheckbox('disable_url_failure')?> />    <label for="disable_url_failure"><?php _e("Disable global URL shortener error messages.", 'wp-to-twitter'); ?></label></li> 
    713             <li><input type="checkbox" name="disable_twitter_failure" id="disable_twitter_failure" value="1" <?php echo jd_checkCheckbox('disable_twitter_failure')?> />    <label for="disable_twitter_failure"><?php _e("Disable global Twitter API error messages.", 'wp-to-twitter'); ?></label></li> 
    714             <li><input type="checkbox" name="wp_debug_oauth" id="wp_debug_oauth" value="1" <?php echo jd_checkCheckbox('wp_debug_oauth')?> /> 
    715                 <label for="wp_debug_oauth"><?php _e("Get Debugging Data for OAuth Connection", 'wp-to-twitter'); ?></label></li> 
    716             <li><input type="checkbox" name="jd_donations" id="jd_donations" value="1" <?php echo jd_checkCheckbox('jd_donations')?> /> 
    717                 <label for="jd_donations"><strong><?php _e("I made a donation, so stop whinging at me, please.", 'wp-to-twitter'); ?></strong></label></li> 
     721            <li><input type="checkbox" name="wpt_permit_feed_styles" id="wpt_permit_feed_styles" value="1" <?php echo jd_checkCheckbox('wpt_permit_feed_styles')?> /> <label for="wpt_permit_feed_styles"><?php _e("Disable Twitter Feed Stylesheet", 'wp-to-twitter'); ?></label></li> 
     722            <li><input type="checkbox" name="wp_debug_oauth" id="wp_debug_oauth" value="1" <?php echo jd_checkCheckbox('wp_debug_oauth')?> /> <label for="wp_debug_oauth"><?php _e("Get Debugging Data for OAuth Connection", 'wp-to-twitter'); ?></label></li> 
     723            <li><input type="checkbox" name="jd_donations" id="jd_donations" value="1" <?php echo jd_checkCheckbox('jd_donations')?> /> <label for="jd_donations"><strong><?php _e("I made a donation, so stop whinging at me, please.", 'wp-to-twitter'); ?></strong></label></li> 
    718724            </ul> 
    719725        </fieldset> 
     
    754760function wpt_sidebar() { 
    755761?> 
    756 <div class="postbox-container" style="width:20%"> 
     762<div class="postbox-container jcd-narrow"> 
    757763<div class="metabox-holder"> 
    758764    <div class="ui-sortable meta-box-sortables"> 
     
    766772            <div class="inside resources"> 
    767773            <p> 
    768             <a href="https://twitter.com/intent/tweet?screen_name=joedolson&text=WP%20to%20Twitter%20is%20great!" class="twitter-mention-button" data-size="large" data-related="joedolson">Tweet about WP to Twitter</a> 
     774            <a href="https://twitter.com/intent/follow?screen_name=joedolson" class="twitter-follow-button" data-size="small" data-related="joedolson">Follow @joedolson</a> 
    769775            <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 
    770776            </p> 
  • wp-to-twitter/trunk/wp-to-twitter-oauth.php

    r855945 r870849  
    169169} 
    170170$server_time = date( DATE_COOKIE ); 
    171 $response = wp_remote_get( "https://api.twitter.com/1.1/", array( 'timeout'=>1, 'redirection'=>1 ) ); 
     171$response = wp_remote_get( "https://twitter.com/", array( 'timeout'=>1, 'redirection'=>1 ) ); 
    172172if ( is_wp_error( $response ) ) { 
    173173    $warning = ''; 
     
    218218            <p>'.__('Your server timezone (should be UTC,GMT,Europe/London or equivalent):','wp-to-twitter').' '.date_default_timezone_get().'</p> 
    219219            </div> 
    220             '.$form.' 
    221                 <fieldset class="options"> 
    222220                    <h4>'.__('1. Register this site as an application on ', 'wp-to-twitter') . '<a href="http://dev.twitter.com/apps/new" target="_blank">'.__('Twitter\'s application registration page','wp-to-twitter').'</a></h4> 
    223221                        <ul> 
     
    228226                        </ul> 
    229227                    <p><em>'.__('Agree to the Developer Rules of the Road and continue.','wp-to-twitter').'</em></p> 
    230                     <h4>'.__('2. Switch to the "Settings" tab in Twitter apps','wp-to-twitter').'. '.__('<em>Do NOT create your access token yet.</em>','wp-to-twitter').'</h4> 
     228                    <h4>'.__( '2. Switch to the "Permissions" tab in Twitter apps', 'wp-to-twitter' ).'</h4> 
    231229                        <ul> 
    232230                        <li>'.__('Select "Read and Write" for the Application Type' , 'wp-to-twitter').'</li> 
    233231                        <li>'.__('Update the application settings' , 'wp-to-twitter').'</li> 
    234                         <li>'.__('Return to the Details tab and create your access token.','wp-to-twitter').'</li>       
    235                         </ul>    
    236                     <p><em>'.__('Once you have registered your site as an application, you will be provided with four keys.' , 'wp-to-twitter').'</em></p> 
    237                     <h4>'.__('3. Copy and paste your consumer key and consumer secret into the fields below' , 'wp-to-twitter').'</h4> 
     232                        </ul> 
     233                    <h4>'.__('3. Switch to the API Keys tab and regenerate your API keys, then create your access token.','wp-to-twitter' ).'</h4> 
     234                        <ul> 
     235                        <li>'.__('Copy your API key and API secret from the top section.' , 'wp-to-twitter').'</li> 
     236                        <li>'.__('Copy your Access token and Access token secret from the bottom section.' , 'wp-to-twitter').'</li> 
     237                        </ul> 
     238            '.$form.' 
     239                <fieldset class="options">                       
    238240                    <div class="tokens"> 
    239241                    <p> 
    240                         <label for="wtt_app_consumer_key">'.__('Twitter Consumer Key', 'wp-to-twitter').'</label> 
     242                        <label for="wtt_app_consumer_key">'.__('API Key', 'wp-to-twitter').'</label> 
    241243                        <input type="text" size="45" name="wtt_app_consumer_key" id="wtt_app_consumer_key" value="'.$ack.'" /> 
    242244                    </p> 
    243245                    <p> 
    244                         <label for="wtt_app_consumer_secret">'.__('Twitter Consumer Secret', 'wp-to-twitter').'</label> 
     246                        <label for="wtt_app_consumer_secret">'.__('API Secret', 'wp-to-twitter').'</label> 
    245247                        <input type="text" size="45" name="wtt_app_consumer_secret" id="wtt_app_consumer_secret" value="'.$acs.'" /> 
    246248                    </p> 
  • wp-to-twitter/trunk/wp-to-twitter-shorteners.php

    r855069 r870849  
    5959            $keyword_format = ( get_option( 'jd_keyword_format' ) == '1' )?$post_ID:false; 
    6060            $keyword_format = ( get_option( 'jd_keyword_format' ) == '2' )?get_post_meta( $post_ID,'_yourls_keyword',true ):$keyword_format; 
     61            $error = ''; 
    6162            // Generate and grab the short url 
    6263            switch ( get_option( 'jd_shortener' ) ) { 
     
    6970                    if ( function_exists('wp_get_shortlink') ) { 
    7071                        // wp_get_shortlink doesn't natively support custom post types; but don't return an error in that case. 
    71                         $shrink = ( $post_ID != false )?wp_get_shortlink( $post_ID, 'post' ):$url; 
     72                        $shrink = ( $post_ID != false ) ? wp_get_shortlink( $post_ID, 'post' ) : $url; 
    7273                    } 
    7374                    if ( !$shrink ) { $shrink = $url; } 
     
    7778                    $bitlylogin = trim ( strtolower( get_option( 'bitlylogin' ) ) );                 
    7879                    $decoded = jd_remote_json( "https://api-ssl.bitly.com/v3/shorten?longUrl=".$encoded."&login=".$bitlylogin."&apiKey=".$bitlyapi."&format=json" ); 
    79                     $error = ''; 
    8080                    if ($decoded) { 
    8181                        if ($decoded['status_code'] != 200) { 
     
    8686                        } 
    8787                    } else { 
    88                     $shrink = false; 
    89                     update_option( 'wp_bitly_error',"JSON result could not be decoded"); 
     88                        $shrink = false; 
    9089                    }    
    91                     if ( !is_valid_url($shrink) ) { $shrink = false; update_option( 'wp_bitly_error',$error ); } 
     90                    if ( !is_valid_url($shrink) ) { $shrink = false; } 
    9291                    break; 
    9392                case 5: 
     
    140139                        $decoded = jd_remote_json( "http://su.pr/api/shorten?longUrl=".$encoded ); 
    141140                    } 
    142                     update_option( 'wp_supr_error',"Su.pr API result: $decoded" ); 
    143141                    if ($decoded['statusCode'] == 'OK') { 
    144142                        $page = str_replace("&","&#38;", urldecode($url)); 
     
    148146                        $shrink = false; 
    149147                        $error = $decoded['errorMessage']; 
    150                         update_option( 'wp_supr_error',"JSON result could not be decoded"); 
    151148                    }    
    152                     if ( !is_valid_url($shrink) ) { $shrink = false; update_option( 'wp_supr_error',$error ); } 
     149                    if ( !is_valid_url($shrink) ) { $shrink = false; } 
    153150                    break; 
    154151                case 8: 
     
    186183                    //\jotURL 
    187184                    $decoded = jd_fetch_url("https://api.joturl.com/a/v1/shorten?url=" . $encoded . "&login=" . $joturllogin . "&key=" . $joturlapi . "&format=plain"); 
    188                     $error = ''; 
    189185                    if ($decoded !== false) { 
    190186                       $shrink = $decoded; 
     
    203199                       $error = $decoded; 
    204200                       $shrink = false; 
    205                        update_option('wp_joturl_error', "JSON result could not be decoded"); 
    206201                    } 
    207202                    if (!is_valid_url($shrink)) { 
    208203                       $shrink = false; 
    209                        update_option('wp_joturl_error', $error); 
    210                     } 
    211                 break;                   
     204                    } 
     205                break; 
     206                update_option( 'wpt_shortener_status', "$shrink : $error" ); 
    212207            } 
    213208            if ( !$testmode ) { 
  • wp-to-twitter/trunk/wp-to-twitter.php

    r855945 r870849  
    44Plugin URI: http://www.joedolson.com/articles/wp-to-twitter/ 
    55Description: Posts a Tweet when you update your WordPress blog or post to your blogroll, using your URL shortening service. Rich in features for customizing and promoting your Tweets. 
    6 Version: 2.8.3 
     6Version: 2.8.4 
    77Author: Joseph Dolson 
    88Author URI: http://www.joedolson.com/ 
     
    4848require_once( plugin_dir_path(__FILE__).'/wpt-widget.php' ); 
    4949 
    50 global $wpt_version,$jd_plugin_url; 
    51 $wpt_version = "2.8.3"; 
     50global $wpt_version; 
     51$wpt_version = "2.8.4"; 
    5252$plugin_dir = basename(dirname(__FILE__)); 
    5353load_plugin_textdomain( 'wp-to-twitter', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); 
     
    7272} 
    7373 
    74 $jd_plugin_url = "http://www.joedolson.com/articles/wp-to-twitter/"; 
    75 $jd_donate_url = "http://www.joedolson.com/articles/wp-tweets-pro/"; 
     74$wpt_donate_url = "http://www.joedolson.com/articles/wp-tweets-pro/"; 
    7675 
    7776function wpt_commments_removed() { 
     
    252251// This function performs the API post to Twitter 
    253252function jd_doTwitterAPIPost( $twit, $auth=false, $id=false, $media=false ) { 
    254     if ( !wpt_check_oauth( $auth ) ) {  
    255         wpt_saves_error( $id, $auth, $twit, __('This account is not authorized to post to Twitter.','wp-tweets-pro'), '401', time() ); 
    256         return true;  
     253    if ( !wpt_check_oauth( $auth ) ) { 
     254        $error = __('This account is not authorized to post to Twitter.','wp-to-twitter' ); 
     255        wpt_saves_error( $id, $auth, $twit, $error, '401', time() ); 
     256        wpt_set_log( 'wpt_status_message', $id, $error ); 
     257        return true; 
    257258    } // exit silently if not authorized 
    258259    $check = ( !$auth )?get_option('jd_last_tweet'):get_user_meta( $auth, 'wpt_last_tweet', true ); // get user's last tweet 
     
    262263            wpt_mail( "Matched: tweet identical: #$id","$twit, $auth, $id" ); // DEBUG 
    263264        } 
    264         wpt_saves_error( $id, $auth, $twit, __('This tweet is identical to another Tweet recently sent to this account.','wp-tweets-pro'), '403', time() ); 
     265        $error = __( 'This tweet is identical to another Tweet recently sent to this account.','wp-to-twitter' ).' '.__( 'Twitter requires all Tweets to be unique.', 'wp-to-twitter' ); 
     266        wpt_saves_error( $id, $auth, $twit, $error, '403', time() ); 
     267        wpt_set_log( 'wpt_status_message', $id, $error ); 
    265268        return true; 
    266269    } else if ( $twit == '' || !$twit ) { 
     
    268271            wpt_mail( "Tweet check: empty sentence: #$id","$twit, $auth, $id"); // DEBUG 
    269272        } 
    270         wpt_saves_error( $id, $auth, $twit, __('This tweet was blank and could not be sent to Twitter.','wp-tweets-pro'), '403', time() ); 
     273        $error = __('This tweet was blank and could not be sent to Twitter.','wp-tweets-pro'); 
     274        wpt_saves_error( $id, $auth, $twit, $error, '403', time() ); 
     275        wpt_set_log( 'wpt_status_message', $id, $error ); 
    271276        return true;     
    272277    } else { 
     
    322327                    break; 
    323328                case '403': 
    324                     $error = __("403 Forbidden: The request is understood, but has been refused by Twitter. Possible reasons: too many Tweets, same Tweet submitted twice, Tweet longer than 140 characters. Not an error from WP to Twitter.",'wp-to-twitter'); 
     329                    $error = __("403 Forbidden: The request is understood, but has been refused by Twitter. Possible reasons: too many Tweets, same Tweet submitted twice, Tweet longer than 140 characters.",'wp-to-twitter'); 
    325330                    break; 
    326331                case '404': 
     
    376381            } 
    377382            if ( !$return ) { 
    378                 update_option( 'jd_status_message',$error ); 
     383                wpt_set_log( 'wpt_status_message', $id, $error ); 
    379384            } else { 
    380                 delete_option( 'jd_status_message' ); 
     385                wpt_set_log( 'wpt_status_message', $id, __( 'Tweet sent successfully.','wp-to-twitter' ) );  
    381386            } 
    382387            return $return;          
    383388        } else { 
     389            wpt_set_log( 'wpt_status_message', $id, __( 'No Twitter OAuth connection found.','wp-to-twitter' ) ); 
    384390            return false; 
    385             update_option( 'jd_status_message',__('No Twitter OAuth connection found.','wp-to-twitter') ); 
    386391        } 
    387392    } 
     
    645650 
    646651function wpt_short_url( $post_id ) { 
     652    global $post_ID; 
     653    if ( !$post_id ) { $post_id = $post_ID; } 
    647654    $jd_short = get_post_meta( $post_id, '_wp_jd_bitly', true ); 
    648655    if ( $jd_short == "" ) {$jd_short = get_post_meta( $post_id, '_wp_jd_goo', true );} 
     
    827834                        foreach ( $wpt_selected_users as $acct ) { 
    828835                            if ( $auth != $acct ) { 
    829                                 $offset = rand(60,480); // offset by 1-8 minutes for additional users 
     836                                $offset = rand( 60,480 ); // offset by 1-8 minutes for additional users 
    830837                            } else { 
    831838                                $offset = 0; 
     
    833840                            if ( wtt_oauth_test( $acct,'verify' ) ) { 
    834841                                $time = apply_filters( 'wpt_schedule_delay',( (int) $post_info['wpt_delay_tweet'] )*60, $acct ); 
    835                                 wp_schedule_single_event( time()+$time+$offset, 'wpt_schedule_tweet_action', array( 'id'=>$acct, 'sentence'=>$sentence, 'rt'=>0, 'post_id'=>$post_ID ) ); 
     842                                $scheduled = wp_schedule_single_event( time()+$time+$offset, 'wpt_schedule_tweet_action', array( 'id'=>$acct, 'sentence'=>$sentence, 'rt'=>0, 'post_id'=>$post_ID ) ); 
    836843                                $tweet = true; // if scheduled, return true. 
    837844                                if ( WPT_DEBUG && function_exists( 'wpt_pro_exists' ) ) { 
    838845                                    if ( $acct ) { $author_id = "#$acct"; } else { $author_id = 'Main'; } 
    839                                     wpt_mail(  "7: Tweet Scheduled for Auth ID $author_id #$post_ID",print_r( array( 'id'=>$acct, 'sentence'=>$sentence, 'rt'=>0, 'post_id'=>$post_ID, 'timestamp'=>time()+$time+$offset, 'current_time'=>time(), 'timezone'=>get_option('gmt_offset') ),1)." / $type"); // DEBUG 
     846                                    wpt_mail(  "7a: Tweet Scheduled for Auth ID $author_id #$post_ID", print_r( array( 'id'=>$acct, 'sentence'=>$sentence, 'rt'=>0, 'post_id'=>$post_ID, 'timestamp'=>time()+$time+$offset, 'current_time'=>time(), 'timezone'=>get_option('gmt_offset'), 'scheduled'=>$scheduled, 'timestamp_string'=>date( 'Y-m-d H:i:s',time()+$time+$offset ),'current_time_string'=>date( 'Y-m-d H:i:s',time() ), ),1 ) ); // DEBUG 
    840847                                } 
    841848                            } 
     
    874881                                    $time = apply_filters( 'wpt_schedule_retweet',($post_info['wpt_retweet_after'])*(60*60)*$i, $acct, $i, $post_info ); 
    875882                                    wp_schedule_single_event( time()+$time+$offset+$delay, 'wpt_schedule_tweet_action', array( 'id'=>$acct, 'sentence'=>$retweet, 'rt'=>$i, 'post_id'=>$post_ID ) ); 
    876                                     $tweet = true; 
     883                                    $tweet = true;                               
    877884                                    if ( $i == 4 ) { break; } 
    878885                                } 
     
    9931000 
    9941001function jd_add_twitter_inner_box( $post ) { 
    995     if ( current_user_can('wpt_can_tweet') ) { 
    996     $is_pro = ( function_exists( 'wpt_pro_exists' ) )?'pro':'free'; 
    997     echo "<div class='wp-to-twitter $is_pro'>"; 
    998     global $jd_plugin_url, $jd_donate_url; 
     1002    if ( current_user_can( 'wpt_can_tweet' ) ) { 
     1003        $is_pro = ( function_exists( 'wpt_pro_exists' ) ) ? 'pro' : 'free'; 
     1004        echo "<div class='wp-to-twitter $is_pro'>"; 
     1005        global $wpt_donate_url; 
    9991006        $tweet_status = ''; 
    10001007        $options = get_option('wpt_post_types'); 
     
    10041011            $post_id = $post->ID; 
    10051012        } 
     1013        $log = wpt_log( 'wpt_status_message', $post_id ); 
     1014        $class = ( $log != 'Tweet sent successfully.' ) ? 'error' : 'updated' ; 
     1015        if ( $log != '' ) { 
     1016            echo "<div class='$class'><p>".wpt_log( 'wpt_status_message', $post_id )."</p></div>"; 
     1017        } 
    10061018        $previous_tweets = get_post_meta ( $post_id, '_jd_wp_twitter', true ); 
    10071019        $failed_tweets = get_post_meta( $post_id, '_wpt_failed' ); 
    1008         $tweet = esc_attr( stripcslashes( get_post_meta($post_id, '_jd_twitter', true ) ) ); 
     1020        $tweet = esc_attr( stripcslashes( get_post_meta( $post_id, '_jd_twitter', true ) ) ); 
    10091021        $tweet = apply_filters( 'wpt_user_text', $tweet, $status ); 
    10101022        $jd_template = ( $status == 'publish' )?$options[$type]['post-edited-text']:$options[$type]['post-published-text']; 
     
    10221034            wpt_pro_compatibility();  
    10231035        } 
    1024         if ( $tweet_status != '' ) { ?> 
    1025             <p class='disabled'><?php echo $tweet_status; ?></p> 
    1026         <?php }  
     1036        if ( $tweet_status != '' ) { echo "<p class='disabled'>$tweet_status</p>"; }  
    10271037        if ( current_user_can( 'wpt_twitter_custom' ) || current_user_can('update_core') ) { ?> 
    10281038            <p class='jtw'> 
     
    11261136        <p class="wpt-support"> 
    11271137        <?php if ( !function_exists( 'wpt_pro_exists' ) ) { ?> 
    1128             <a target="_blank" href="<?php echo admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php'); ?>#get-support"><?php _e('Get Support', 'wp-to-twitter', 'wp-to-twitter') ?></a> &bull; <strong><a target="__blank" href="<?php echo $jd_donate_url; ?>"><?php _e('Upgrade to WP Tweets Pro', 'wp-to-twitter', 'wp-to-twitter') ?></a></strong> &raquo; 
     1138            <a target="_blank" href="<?php echo admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php'); ?>#get-support"><?php _e('Get Support', 'wp-to-twitter', 'wp-to-twitter') ?></a> &bull; <strong><a target="__blank" href="<?php echo $wpt_donate_url; ?>"><?php _e('Upgrade to WP Tweets Pro', 'wp-to-twitter', 'wp-to-twitter') ?></a></strong> &raquo; 
    11291139        <?php } else { ?> 
    11301140            <a target="_blank" href="<?php echo admin_url('admin.php?page=wp-tweets-pro'); ?>#get-support"><?php _e('Get Support', 'wp-to-twitter', 'wp-to-twitter') ?></a> &raquo; 
     
    13681378    if ( $file == plugin_basename(dirname(__FILE__).'/wp-to-twitter.php') ) { 
    13691379        $admin_url = ( is_plugin_active('wp-tweets-pro/wpt-pro-functions.php') )?admin_url('admin.php?page=wp-tweets-pro'):admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php'); 
    1370         global $jd_donate_url; 
     1380        global $wpt_donate_url; 
    13711381        $links[] = "<a href='$admin_url'>" . __('Settings', 'wp-to-twitter', 'wp-to-twitter') . "</a>"; 
    1372         if ( ! function_exists( 'wpt_pro_exists' ) ) { $links[] = "<a href='$jd_donate_url'>" . __('Upgrade', 'wp-to-twitter', 'wp-to-twitter') . "</a>"; }  
     1382        if ( ! function_exists( 'wpt_pro_exists' ) ) { $links[] = "<a href='$wpt_donate_url'>" . __('Upgrade', 'wp-to-twitter', 'wp-to-twitter') . "</a>"; }     
    13731383    } 
    13741384    return $links; 
     
    13841394 
    13851395$admin_url = ( is_plugin_active('wp-tweets-pro/wpt-pro-functions.php') )?admin_url('admin.php?page=wp-tweets-pro'):admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php'); 
    1386  
    1387 if ( get_option( 'disable_url_failure' ) != '1' ) { 
    1388     if ( get_option( 'wp_url_failure' ) == '1' && !( isset($_POST['submit-type']) && $_POST['submit-type'] == 'clear-error' ) ) { 
    1389         add_action('admin_notices', create_function( '', "if ( ! current_user_can( 'manage_options' ) ) { return; } echo '<div class=\"error\"><p>';_e('There\'s been an error shortening your URL! <a href=\"".$admin_url."\">Visit your WP to Twitter settings page</a> to get more information and to clear this error message.','wp-to-twitter'); echo '</p></div>';" ) ); 
    1390     } 
    1391 } 
    1392 if ( get_option( 'disable_twitter_failure' ) != '1' ) { 
    1393     if ( get_option( 'wp_twitter_failure' ) == '1' && !( isset($_POST['submit-type']) && $_POST['submit-type'] == 'clear-error' ) ) { 
    1394         add_action('admin_notices', create_function( '', "if ( ! current_user_can( 'manage_options' ) ) { return; } echo '<div class=\"error\"><p>';_e('There\'s been an error posting your Twitter status! <a href=\"".$admin_url."\">Visit your WP to Twitter settings page</a> to get more information and to clear this error message.','wp-to-twitter'); echo '</p></div>';" ) ); 
    1395     } 
    1396 } 
    13971396 
    13981397add_action( 'in_plugin_update_message-wp-to-twitter/wp-to-twitter.php', 'wpt_plugin_update_message' ); 
     
    15051504    } 
    15061505} 
     1506 
     1507add_filter( 'wpt_enqueue_feed_styles', 'wpt_permit_feed_styles' ); 
     1508function wpt_permit_feed_styles( $value ) { 
     1509    if ( get_option( 'wpt_permit_feed_styles' ) == 1 ) { 
     1510        $value = false; 
     1511    } 
     1512    return $value; 
     1513} 
    15071514/* 
    15081515// Add notes about Tweet status to posts admin  
  • wp-to-twitter/trunk/wpt-functions.php

    r855945 r870849  
    11<?php  
    22// This file contains secondary functions supporting WP to Twitter 
    3 // These functions don't perform any WP to Twitter actions, but are sometimes called for when  
    4 // support for primary functions is lacking. 
     3// These functions don't perform any WP to Twitter actions, but add  
     4// support for primary functions if lacking. 
    55if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 
    66 
     
    1313function jd_remote_json( $url, $array=true ) { 
    1414    $input = jd_fetch_url( $url ); 
    15     $obj = json_decode($input, $array ); 
     15    $obj = json_decode( $input, $array ); 
    1616    try { 
    17         if (is_null($array)) { 
     17        if ( is_null( $obj ) ) { 
    1818            switch ( json_last_error() ) { 
    1919                case JSON_ERROR_DEPTH : 
     
    3838            throw new Exception($msg); 
    3939        } 
    40     } catch (Exception $e) { 
     40    } catch ( Exception $e ) { 
    4141        return $e -> getMessage(); 
    4242    }    
    4343    return $obj; 
    44     // TODO: some error handling ? 
    4544}            
    4645 
    4746function is_valid_url( $url ) { 
    48     if (is_string($url)) { 
    49         $url = urldecode($url); 
    50         return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);     
     47    if ( is_string( $url ) ) { 
     48        $url = urldecode( $url ); 
     49        return preg_match( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url ); 
    5150    } else { 
    5251        return false; 
     
    5655function jd_fetch_url( $url, $method='GET', $body='', $headers='', $return='body' ) { 
    5756    $request = new WP_Http; 
    58     $result = $request->request( $url , array( 'method'=>$method, 'body'=>$body, 'headers'=>$headers, 'sslverify'=>false, 'user-agent'=>'WP to Twitter http://www.joedolson.com/articles/wp-to-twitter/' ) ); 
     57    $result = $request->request( $url , array( 'method'=>$method, 'body'=>$body, 'headers'=>$headers, 'sslverify'=>false, 'user-agent'=>'WP to Twitter/http://www.joedolson.com/articles/wp-to-twitter/' ) ); 
    5958    // Success? 
    60     if ( !is_wp_error($result) && isset($result['body']) ) { 
     59    if ( !is_wp_error( $result ) && isset( $result['body'] ) ) { 
    6160        if ( $result['response']['code'] == 200 ) { 
    62             if ($return == 'body') { 
    63             return $result['body']; 
     61            if ( $return == 'body' ) { 
     62                return $result['body']; 
    6463            } else { 
    65             return $result; 
     64                return $result; 
    6665            } 
    6766        } else { 
  • wp-to-twitter/trunk/wpt_twitter_oauth.php

    r809350 r870849  
    187187        // if install is at root, can query src path. Otherwise, need to take full image. 
    188188        $at_root = ( wp_make_link_relative( home_url() ) == home_url() || wp_make_link_relative( home_url() ) == '/' ) ? true : false ; 
    189         if ( $at_root ) {        
    190             $upload = wp_get_attachment_image_src( $attachment, apply_filters( 'wpt_upload_image_size', 'medium' ) ); 
     189        if ( $at_root ) {    
     190            $image_sizes = get_intermediate_image_sizes(); 
     191            if ( in_array( 'large', $image_sizes ) ) { 
     192                $size = 'large'; 
     193            } else { 
     194                $size = array_pop( $image_sizes ); 
     195            } 
     196            $upload = wp_get_attachment_image_src( $attachment, apply_filters( 'wpt_upload_image_size', $size ) );           
    191197            $path = get_home_path() . wp_make_link_relative( $upload[0] ); 
    192198            $image = str_replace( '//', '/', $path ); 
Note: See TracChangeset for help on using the changeset viewer.