WordPress.org

Plugin Directory

Changeset 611167


Ignore:
Timestamp:
10/11/12 22:11:11 (19 months ago)
Author:
joedolson
Message:

Version 2.4.12. Moved languages to subdirectory. Bug fixes.

Location:
wp-to-twitter/trunk
Files:
36 added
35 deleted
3 edited

Legend:

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

    r603870 r611167  
    6464== Changelog == 
    6565 
     66= 2.4.12 = 
     67 
     68* Bug fix: Issues with permissions disallowing some behaviors incorrectly. 
     69* Bug fix: Stripping of nonalphanumerics in hashtags is now UTF8 friendly. 
     70* Change: Tweaking of the  meaning of some permissions. 
     71* Add: permission to disallow a role from Tweeting at all. 
     72 
    6673= 2.4.11 = 
    6774 
  • wp-to-twitter/trunk/wp-to-twitter-manager.php

    r603870 r611167  
    129129        $administrator->add_cap('wpt_twitter_custom'); 
    130130        $administrator->add_cap('wpt_twitter_switch'); 
     131        $administrator->add_cap('wpt_can_tweet'); 
     132        $editor = get_role('editor'); 
     133        $editor->add_cap('wpt_can_tweet'); 
     134        $author = get_role('author'); 
     135        $author->add_cap('wpt_can_tweet'); 
     136        $contributor = get_role('contributor'); 
     137        $contributor->add_cap('wpt_can_tweet'); 
     138        update_option('wpt_can_tweet','contributor'); 
    131139        update_option('wtt_show_custom_tweet','administrator'); 
    132140 
     
    274282        update_option( 'wpt_twitter_switch',$wpt_twitter_switch); 
    275283         
     284        $wpt_can_tweet = $_POST['wpt_can_tweet']; 
     285        $prev = get_option('wpt_can_tweet'); 
     286        if ( $wpt_can_tweet != $prev ) { 
     287            $subscriber = get_role('subscriber'); $subscriber->remove_cap('wpt_can_tweet'); 
     288            $contributor = get_role('contributor'); $contributor->remove_cap('wpt_can_tweet'); 
     289            $author = get_role('author'); $author->remove_cap('wpt_can_tweet'); 
     290            $editor = get_role('editor'); $editor->remove_cap('wpt_can_tweet'); 
     291            switch ( $wpt_can_tweet ) { 
     292                case 'subscriber': $subscriber->add_cap('wpt_can_tweet'); $contributor->add_cap('wpt_can_tweet'); $author->add_cap('wpt_can_tweet'); $editor->add_cap('wpt_can_tweet');   break; 
     293                case 'contributor': $contributor->add_cap('wpt_can_tweet'); $author->add_cap('wpt_can_tweet'); $editor->add_cap('wpt_can_tweet');  break; 
     294                case 'author': $author->add_cap('wpt_can_tweet'); $editor->add_cap('wpt_can_tweet'); break; 
     295                case 'editor':$editor->add_cap('wpt_can_tweet'); break; 
     296                default:  
     297                    $role = get_role( $wpt_can_tweet );  
     298                    $role->add_cap('wpt_can_tweet'); 
     299                break; 
     300            } 
     301        } 
     302        update_option( 'wpt_can_tweet',$wpt_can_tweet);      
     303         
    276304        update_option( 'disable_url_failure' , ( isset( $_POST['disable_url_failure'] ) )?$_POST['disable_url_failure']:0 ); 
    277305        update_option( 'disable_twitter_failure' , ( isset( $_POST['disable_twitter_failure'] ) )?$_POST['disable_twitter_failure']:0 ); 
     
    750778        $permissions = ''; 
    751779        $switcher = ''; 
     780        $can_tweet = ''; 
    752781        foreach ( $roles as $role=>$rolename ) { 
    753782            $permissions .= ($role !='subscriber')?"<option value='$role'".wtt_option_selected(get_option('wtt_user_permissions'),$role,'option').">$rolename</option>\n":''; 
    754783            $options .= ($role !='subscriber')?"<option value='$role'".wtt_option_selected(get_option('wtt_show_custom_tweet'),$role,'option').">$rolename</option>\n":''; 
    755             $switcher .= ($role !='subscriber')?"<option value='$role'".wtt_option_selected(get_option('wpt_twitter_switch'),$role,'option').">$rolename</option>\n":'';             
     784            $switcher .= ($role !='subscriber')?"<option value='$role'".wtt_option_selected(get_option('wpt_twitter_switch'),$role,'option').">$rolename</option>\n":''; 
     785            $can_tweet .= ($role !='subscriber')?"<option value='$role'".wtt_option_selected(get_option('wpt_can_tweet'),$role,'option').">$rolename</option>\n":''; 
    756786        } 
    757787        ?> 
    758788            <p> 
    759             <label for="wtt_user_permissions"><?php _e('Choose the lowest user group that can add their Twitter information','wp-to-twitter'); ?></label> <select id="wtt_user_permissions" name="wtt_user_permissions"> 
     789            <label for="wtt_user_permissions"><?php _e('The lowest user group that can add their Twitter information','wp-to-twitter'); ?></label> <select id="wtt_user_permissions" name="wtt_user_permissions"> 
    760790                <?php echo $permissions; ?> 
    761791            </select>  
    762792            </p> 
    763793            <p> 
    764             <label for="wtt_show_custom_tweet"><?php _e('Choose the lowest user group that can see the Custom Tweet options when posting','wp-to-twitter'); ?></label> <select id="wtt_show_custom_tweet" name="wtt_show_custom_tweet"> 
     794            <label for="wtt_show_custom_tweet"><?php _e('The lowest user group that can see the Custom Tweet options when posting','wp-to-twitter'); ?></label> <select id="wtt_show_custom_tweet" name="wtt_show_custom_tweet"> 
    765795                <?php echo $options; ?> 
    766796            </select>  
    767797            </p> 
    768798            <p> 
    769             <label for="wpt_twitter_switch"><?php _e('User groups above this can toggle the Tweet/Don\'t Tweet option, but not see other custom tweet options.','wp-to-twitter'); ?></label> <select id="wpt_twitter_switch" name="wpt_twitter_switch"> 
     799            <label for="wpt_twitter_switch"><?php _e('The lowest user group that can toggle the Tweet/Don\'t Tweet option','wp-to-twitter'); ?></label> <select id="wpt_twitter_switch" name="wpt_twitter_switch"> 
    770800                <?php echo $switcher; ?> 
    771801            </select>  
    772802            </p> 
     803            <p> 
     804            <label for="wpt_can_tweet"><?php _e('The lowest user group that can send Twitter updates','wp-to-twitter'); ?></label> <select id="wpt_can_tweet" name="wpt_can_tweet"> 
     805                <?php echo $can_tweet; ?> 
     806            </select>  
     807            </p>             
    773808        </fieldset> 
    774809        <fieldset> 
  • wp-to-twitter/trunk/wp-to-twitter.php

    r603872 r611167  
    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 chosen URL shortening service. Rich in features for customizing and promoting your Tweets. 
    6 Version: 2.4.11 
     6Version: 2.4.12 
    77Author: Joseph Dolson 
    88Author URI: http://www.joedolson.com/ 
     
    5858 
    5959global $wpt_version,$jd_plugin_url,$jdwp_api_post_status; 
    60 $wpt_version = "2.4.11"; 
     60$wpt_version = "2.4.12"; 
    6161$plugin_dir = basename(dirname(__FILE__)); 
    62 load_plugin_textdomain( 'wp-to-twitter', false, dirname( plugin_basename( __FILE__ ) ) ); 
     62load_plugin_textdomain( 'wp-to-twitter', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); 
    6363 
    6464$protocol = ( get_option( 'wpt_http' ) == '1' )?'http:':'https:'; 
     
    202202        $administrator->add_cap('wpt_twitter_oauth'); 
    203203        $administrator->add_cap('wpt_twitter_custom'); 
    204         $administrator->add_cap('wpt_twitter_switch'); 
    205         switch ( get_option('wtt_user_permissions') ) { 
     204        $administrator->add_cap('wpt_twitter_switch'); // can toggle tweet/don't tweet 
     205        switch ( get_option('wtt_user_permissions') ) { // users that can add twitter information 
    206206            case 'subscriber': $subscriber->add_cap('wpt_twitter_oauth'); $contributor->add_cap('wpt_twitter_oauth'); $author->add_cap('wpt_twitter_oauth'); $editor->add_cap('wpt_twitter_oauth');   break; 
    207207            case 'contributor': $contributor->add_cap('wpt_twitter_oauth'); $author->add_cap('wpt_twitter_oauth'); $editor->add_cap('wpt_twitter_oauth');  break; 
     
    216216            break; 
    217217        } 
    218         switch ( get_option('wtt_show_custom_tweet') ) { 
     218        switch ( get_option('wtt_show_custom_tweet') ) { // users that can compose a custom tweet 
    219219            case 'subscriber': $subscriber->add_cap('wpt_twitter_custom'); $contributor->add_cap('wpt_twitter_custom'); $author->add_cap('wpt_twitter_custom'); $editor->add_cap('wpt_twitter_custom');   break; 
    220220            case 'contributor': $contributor->add_cap('wpt_twitter_custom'); $author->add_cap('wpt_twitter_custom'); $editor->add_cap('wpt_twitter_custom');  break; 
     
    229229            break; 
    230230        } 
     231    } 
     232    $upgrade = version_compare( $prev_version, "2.4.12","<" ); 
     233    if ( $upgrade ) { 
     234        $administrator = get_role('administrator'); 
     235            $administrator->add_cap('wpt_can_tweet'); 
     236        $editor = get_role('editor'); 
     237            $editor->add_cap('wpt_can_tweet'); 
     238        $author = get_role('author'); 
     239            $author->add_cap('wpt_can_tweet'); 
     240        $contributor = get_role('contributor'); 
     241            $contributor->add_cap('wpt_can_tweet'); 
     242        update_option('wpt_can_tweet','contributor'); 
    231243    } 
    232244    update_option( 'wp_to_twitter_version',$wpt_version ); 
     
    11491161            $replace = get_option( 'jd_replace_character' ); 
    11501162            $strip = get_option( 'jd_strip_nonan' ); 
    1151             $search = "/[^a-zA-Z0-9]/"; 
     1163            $search = "/[^\p{L}\p{N}\s]/u"; 
    11521164            if ($replace == "[ ]") { $replace = ""; } 
    11531165            $tag = str_ireplace( " ",$replace,trim( $tag ) ); 
     
    11841196 
    11851197function jd_add_twitter_inner_box() { 
     1198 
     1199if ( current_user_can('wpt_can_tweet') ) { 
    11861200global $post, $jd_plugin_url, $jd_donate_url; 
    11871201    $post_length = 140; 
     
    12601274    } 
    12611275?> 
     1276<?php } else { ?> 
     1277<input type="hidden" name='_jd_twitter' value='' /> 
    12621278<?php } ?> 
    1263 <?php if ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'wpt_twitter_switch' ) || current_user_can('update_core') ) { ?> 
     1279<?php if ( current_user_can( 'wpt_twitter_switch' ) || current_user_can('update_core') ) { ?> 
    12641280<?php 
    12651281    // "no" means 'Don't Tweet' (is checked) 
     
    12681284?> 
    12691285<p><input type="radio" name="_jd_tweet_this" value="no" id="jtn"<?php echo $nochecked; ?> /> <label for="jtn"><?php _e("Don't Tweet this post.", 'wp-to-twitter'); ?></label> <input type="radio" name="_jd_tweet_this" value="yes" id="jty"<?php echo $yeschecked; ?> /> <label for="jty"><?php _e("Tweet this post.", 'wp-to-twitter'); ?></label></p> 
     1286<?php } else { ?> 
     1287    <input type='hidden' name='_jd_tweet_this' value='<?php echo $jd_tweet_this; ?>' /> 
    12701288<?php } ?> 
    12711289<?php /* WPT PRO */ ?> 
    12721290<?php  
    1273 if ( function_exists('wpt_pro_exists') ) {  
     1291if ( function_exists('wpt_pro_exists') && ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'update_core' ) ) ) {  
    12741292    wpt_schedule_values( $post_id );  
    12751293} ?> 
    12761294<?php /* WPT PRO */ ?> 
    1277 <?php if ( !current_user_can( 'wpt_twitter_custom' ) || !current_user_can( 'wpt_twitter_switch' ) ) { ?> 
     1295<?php if ( !current_user_can( 'wpt_twitter_custom' ) && !current_user_can( 'update_core' ) ) { ?> 
    12781296<div> 
    12791297<p><?php _e('Access to customizing WP to Twitter values is not allowed for your user role.','wp-to-twitter'); ?></p> 
    1280 <?php if ( !current_user_can( 'wpt_twitter_switch' ) ) { ?> 
    1281 <input type="hidden" name='_jd_tweet_this' value='<?php echo $jd_tweet_this; ?>' /> 
    1282 <?php } ?> 
    1283 <input type="hidden" name='_jd_twitter' value='' /> 
    12841298<?php  
    12851299if ( function_exists('wpt_pro_exists') ) {  
     
    13011315?> 
    13021316</p> 
     1317<?php if ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'update_core' ) ) { ?> 
    13031318<p> 
    13041319<?php _e("Twitter posts are a maximum of 140 characters; Twitter counts URLs as 19 characters. Template tags: <code>#url#</code>, <code>#title#</code>, <code>#post#</code>, <code>#category#</code>, <code>#date#</code>, <code>#modified#</code>, <code>#author#</code>, <code>#account#</code>, <code>#tags#</code>, or <code>#blog#</code>.", 'wp-to-twitter') ?>  
    13051320</p> 
     1321<?php } ?> 
    13061322<p> 
    13071323<?php if ( !function_exists( 'wpt_pro_exists' ) ) { ?> 
     
    13111327<?php } ?> 
    13121328</p> 
    1313 <?php }  
     1329<?php  
     1330    } else { // permissions: this user isn't allowed to Tweet; 
     1331        _e('Your role does not have the ability to Post Tweets from this site.','wp-to-twitter'); ?> <input type='hidden' name='_jd_tweet_this' value='no' /> <?php 
     1332    } 
     1333}  
    13141334function jd_add_twitter_outer_box() { 
    13151335    wpt_check_version(); 
     
    13251345    } 
    13261346} 
    1327 /* This function upgrades post meta from a format not used since July 2010, prior to converting to OAuth.  
     1347/* This function upgraded post meta from a format not used since July 2010, prior to converting to OAuth.  
    13281348function jd_fix_post_meta( $post_id ) { 
    13291349    $oldmeta = array('jd_tweet_this','jd_twitter','wp_jd_clig','wp_jd_bitly','wp_jd_wp','wp_jd_yourls','wp_jd_url','wp_jd_target','jd_wp_twitter'); 
Note: See TracChangeset for help on using the changeset viewer.