WordPress.org

Plugin Directory

Changeset 640172


Ignore:
Timestamp:
12/16/12 21:40:26 (16 months ago)
Author:
ozh
Message:

1.6.1:
Fixed: Partial SVN commit, doh.

Location:
yourls-wordpress-to-twitter/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • yourls-wordpress-to-twitter/trunk/inc/core.php

    r476261 r640172  
    1010        wp_ozh_yourls_head_linkrel(); 
    1111    } 
    12 } 
    13  
    14 // Manual tweet from the Edit interface 
    15 function wp_ozh_yourls_promote() { 
    16     check_ajax_referer( 'yourls' ); 
    17     $post_id = (int) $_POST['yourls_post_id']; 
    18      
    19     $sent = wp_ozh_yourls_send_tweet( stripslashes($_POST['yourls_tweet']) ); 
    20      
    21     if ( !isset($sent->error) ) { 
    22         $account = wp_ozh_yourls_get_twitter_screen_name(); 
    23         $result = sprintf( __( "Success! Post was promoted on <a href='http://twitter.com/%1$s'>%2$s</a>!", 'wp-ozh-yourls' ), $account, $account ); 
    24         update_post_meta($post_id, 'yourls_tweeted', 1); 
    25     } else { 
    26         $result = $sent->error; 
    27     } 
    28     $x = new WP_AJAX_Response( array( 
    29         'data' => $result 
    30     ) ); 
    31     $x->send(); 
    32     die('1');    
    3312} 
    3413 
     
    151130    } 
    152131     
    153 } 
    154  
    155 // Tweet something. Returns stuff. 
    156 function wp_ozh_yourls_send_tweet( $tweet ) { 
    157     global $wp_ozh_yourls; 
    158      
    159     do_action( 'yourls_send_tweet', $tweet ); 
    160      
    161     require_once( dirname(__FILE__) . '/oauth.php' ); 
    162     return wp_ozh_yourls_tweet_it( $tweet ); 
    163132} 
    164133 
     
    277246            break; 
    278247         
    279         case 'bitly': 
    280             $api_url = sprintf( 'http://api.bit.ly/shorten?version=2.0.1&longUrl=%s&login=%s&apiKey=%s', 
    281                 urlencode($url), $wp_ozh_yourls['bitly_login'], $wp_ozh_yourls['bitly_password'] ); 
    282             $json = wp_ozh_yourls_remote_json( $api_url ); 
    283             if ($json) 
    284                 $shorturl = $json->results->$url->shortUrl; // bit.ly's API makes ugly JSON, seriously, tbh 
    285             break; 
    286              
    287         case 'pingfm': 
    288             $api_url = 'http://api.ping.fm/v1/url.create'; 
    289             $body = array( 
    290                 'api_key' => 'd0e1aad9057142126728c3dcc03d7edb', 
    291                 'user_app_key' => $wp_ozh_yourls['pingfm_user_app_key'], 
    292                 'long_url' => $url 
    293             ); 
    294             $xml = wp_ozh_yourls_fetch_url( $api_url, 'POST', $body ); 
    295             if ($xml) { 
    296                 preg_match_all('!<short_url>[^<]+</short_url>!', $xml, $matches); 
    297                 $shorturl = $matches[0][0];              
    298             } 
    299             break; 
    300          
    301         case 'tinyurl': 
    302             $api_url = sprintf( 'http://tinyurl.com/api-create.php?url=%s', urlencode($url) ); 
    303             $shorturl = wp_ozh_yourls_remote_simple( $api_url ); 
    304             break; 
    305          
    306         case 'isgd': 
    307             $api_url = sprintf( 'http://is.gd/api.php?longurl=%s', urlencode($url) ); 
    308             $shorturl = wp_ozh_yourls_remote_simple( $api_url ); 
    309             break; 
    310              
    311248        default: 
    312249            die('Error, unknown service'); 
     
    408345} 
    409346 
    410 // Parse the tweet template and make a 140 char string 
    411 function wp_ozh_yourls_maketweet( $url, $title, $id ) { 
     347// Init plugin on public part 
     348function wp_ozh_yourls_init() { 
     349    global $wp_ozh_yourls; 
     350    $wp_ozh_yourls = get_option('ozh_yourls'); 
     351} 
     352 
     353// Init admin stuff 
     354function wp_ozh_yourls_admin_init() { 
     355    global $wp_ozh_yourls; 
     356    $wp_ozh_yourls = get_option('ozh_yourls'); 
     357 
     358    register_setting( 'wp_ozh_yourls_options', 'ozh_yourls', 'wp_ozh_yourls_sanitize' ); 
     359 
     360    if ( !wp_ozh_yourls_settings_are_ok() ) { 
     361        add_action( 'admin_notices', 'wp_ozh_yourls_admin_notice' ); 
     362    } 
     363 
     364} 
     365 
     366// Generate on... $type = 'post' or 'page' or any custom post type, returns boolean 
     367function wp_ozh_yourls_generate_on( $type ) { 
    412368    global $wp_ozh_yourls; 
    413369 
     
    415371        $wp_ozh_yourls = get_option( 'ozh_yourls' ); 
    416372 
    417     $tweet = $wp_ozh_yourls['twitter_message']; 
    418  
    419     // Plugin author: interrupt here before everything is parsed 
    420     $tweet = apply_filters( 'pre_ozh_yourls_tweet', $tweet, $url, $title, $id ); 
    421  
    422     // Replace %U with short url 
    423     $tweet = str_replace('%U', $url, $tweet); 
    424      
    425     // Replace %F{bleh} with custom post field 'bleh' 
    426     if( preg_match_all( '/%F\{([^\}]+)\}/', $tweet, $matches ) ) { 
    427         foreach( $matches[1] as $match ) { 
    428             $field = get_post_meta( $id, $match, true ); 
    429             $tweet = str_replace('%F{'.$match.'}', $field, $tweet); 
    430         } 
    431         unset( $matches ); 
    432     } 
    433  
    434         if (strpos($tweet, '%A') !== false) { 
    435             // Get author info 
    436             $post = get_post( $id ); 
    437             $author_id = $post->post_author; 
    438             $author_info = get_userdata( $author_id ); 
    439             unset( $post ); 
    440  
    441             // Replace %A{bleh} with author data 'bleh' 
    442             if( preg_match_all('/%A\{([^\}]+)\}/', $tweet, $matches)) { 
    443                 foreach( $matches[1] as $match ) { 
    444                     $tweet = str_replace('%A{'.$match.'}', $author_info->$match, $tweet); 
    445                 } 
    446                 unset( $matches ); 
    447             } 
    448  
    449             // Replace %A with author display name 
    450             $tweet = str_replace('%A', $author_info->display_name, $tweet); 
    451         } 
    452  
    453         if (strpos($tweet, '%X') !== false) { 
    454             if (preg_match_all('/%X\{([^\}]+)\}/', $tweet, $matches)) { 
    455                 foreach ($matches[1] as $tax) { 
    456                     $_terms = array_slice((array)get_the_terms($id, $tax), 0, 3); 
    457                     $terms = array(); 
    458                     foreach ($_terms as $term) { 
    459                         $terms[] = strtolower(str_replace(" ", "", $term->name)); 
    460                     } 
    461                     unset($_terms); 
    462  
    463                     $tweet = str_replace('%X{'.$tax.'}', join(' ', $terms), $tweet); 
    464                 } 
    465                 unset($matches); 
    466             } 
    467         } 
    468  
    469         if (strpos($tweet, '%Y') !== false) { 
    470             if (preg_match_all('/%Y\{([^\}]+)\}/', $tweet, $matches)) { 
    471                 foreach ($matches[1] as $tax) { 
    472                     $_terms = array_slice((array)get_the_terms($id, $tax), 0, 3); 
    473                     $terms = array(); 
    474                     foreach ($_terms as $term) { 
    475                         $terms[] = strtolower(str_replace(" ", "", $term->name)); 
    476                     } 
    477                     unset($_terms); 
    478  
    479                     $tweet = str_replace('%Y{'.$tax.'}', "#".join(' #', $terms), $tweet); 
    480                 } 
    481                 unset($matches); 
    482             } 
    483         } 
    484  
    485         if (strpos($tweet, '%L') !== false || strpos($tweet, '%H') !== false) { 
    486             // Get tags (up to 3) 
    487             $_tags = array_slice( (array)get_the_tags( $id ), 0, 3 ); 
    488             $tags = array(); 
    489             foreach( $_tags as $tag ) { $tags[] = strtolower( str_replace( " ", "", $tag->name ) ); } 
    490             unset( $_tags ); 
    491  
    492             // Replace %L with tags as plaintext (space separated if more than one) (up to 3 tags) 
    493             $tweet = str_replace('%L', join(' ', $tags), $tweet); 
    494  
    495             // Replace %H with tags as hashtags (space separated if more than one) (up to 3 tags)  
    496             $tweet = str_replace('%H', '#'.join(' #', $tags), $tweet); 
    497         } 
    498  
    499         if (strpos($tweet, '%C') !== false || strpos($tweet, '%D') !== false) { 
    500             // Get categories (up to 3) 
    501             $_cats = array_slice( (array)get_the_category( $id ), 0, 3 ); 
    502             $cats = array(); 
    503             foreach( $_cats as $cat ) { $cats[] = strtolower( str_replace( " ", "", $cat->name ) ); } 
    504             unset( $_cats ); 
    505  
    506             // Replace %C with categories (space separated if more than one) (up to 3 categories)  
    507             $tweet = str_replace('%C', join(' ', $cats), $tweet); 
    508  
    509             // Replace %D with categories as hashtags (space separated if more than one) (up to 3 categories)  
    510             $tweet = str_replace('%D', '#'.join(' #', $cats), $tweet); 
    511         } 
    512  
    513     // Finally replace %T with as many chars as possible to keep under 140 
    514     $tweet = trim( $tweet ); 
    515     $maxlen = 140 - ( strlen( $tweet ) - 2); // 2 = "%T" 
    516     if (strlen($title) > $maxlen) { 
    517         $title = substr($title, 0, ($maxlen - 3)) . '...'; 
    518     } 
    519     $tweet = str_replace('%T', $title, $tweet); 
    520  
    521     $tweet = apply_filters( 'ozh_yourls_tweet', $tweet, $url, $title, $id ); 
    522  
    523     return $tweet; 
    524 } 
    525  
    526 // Init plugin on public part 
    527 function wp_ozh_yourls_init() { 
    528     global $wp_ozh_yourls; 
    529     $wp_ozh_yourls = get_option('ozh_yourls'); 
    530      
    531     // check for OAuth requests on plugin load. 
    532     if( isset($_GET['oauth_start']) ) { 
    533         require_once( dirname(__FILE__).'/oauth.php' ); 
    534         wp_ozh_yourls_oauth_start(); 
    535     } 
    536     if( isset($_GET['oauth_token']) ) { 
    537         require_once( dirname(__FILE__).'/oauth.php' ); 
    538         wp_ozh_yourls_oauth_confirm(); 
    539     } 
    540      
    541 } 
    542  
    543 // Init admin stuff 
    544 function wp_ozh_yourls_admin_init() { 
    545     global $wp_ozh_yourls; 
    546     $wp_ozh_yourls = get_option('ozh_yourls'); 
    547  
    548     register_setting( 'wp_ozh_yourls_options', 'ozh_yourls', 'wp_ozh_yourls_sanitize' ); 
    549  
    550     if ( !wp_ozh_yourls_settings_are_ok() ) { 
    551         add_action( 'admin_notices', 'wp_ozh_yourls_admin_notice' ); 
    552     } 
    553  
    554     // Deprecated settings since we now use OAuth 
    555     if( isset( $wp_ozh_yourls['twitter_login'] ) or isset( $wp_ozh_yourls['twitter_password'] ) ) { 
    556         unset( $wp_ozh_yourls['twitter_login'] ); 
    557         unset( $wp_ozh_yourls['twitter_password'] ); 
    558         update_option( 'ozh_yourls', $wp_ozh_yourls ); 
    559     } 
    560 } 
    561  
    562 // Generate on... $type = 'post' or 'page' or any custom post type, returns boolean 
    563 function wp_ozh_yourls_generate_on( $type ) { 
     373    return ( isset( $wp_ozh_yourls['generate_on_'.$type] ) && $wp_ozh_yourls['generate_on_'.$type] == 1 ); 
     374} 
     375 
     376// Send tweet on... $type = 'post' or 'page' or any custom post type, returns boolean 
     377function wp_ozh_yourls_tweet_on( $type ) { 
    564378    global $wp_ozh_yourls; 
    565379 
     
    567381        $wp_ozh_yourls = get_option( 'ozh_yourls' ); 
    568382 
    569     return ( isset( $wp_ozh_yourls['generate_on_'.$type] ) && $wp_ozh_yourls['generate_on_'.$type] == 1 ); 
    570 } 
    571  
    572 // Send tweet on... $type = 'post' or 'page' or any custom post type, returns boolean 
    573 function wp_ozh_yourls_tweet_on( $type ) { 
    574     global $wp_ozh_yourls; 
    575  
    576         if ( empty( $wp_ozh_yourls ) ) 
    577         $wp_ozh_yourls = get_option( 'ozh_yourls' ); 
    578  
    579383    return ( isset( $wp_ozh_yourls['tweet_on_'.$type] ) && $wp_ozh_yourls['tweet_on_'.$type] == 1 ); 
    580384} 
     
    587391        $wp_ozh_yourls = get_option( 'ozh_yourls' ); 
    588392     
    589     if ( $wp_ozh_yourls['service'] == 'yourls' && $wp_ozh_yourls['location'] == 'local' ) 
     393    if ( $wp_ozh_yourls['location'] == 'local' ) 
    590394        return 'yourls-local'; 
    591395     
    592     if ( $wp_ozh_yourls['service'] == 'yourls' && $wp_ozh_yourls['location'] == 'remote' ) 
     396    if ( $wp_ozh_yourls['location'] == 'remote' ) 
    593397        return 'yourls-remote'; 
    594398         
    595     if ( $wp_ozh_yourls['service'] == 'other') 
    596         return $wp_ozh_yourls['other']; 
     399    return $wp_ozh_yourls['other']; 
    597400} 
    598401 
     
    734537            } 
    735538             
    736             break; 
    737          
    738         case 'bitly' : 
    739             $url = 'http://bit.ly'; 
    740             break; 
    741          
    742         case 'tinyurl' : 
    743             $url = 'http://tinyurl.com'; 
    744             break; 
    745          
    746         case 'isgd' : 
    747             $url = 'http://is.gd'; 
    748539            break; 
    749540         
  • yourls-wordpress-to-twitter/trunk/inc/options.php

    r476261 r640172  
    55    global $plugin_page; 
    66    if( $plugin_page == 'ozh_yourls' ) { 
    7         $message = __( '<strong>YOURLS - WordPress to Twitter</strong> configuration incomplete', 'wp-ozh-yourls' ); 
     7        $message = __( '<strong>YOURLS - WordPress</strong> configuration incomplete', 'wp-ozh-yourls' ); 
    88    } else { 
    99        $url = menu_page_url( 'ozh_yourls', false ); 
    10         $message = sprintf( __( 'Please configure <strong>YOURLS - WordPress to Twitter</strong> <a href="%s">settings</a> now', 'wp-ozh-yourls' ), $url ); 
     10        $message = sprintf( __( 'Please configure <strong>YOURLS - WordPress</strong> <a href="%s">settings</a> now', 'wp-ozh-yourls' ), $url ); 
    1111    } 
    1212    $notice = <<<NOTICE 
     
    1919function wp_ozh_yourls_add_page() { 
    2020    // Loading CSS & JS *only* where needed. Do it this way too, goddamnit. 
    21     $page = add_options_page( __( 'YOURLS: WordPress to Twitter', 'wp-ozh-yourls' ), 'YOURLS', 'manage_options', 'ozh_yourls', 'wp_ozh_yourls_do_page' ); 
     21    $page = add_options_page( __( 'YOURLS WordPress', 'wp-ozh-yourls' ), 'YOURLS', 'manage_options', 'ozh_yourls', 'wp_ozh_yourls_do_page' ); 
    2222    add_action("load-$page", 'wp_ozh_yourls_add_css_js_plugin'); 
    2323    add_action("load-$page", 'wp_ozh_yourls_handle_action_links'); 
     
    6262        } 
    6363    } 
    64      
    65     // Twitter keys 
    66     foreach( array( 'consumer_key', 'consumer_secret', 'yourls_acc_token', 'yourls_acc_secret' ) as $key ) { 
    67         $in[$key] = wp_ozh_yourls_validate_key( $in[$key] ); 
    68     } 
    69      
     64 
    7065    // Get the shortener base URL based, on the new settings 
    7166    $in['shortener_base_url'] = wp_ozh_yourls_determine_base_url( $in ); 
    7267     
    7368    return $in; 
    74 } 
    75  
    76 // Validate Twitter keys 
    77 function wp_ozh_yourls_validate_key( $key ) { 
    78     $key = trim( $key ); 
    79     if( !preg_match('/^[A-Za-z0-9-_]+$/', $key) ) 
    80           $key = ''; 
    81     return $key; 
    82 } 
    83  
    84 // Admin notice telling the Twitter keys were reset because invalid 
    85 function wp_ozh_yourls_admin_notice_twitter_key() { 
    86     echo <<<OOPS 
    87     <div class="error"><p>The Consumer or Secret Key is invalid. Please re-input.</p></div> 
    88 OOPS; 
    8969} 
    9070 
     
    9373    global $wp_ozh_yourls; 
    9474 
    95     $check_twitter   = ( wp_ozh_yourls_twitter_keys_empty() ? false : true ); 
    96     $check_twitter   = ( $check_twitter && ( wp_ozh_yourls_twitter_check() === true ) ); 
    97     $check_yourls    = ( isset( $wp_ozh_yourls['service'] ) && !empty( $wp_ozh_yourls['service'] ) ? true : false ); 
    98     $check_wordpress = ( isset( $wp_ozh_yourls['twitter_message'] ) && !empty( $wp_ozh_yourls['twitter_message'] ) ? true : false ); 
     75    $check_yourls    = ( isset( $wp_ozh_yourls['location'] ) && !empty( $wp_ozh_yourls['location'] ) ? true : false ); 
    9976     
    10077    $check_buddypress = true; // We don't really care if BP is set up 
    10178     
    10279    if( $check == 'overall' ) { 
    103         $overall = $check_twitter && $check_yourls && $check_wordpress ; 
     80        $overall = $check_yourls && $check_buddypress ; 
    10481        return $overall; 
    10582    } else { 
    106         return array( 'check_yourls' => $check_yourls, 'check_twitter' => $check_twitter, 'check_wordpress' => $check_wordpress, 'check_buddypress' => $check_buddypress ); 
     83        return array( 'check_yourls' => $check_yourls, 'check_buddypress' => $check_buddypress ); 
    10784    } 
    10885} 
     
    159136    $ozh_yourls = get_option('ozh_yourls');  
    160137     
    161     extract( wp_ozh_yourls_settings_are_ok( 'all' ) ); // $check_twitter, $check_yourls, $check_wordpress 
    162      
    163     // If only one of the 3 $check_ is false, expand that section, otherwise expand first 
    164     switch( intval( $check_twitter ) + intval( $check_yourls ) + intval( $check_wordpress ) ) { 
    165         case 0: 
    166         case 3: 
    167             $script_expand = "jQuery('#h3_yourls').click();"; 
    168             break; 
    169         case 1: 
    170         case 2: 
    171             if( !$check_yourls ) { 
    172                 $script_expand = "jQuery('#h3_yourls').click();"; 
    173             } elseif( !$check_twitter ) { 
    174                 $script_expand = "jQuery('#h3_twitter').click();"; 
    175             } else { 
    176                 $script_expand = "jQuery('#h3_wordpress').click();"; 
    177             } 
    178             break; 
    179     } 
    180  
    181      
    182138    ?> 
    183     <script> 
    184     jQuery(document).ready(function(){ 
    185         toggle_ok_notok('#h3_check_yourls', '<?php echo $check_yourls ? 'ok' : 'notok' ; ?>' ); 
    186         toggle_ok_notok('#h3_check_twitter', '<?php echo $check_twitter ? 'ok' : 'notok' ; ?>' ); 
    187         toggle_ok_notok('#h3_check_wordpress', '<?php echo $check_wordpress ? 'ok' : 'notok' ; ?>' ); 
    188         <?php echo $script_expand; ?> 
    189     }); 
    190     </script>    
    191      
     139 
    192140    <div class="wrap"> 
    193141     
     
    198146 
    199147    <div class="icon32" id="icon-plugins"><br/></div> 
    200     <h2><?php _e( 'YOURLS - WordPress to Twitter', 'wp-ozh-yourls' ) ?></h2> 
     148    <h2><?php _e( 'YOURLS - WordPress', 'wp-ozh-yourls' ) ?></h2> 
    201149     
    202150    <div id="y_logo"> 
     
    206154        <div class="y_text"> 
    207155            <p><?php _e( '<a href="http://yourls.org/">YOURLS</a> is a free URL shortener service you can run on your webhost to have your own personal TinyURL.', 'wp-ozh-yourls' ) ?></p> 
    208             <p><?php _e( 'This plugin is a bridge between <a href="http://yourls.org/">YOURLS</a>, <a href="http://twitter.com/">Twitter</a> and your blog: when you submit a new post or page, your blog will tap into YOURLS to generate a short URL for it, and will then tweet it.', 'wp-ozh-yourls' ) ?></p> 
    209             <p><?php _e( 'Note that, for maximum fun, this plugin also supports a few other public URL shortener services: is.gd, tinyURL and bit.ly', 'wp-ozh-yourls' ) ?></p> 
     156            <p><?php _e( 'This plugin is a bridge between <a href="http://yourls.org/">YOURLS</a> and your blog: when you submit a new post or page, your blog will tap into YOURLS to generate a short URL for it', 'wp-ozh-yourls' ) ?></p> 
    210157        </div> 
    211158    </div> 
     
    214161    <?php settings_fields('wp_ozh_yourls_options'); ?> 
    215162 
    216     <h3><?php _e( 'URL Shortener Settings', 'wp-ozh-yourls' ) ?> <span class="h3_toggle expand" id="h3_yourls">+</span> <span id="h3_check_yourls" class="h3_check">*</span></h3> 
     163    <h3><?php _e( 'URL Shortener Settings', 'wp-ozh-yourls' ) ?></h3> 
    217164 
    218165    <div class="div_h3" id="div_h3_yourls"> 
     
    223170    <td> 
    224171 
    225     <label for="y_service"><?php _e( 'You are using:', 'wp-ozh-yourls' ) ?></label> 
    226     <select name="ozh_yourls[service]" id="y_service" class="y_toggle"> 
    227     <option value="" <?php selected( '', $ozh_yourls['service'] ); ?> ><?php _e( 'Please select..', 'wp-ozh-yourls' ) ?></option> 
    228     <option value="yourls" <?php selected( 'yourls', $ozh_yourls['service'] ); ?> ><?php _e( 'your own YOURLS install', 'wp-ozh-yourls' ) ?></option> 
    229     <option value="other" <?php selected( 'other', $ozh_yourls['service'] ); ?> ><?php _e( 'another public service such as TinyURL or bit.ly', 'wp-ozh-yourls' ) ?></option> 
     172    <label for="y_service"><?php _e( 'Your YOURLS installation is', 'wp-ozh-yourls' ) ?></label> 
     173    <select name="ozh_yourls[location]" id="y_location" class="y_toggle"> 
     174    <option value="" <?php selected( '', $ozh_yourls['location'] ); ?> ><?php _e( 'Please select...', 'wp-ozh-yourls' ) ?></option> 
     175    <option value="local" <?php selected( 'local', $ozh_yourls['location'] ); ?> ><?php _e( 'local, on the same webserver', 'wp-ozh-yourls' ) ?></option> 
     176    <option value="remote" <?php selected( 'remote', $ozh_yourls['location'] ); ?> ><?php _e( 'remote, on another webserver', 'wp-ozh-yourls' ) ?></option> 
    230177    </select> 
    231178     
    232     <?php $hidden = ( $ozh_yourls['service'] == 'yourls' ? '' : 'y_hidden' ) ; ?> 
    233     <div id="y_show_yourls" class="<?php echo $hidden; ?> y_service y_level2"> 
    234         <label for="y_location"><?php _e( 'Your YOURLS installation is', 'wp-ozh-yourls' ) ?></label> 
    235         <select name="ozh_yourls[location]" id="y_location" class="y_toggle"> 
    236         <option value="" <?php selected( '', $ozh_yourls['location'] ); ?> ><?php _e( 'Please select...', 'wp-ozh-yourls' ) ?></option> 
    237         <option value="local" <?php selected( 'local', $ozh_yourls['location'] ); ?> ><?php _e( 'local, on the same webserver', 'wp-ozh-yourls' ) ?></option> 
    238         <option value="remote" <?php selected( 'remote', $ozh_yourls['location'] ); ?> ><?php _e( 'remote, on another webserver', 'wp-ozh-yourls' ) ?></option> 
    239         </select> 
    240          
    241179        <?php $hidden = ( $ozh_yourls['location'] == 'local' ? '' : 'y_hidden' ) ; ?> 
    242         <div id="y_show_local" class="<?php echo $hidden; ?> y_location y_level3"> 
     180        <div id="y_show_local" class="<?php echo $hidden; ?> y_location y_level2"> 
    243181            <label for="y_path">Path to YOURLS <tt>config.php</tt></label> <input type="text" class="y_longfield" id="y_path" name="ozh_yourls[yourls_path]" value="<?php echo $ozh_yourls['yourls_path']; ?>"/> <span id="check_path" class="yourls_check button">check</span><br/> 
    244182            <em><?php _e( 'Example:', 'wp-ozh-yourls' ) ?></em> <tt>/home/you/site.com/yourls/includes/config.php</tt> 
     
    246184         
    247185        <?php $hidden = ( $ozh_yourls['location'] == 'remote' ? '' : 'y_hidden' ) ; ?> 
    248         <div id="y_show_remote" class="<?php echo $hidden; ?> y_location y_level3"> 
     186        <div id="y_show_remote" class="<?php echo $hidden; ?> y_location y_level2"> 
    249187            <label for="y_url"><?php _e( 'URL to the YOURLS API', 'wp-ozh-yourls' ) ?></label> <input type="text" id="y_url" class="y_longfield" name="ozh_yourls[yourls_url]" value="<?php echo $ozh_yourls['yourls_url']; ?>"/> <span id="check_url" class="yourls_check button">check</span><br/> 
    250188            <em><?php _e( 'Example:', 'wp-ozh-yourls' ) ?></em> <tt>http://site.com/yourls-api.php</tt><br/> 
    251189            <label for="y_yourls_login"><?php _e( 'YOURLS Login', 'wp-ozh-yourls' ) ?></label> <input type="text" id="y_yourls_login" name="ozh_yourls[yourls_login]" value="<?php echo $ozh_yourls['yourls_login']; ?>"/><br/> 
    252190            <label for="y_yourls_passwd"><?php _e( 'YOURLS Password', 'wp-ozh-yourls' ) ?></label> <input type="password" id="y_yourls_passwd" name="ozh_yourls[yourls_password]" value="<?php echo $ozh_yourls['yourls_password']; ?>"/><br/> 
     191            <strong>Tip</strong>: you can create a new YOURLS user, eg <code>myblog</code>, for this. <a href="http://code.google.com/p/yourls/wiki/UsernamePasswords">Guide</a> 
    253192        </div> 
    254193        <?php 
     
    257196    </div> 
    258197     
    259     <?php $hidden = ( $ozh_yourls['service'] == 'other' ? '' : 'y_hidden' ) ; ?> 
    260     <div id="y_show_other" class="<?php echo $hidden; ?> y_service y_level2"> 
    261  
    262         <label for="y_other"><?php _e( 'Public service', 'wp-ozh-yourls' ) ?></label> 
    263         <select name="ozh_yourls[other]" id="y_other" class="y_toggle"> 
    264         <option value="" <?php selected( '', $ozh_yourls['other'] ); ?> ><?php _e( 'Please select...', 'wp-ozh-yourls' ) ?></option> 
    265         <!--<option value="pingfm" <?php selected( 'pingfm', $ozh_yourls['other'] ); ?> >ping.fm</option>--> 
    266         <option value="bitly" <?php selected( 'bitly', $ozh_yourls['other'] ); ?> >bit.ly</option> 
    267         <option value="tinyurl" <?php selected( 'tinyurl', $ozh_yourls['other'] ); ?> >tinyURL</option> 
    268         <option value="isgd" <?php selected( 'isgd', $ozh_yourls['other'] ); ?> >is.gd</option> 
    269         </select> 
    270          
    271         <?php $hidden = ( $ozh_yourls['other'] == 'bitly' ? '' : 'y_hidden' ) ; ?> 
    272         <div id="y_show_bitly" class="<?php echo $hidden; ?> y_other y_level3"> 
    273             <label for="y_api_bitly_login"><?php _e( 'API Login', 'wp-ozh-yourls' ) ?> </label> <input type="text" id="y_api_bitly_login" name="ozh_yourls[bitly_login]" value="<?php echo $ozh_yourls['bitly_login']; ?>"/> <?php _e( '(case sensitive!)', 'wp-ozh-yourls' ) ?><br/> 
    274             <label for="y_api_bitly_pass"><?php _e( 'API Key', 'wp-ozh-yourls' ) ?></label> <input type="text" id="y_api_bitly_pass" class="y_longfield" name="ozh_yourls[bitly_password]" value="<?php echo $ozh_yourls['bitly_password']; ?>"/><br/> 
    275             <p class="description"><?php _e( 'If you have a <a href="http://bit.ly/account/">bit.ly</a> account, entering your credentials will link the short URLs to it', 'wp-ozh-yourls' ) ?></p> 
    276         </div> 
    277  
    278         <?php $hidden = ( $ozh_yourls['other'] == 'pingfm' ? '' : 'y_hidden' ) ; ?> 
    279         <div id="y_show_pingfm" class="<?php echo $hidden; ?> y_other y_level3"> 
    280             <label for="y_api_pingfm_user_app_key"><?php _e( 'Web Key', 'wp-ozh-yourls' ) ?></label> <input type="text" id="y_api_pingfm_user_app_key" name="ozh_yourls[pingfm_user_app_key]" value="<?php echo $ozh_yourls['pingfm_user_app_key']; ?>"/><br/> 
    281             <p class="description"><?php _e( 'If you have a <a href="http://ping.fm/">ping.fm</a> account, enter your private <a href="http://ping.fm/key/">Web Key</a>', 'wp-ozh-yourls' ) ?></p> 
    282         </div> 
    283          
    284         <?php $hidden = ( $ozh_yourls['other'] == 'tinyurl' ? '' : 'y_hidden' ) ; ?> 
    285         <div id="y_show_tinyurl" class="<?php echo $hidden; ?> y_other y_level3"> 
    286             <p class="description"><?php _e( '(this service needs no authentication)', 'wp-ozh-yourls' ) ?></p> 
    287         </div> 
    288          
    289  
    290         <?php $hidden = ( $ozh_yourls['other'] == 'isgd' ? '' : 'y_hidden' ) ; ?> 
    291         <div id="y_show_isgd" class="<?php echo $hidden; ?> y_other y_level3"> 
    292             <p class="description"><?php _e( '(this service needs no authentication)', 'wp-ozh-yourls' ) ?></p> 
    293         </div> 
    294          
    295     </div> 
     198 
    296199 
    297200    </td> 
     
    300203    </div><!-- div_h3_yourls --> 
    301204     
    302     <h3><?php _e( 'Twitter Settings', 'wp-ozh-yourls' ) ?> <span class="h3_toggle expand" id="h3_twitter">+</span> <span id="h3_check_twitter" class="h3_check">*</span></h3>  
    303      
    304     <?php 
    305     $blogurl  = get_home_url(); 
    306     $blogname = urlencode( get_bloginfo( 'name' ) ); 
    307     $blogdesc = urlencode( trim( get_bloginfo( 'description' ), '.' ).'. Powered by YOURLS.' ); 
    308     $help_url = $plugin_url."res/help.jpg?tb_iframe=1&width=677&height=608"; 
    309     ?> 
    310      
    311     <div class="div_h3" id="div_h3_twitter"> 
    312     <p><?php _e( 'To connect your site to Twitter, you need to register your blog as a <strong>Twitter Application</strong> and get a <strong>Consumer Key</strong>, a <strong>Consumer Secret</strong>, an <strong>Access Token</strong> and an <strong>Access Token Secret</strong>. Phew. Complicated? Blame Twitter :)', 'wp-ozh-yourls' ) ?></p> 
    313     <p><?php _e( 'Already registered? Find your keys on <a href="http://dev.twitter.com/apps">Twitter Application List</a>', 'wp-ozh-yourls' ) ?></p> 
    314     <p><?php _e( 'Need to register? <a href="http://dev.twitter.com/apps/new">Register an Application</a> and fill the form as <a title="Register your app like this" href="<?php echo $help_url; ?>" class="thickbox">in this help screen</a> to get your keys and tokens', 'wp-ozh-yourls' ) ?></p> 
    315     <ul id="appdetails"> 
    316         <li><?php _e( 'Set <strong>Application Type</strong> to <strong>Browser</strong>', 'wp-ozh-yourls' ) ?></li> 
    317         <li><?php _e( 'Set <strong>Callback URL</strong> to <strong><?php echo $blogurl; ?></strong>', 'wp-ozh-yourls' ) ?></li> 
    318         <li><?php _e( 'Set <strong>Default Access type</strong> to <strong>Read &amp; Write</strong>', 'wp-ozh-yourls' ) ?></li> 
    319     </ul> 
    320  
    321     <table class="form-table"> 
    322  
    323     <tr valign="top"> 
    324     <th scope="row"><?php _e( 'Consumer Key', 'wp-ozh-yourls' ) ?><span class="mandatory">*</span></th> 
    325     <td><input id="consumer_key" name="ozh_yourls[consumer_key]" type="password" size="50" value="<?php echo $ozh_yourls['consumer_key']; ?>"/></td> 
    326     </tr> 
    327  
    328     <tr valign="top"> 
    329     <th scope="row"><?php _e( 'Consumer Secret', 'wp-ozh-yourls' ) ?><span class="mandatory">*</span></th> 
    330     <td><input id="consumer_secret" name="ozh_yourls[consumer_secret]" type="password" size="50" value="<?php echo $ozh_yourls['consumer_secret']; ?>"/></td> 
    331     </tr> 
    332      
    333     <tr valign="top"><td colspan="2"><p><?php _e( 'On the right hand column of your application page, click on \'My Access Token\' for the following values:', 'wp-ozh-yourls' ) ?></p></td></tr> 
    334  
    335     <tr valign="top"> 
    336     <th scope="row"><?php _e( 'Access Token', 'wp-ozh-yourls' ) ?><span class="mandatory">*</span></th> 
    337     <td><input id="yourls_acc_token" name="ozh_yourls[yourls_acc_token]" type="password" size="50" value="<?php echo $ozh_yourls['yourls_acc_token']; ?>"/></td> 
    338     </tr> 
    339      
    340     <tr valign="top"> 
    341     <th scope="row"><?php _e( 'Access Token Secret', 'wp-ozh-yourls' ) ?><span class="mandatory">*</span></th> 
    342     <td><input id="yourls_acc_secret" name="ozh_yourls[yourls_acc_secret]" type="password" size="50" value="<?php echo $ozh_yourls['yourls_acc_secret']; ?>"/></td> 
    343     </tr> 
    344      
    345     <tr> 
    346     <td colspan="2" id="yourls_twitter_infos"> 
    347     <?php 
    348     if( !wp_ozh_yourls_twitter_keys_empty() ) { 
    349         wp_ozh_yourls_twitter_button_or_infos(); // in oauth.php 
    350     } 
    351     ?> 
    352     </td> 
    353     </tr> 
    354      
    355     </table> 
    356      
    357      
    358     </div> <!-- div_h3_twitter --> 
    359      
    360     <h3><?php _e( 'WordPress settings', 'wp-ozh-yourls' ) ?> <span class="h3_toggle expand" id="h3_wordpress">+</span> <span id="h3_check_wordpress" class="h3_check">*</span></h3>  
     205 
     206    <h3><?php _e( 'WordPress settings', 'wp-ozh-yourls' ) ?></h3>  
    361207 
    362208    <div class="div_h3" id="div_h3_wordpress"> 
    363209 
    364     <h4><?php _e( 'When to generate a short URL and tweet it', 'wp-ozh-yourls' ) ?></h4>  
     210    <h4><?php _e( 'When to generate a short URL', 'wp-ozh-yourls' ) ?></h4>  
    365211     
    366212    <table class="form-table"> 
     
    377223        <th scope="row"><?php printf( __( 'New <strong>%s</strong> published', 'wp-ozh-yourls' ), $name ) ?></th> 
    378224        <td> 
    379         <input class="y_toggle" id="generate_on_<?php echo $type; ?>" name="ozh_yourls[generate_on_<?php echo $type; ?>]" type="checkbox" value="1" <?php checked( '1', $generate_checked ); ?> /><label for="generate_on_<?php echo $type; ?>"> <?php _e( 'Generate short URL', 'wp-ozh-yourls' ) ?></label><br/> 
    380         <?php $hidden = ( $generate_checked == '1' ? '' : 'y_hidden' ) ; ?> 
    381         <?php if( $type != 'attachment' ) { ?> 
    382         <div id="y_show_generate_on_<?php echo $type; ?>" class="<?php echo $hidden; ?> generate_on_<?php echo $type; ?>"> 
    383             <input id="tweet_on_<?php echo $type; ?>" name="ozh_yourls[tweet_on_<?php echo $type; ?>]" type="checkbox" value="1" <?php checked( '1', $tweet_checked ) ?> /><label for="tweet_on_<?php echo $type; ?>"> <?php _e( 'Send a tweet with the short URL', 'wp-ozh-yourls' ) ?></label> 
    384         </div> 
    385         <?php } ?> 
     225        <input class="y_toggle" id="generate_on_<?php echo $type; ?>" name="ozh_yourls[generate_on_<?php echo $type; ?>]" type="checkbox" value="1" <?php checked( '1', $generate_checked ); ?> /><label for="generate_on_<?php echo $type; ?>"> <?php _e( 'Generate short URL', 'wp-ozh-yourls' ) ?></label> 
    386226        </td> 
    387227        </tr> 
     
    390230    </table> 
    391231 
    392     <h4><?php _e( 'What to tweet', 'wp-ozh-yourls' ) ?></h4>  
    393  
    394     <table class="form-table"> 
    395  
    396     <tr valign="top"> 
    397     <th scope="row"><?php _e( 'Tweet message', 'wp-ozh-yourls' ) ?><span class="mandatory">*</span></th> 
    398     <td><input id="tw_msg" name="ozh_yourls[twitter_message]" type="text" size="50" value="<?php echo $ozh_yourls['twitter_message']; ?>"/><br/> 
    399     <?php _e( 'This is your tweet template. The plugin will replace <tt>%T</tt> with the post title and <tt>%U</tt> with its short URL, with as much text as possible so it fits in the 140 character limit<br/> 
    400     Examples (click one to copy)', 'wp-ozh-yourls' ) ?><br/> 
    401     <ul id="tw_msg_sample"> 
    402         <li><code class="tw_msg_sample"><?php printf( __( 'Fresh on %s', 'wp-ozh-yourls' ), get_bloginfo() ) ?>: %T %U</code></li> 
    403         <li><code class="tw_msg_sample"><?php _e( 'Just posted:', 'wp-ozh-yourls' ) ?> %T %U</code></li> 
    404         <li><code class="tw_msg_sample">%T - %U</code></li> 
    405     </ul> 
    406     <em><?php _e( 'Tip: Keep the tweet message template short!', 'wp-ozh-yourls' ) ?></em> 
    407     <h4 id="toggle_advanced_template"><?php _e( 'Advanced template', 'wp-ozh-yourls' ) ?></h4> 
    408     <div id="advanced_template"> 
    409         <?php _e( 'You can use all of the following tokens in your tweet template:', 'wp-ozh-yourls' ) ?> 
    410         <ul> 
    411             <li><b><tt>%U</tt></b>: <?php _e( 'shorturl', 'wp-ozh-yourls' ) ?></li> 
    412             <li><b><tt>%T</tt></b>: <?php _e( 'post title', 'wp-ozh-yourls' ) ?></li> 
    413             <li><b><tt>%A</tt></b>: <?php _e( 'author\'s display name', 'wp-ozh-yourls' ) ?></li> 
    414             <li><b><tt>%A{<?php _e( 'something', 'wp-ozh-yourls' ) ?>}</tt></b>: <?php _e( 'author\'s \'something\' as stored in the database. Example: %A{first_name}. See <a href="http://codex.wordpress.org/Function_Reference/get_userdata">get_userdata()</a>.', 'wp-ozh-yourls' ) ?></li> 
    415             <li><b><tt>%F{<?php _e( 'something', 'wp-ozh-yourls' ) ?>}</tt></b>: <?php _e( 'custom post field \'something\'. See <a href="http://codex.wordpress.org/Function_Reference/get_post_meta">get_post_meta()</a>.', 'wp-ozh-yourls' ) ?></li> 
    416             <li><b><tt>%X{<?php _e( 'taxonomy', 'wp-ozh-yourls' ) ?>}</tt></b>: <?php _e( 'terms as plaintext and lowercase for taxonomy. Example: %X{category} (space separated if more than one, up to 3 tags)', 'wp-ozh-yourls' ) ?></li> 
    417             <li><b><tt>%Y{<?php _e( 'taxonomy', 'wp-ozh-yourls' ) ?>}</tt></b>: <?php _e( 'terms as #hashtags and lowercase for taxonomy. Example: %Y{category} (space separated if more than one, up to 3 tags)', 'wp-ozh-yourls' ) ?></li> 
    418             <li><b><tt>%L</tt></b>: <?php _e( 'tags as plaintext and lowercase (space separated if more than one, up to 3 tags)', 'wp-ozh-yourls' ) ?></li> 
    419             <li><b><tt>%H</tt></b>: <?php _e( 'tags as #hashtags and lowercase (space separated if more than one, up to 3 tags)', 'wp-ozh-yourls' ) ?></li> 
    420             <li><b><tt>%C</tt></b>: <?php _e( 'categories as plaintext and lowercase (space separated if more than one, up to 3 categories)', 'wp-ozh-yourls' ) ?></li> 
    421             <li><b><tt>%D</tt></b>: <?php _e( 'categories as #hashtags and lowercase (space separated if more than one, up to 3 categories)', 'wp-ozh-yourls' ) ?></li> 
    422         </ul> 
    423         <?php _e( 'Remember that you only have 140 characters! The title will be added last, so if you put too many tokens like hashtags and stuff, the title might get trimmed hard!', 'wp-ozh-yourls' ) ?> 
     232    </div> <!-- div_h3_wordpress --> 
     233     
     234    <div> 
     235    <h3>Twitter settings?</h3> 
     236    <p>This plugin does not support Twitter stuff any longer. If you want to auto tweet short URLs, use <a href="https://www.google.com/search?q=auto+tweet+wordpress+post">a plugin for that</a></p> 
    424237    </div> 
    425     </td> 
    426     </tr> 
    427  
    428     </table> 
    429      
    430     </div> <!-- div_h3_wordpress --> 
    431238     
    432239    <?php do_action( 'ozh_yourls_admin_sections' ) ?> 
     
    442249    </p> 
    443250     
    444     <p><small><?php printf( __( '<span class="mandatory">*</span> denotes a mandatory field. A green check<img src="%1$s/res/accept.png" /> indicates the section main parameters are <em>filled</em>, not necessarily <em>correct</em>. Click on the <img src="%1$s/res/expand.png" /> to expand a setting section.', 'wp-ozh-yourls' ), $plugin_url ) ?></small></p> 
    445  
    446251    </form> 
    447252 
     
    483288    // Too early, young Padawan 
    484289    if ( $status != 'publish' ) { 
    485         _e( '<p>Depending on <a href="options-general.php?page=ozh_yourls">configuration</a>, a short URL will be generated and/or a tweet will be sent.</p>', 'wp-ozh-yourls' ); 
     290        _e( '<p>Depending on <a href="options-general.php?page=ozh_yourls">configuration</a>, a short URL will be generated.</p>', 'wp-ozh-yourls' ); 
    486291        return; 
    487292    } 
     
    509314    echo '<p style="text-align:right"><input class="button" id="yourls_reset" type="submit" value="' . __( 'Reset short URL', 'wp-ozh-yourls' ) . '" /></p>'; 
    510315    echo '</div>'; 
    511      
    512  
    513     // Twitter part: 
    514     if( wp_ozh_yourls_twitter_keys_empty() or wp_ozh_yourls_get_twitter_screen_name() === false ) 
    515         return; 
    516      
    517     $action = __( 'Tweet this', 'wp-ozh-yourls' ); 
    518     $promote = sprintf( __( "Promote this %s", 'wp-ozh-yourls' ), $type_label ); 
    519     $tweeted = get_post_meta( $id, 'yourls_tweeted', true ); 
    520  
    521     echo '<p><strong>'.$promote.' on <a href="http://twitter.com/'.$account.'">@'.$account.'</a>: </strong></p> 
    522     <div id="yourls-promote">'; 
    523     if ($tweeted) { 
    524         $action = __( 'Retweet this', 'wp-ozh-yourls' ); 
    525         $promote = sprintf( __( "Promote this %s again", 'wp-ozh-yourls' ), $type_label ); 
    526         echo '<p>' . __( '<em>Note:</em> this post has already been tweeted. Not that there\'s something wrong to promote it again, of course :)', 'wp-ozh-yourls' ) . '</p>'; 
    527     } 
    528     echo '<p><textarea id="yourls_tweet" rows="1" style="width:100%">'.wp_ozh_yourls_maketweet( $shorturl, $title, $id ).'</textarea></p> 
    529     <p style="text-align:right"><input class="button" id="yourls_promote" type="submit" value="'.$action.'" /></p> 
    530     </div>'; 
    531316} 
    532317 
  • yourls-wordpress-to-twitter/trunk/plugin.php

    r640152 r640172  
    66Author: Ozh 
    77Author URI: http:/ozh.org/ 
    8 Version: 1.6 
     8Version: 1.6.1 
    99*/ 
    1010 
     
    6464 * 1.6:       Removed: Twitter functions 
    6565              Announced: End Of Life for this plugin 
     66 * 1.6.1:     Fixed: Partial SVN commit, doh. 
    6667 */ 
    6768 
Note: See TracChangeset for help on using the changeset viewer.