Plugin Directory

Changeset 198746


Ignore:
Timestamp:
01/27/2010 12:47:39 PM (16 years ago)
Author:
geraldyeo
Message:
 
Location:
url-shortener/trunk
Files:
11 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • url-shortener/trunk/fts-shortenurl.php

    r185791 r198746  
    66Author: Gerald Yeo
    77Author URI: http://fusedthought.com
    8 Version: 1.7
     8Version: 2.0
    99*/
    1010
     
    1414 */
    1515
    16 global $globe_fts_urlfx;
     16global $fts_urlfx;
    1717global $addonurl;
    1818$addonurl = "http://fusedthought.com/downloads/addon-module-for-url-shortener-wordpress-plugin/";
    1919
    20 require_once( dirname(__FILE__) . '/req/urlservices.php' );
     20function fts_shortenurl_init(){
     21    global $fts_urlfx;
     22    //name - db
     23    register_setting('fts_shortenurl','fts_urlfx');
     24    $fts_urlfx = get_option('fts_urlfx');
     25}
     26if ( is_admin() ){
     27    add_action('admin_init', 'fts_shortenurl_init');
     28}
     29require_once( dirname(__FILE__) . '/req/class.FTShorten.php' );
    2130require_once( dirname(__FILE__) . '/req/options.php' );
    22 require_once( dirname(__FILE__) . '/req/services/wprewriteredirect.php' );
    23 require_once( dirname(__FILE__) . '/req/services/templateredirect.php' );
     31require_once( dirname(__FILE__) . '/req/wprewriteredirect.php' );
     32require_once( dirname(__FILE__) . '/req/templateredirect.php' );
     33require_once( dirname(__FILE__) . '/req/addtable.php' );
    2434
    2535function fts_show_shorturl($post){
    2636    $postid = $post->ID;
    27     $the_shorturl = get_post_meta($postid, 'shorturl', $single = true);
     37    $the_shorturl = get_post_meta($postid, 'shorturl', true);
     38    if (!$the_shorturl){
     39        $the_shorturl = get_post_meta($postid, 'short_url', true);
     40    }
    2841    echo $the_shorturl;
    2942}
    3043
    31 function fts_shorturl($url, $api){
     44function fts_shorturl($posturl, $api){
    3245    $api = strip_tags($api);
    3346    $api = preg_replace("/[^a-zA-Z0-9]/", "", $api);
    34     $the_shorturl = createshorturl($api, $url);
    35     echo $the_shorturl;
     47    $selectedservice = $api;
     48    require( dirname(__FILE__) . '/fts-shortenurl-logic.php' );
     49    echo $short;
    3650}
    37 
    38 
    39 function fts_shortenurl($post_ID){
    40     global $globe_fts_urlfx;
    41    
    42     // Generate short URL ?
    43     $got_shorturl = get_post_meta($post_ID, 'shorturl', true);
    44     if (!$got_shorturl){
    45         $posturl = get_permalink($post_ID);
    46        
    47         $selectedservice = $globe_fts_urlfx['urlservice'];
    48         $short = createshorturl($selectedservice, $posturl);
    49         //$short = $posturl; //for testing
    50        
    51         if($short){
    52             update_post_meta($post_ID, 'shorturl', $short);
    53         }else{};
    54        
    55     } else {};
    56 }
    57 
    58 
    59 function fts_shortenurl_get($post_ID){
    60     if($_POST['get-shortlink'] == 'Enabled'){
    61         fts_shortenurl($post_ID);
    62     }
    63 }
    64 
    6551
    6652function fts_shortenurl_remove($post_ID){
     
    7561}
    7662
    77 function fts_shortenurl_future($post){
    78     $fts_urlfx = get_option('fts_urlfx');
     63function fts_shortenurl($post_ID, $typeofpost = 'none'){
     64    global $fts_urlfx;
     65   
     66    $got_shorturl = get_post_meta($post_ID, 'shorturl', true);
     67    $got_other_shorturl = get_post_meta($post_ID, 'short_url', true);
     68   
     69    // Generate short URL
     70    if (!$got_shorturl){
     71        if ($got_other_shorturl){
     72        }else{
     73            if ($typeofpost == 'post'){
     74                $posturl = get_option('home')."/index.php?p=".$post_ID;
     75            }elseif($typeofpost == 'page'){
     76                $posturl = get_option('home')."/index.php?page_id=".$post_ID;
     77            }else{
     78                $posturl = get_permalink($post_ID);
     79            }
     80           
     81            $selectedservice = $fts_urlfx['urlservice'];
     82            require( dirname(__FILE__) . '/fts-shortenurl-logic.php' );
     83            //$short = $posturl; //for testing 
     84            if($short){
     85                update_post_meta($post_ID, 'shorturl', $short);         
     86            }else{};
     87        }; 
     88    }
     89}
     90function fts_shortenurl_gateway($post){
     91    global $fts_urlfx;
    7992    $postid = $post->ID;
    8093    $customyes = $_POST['get-shortlink'];
     94    $typeofpost = $_POST['post_type'];
    8195    $shorturl = get_post_meta($postid, 'shorturl', true);
    8296    if ($fts_urlfx['urlserviceenable'] == 'yes'){
    8397        if($fts_urlfx['urlservice'] != 'none' && !$shorturl){   
    8498            if($fts_urlfx['urlautogen'] == 'yes'){ 
    85                 fts_shortenurl($postid);
     99                fts_shortenurl($postid, $typeofpost);
    86100            } elseif($fts_urlfx['urlautogen'] == 'no' && $customyes == 'Enabled'){
    87                 fts_shortenurl($postid);
     101                fts_shortenurl($postid, $typeofpost);
    88102            }else{};
    89103        }
     
    92106
    93107// Hooks
    94 add_action('wp_ajax_getshortlink', 'fts_shortenurl_get' );
    95 add_action('wp_ajax_removeshortlink', 'fts_shortenurl_remove' );
    96108add_action('save_post', 'fts_shortenurl_remove');
    97 add_action('publish_to_publish', 'fts_shortenurl_future');
    98 add_action('draft_to_publish', 'fts_shortenurl_future');
    99 add_action('private_to_publish', 'fts_shortenurl_future');
    100 add_action('future_to_publish', 'fts_shortenurl_future');
    101 add_action('pending_to_publish', 'fts_shortenurl_future'); 
    102 add_action('new_to_publish', 'fts_shortenurl_future');
    103 //add_action('publish_post', 'fts_shortenurl_get');
    104 //add_action('publish_page', 'fts_shortenurl_get');
     109add_action('publish_to_publish', 'fts_shortenurl_gateway', 15);
     110add_action('draft_to_publish', 'fts_shortenurl_gateway', 15);
     111add_action('private_to_publish', 'fts_shortenurl_gateway', 15);
     112add_action('future_to_publish', 'fts_shortenurl_gateway', 15);
     113add_action('pending_to_publish', 'fts_shortenurl_gateway', 15); 
     114add_action('new_to_publish', 'fts_shortenurl_gateway', 15);
    105115add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'fts_shortenurl_actions', -10);
    106116?>
  • url-shortener/trunk/readme.txt

    r185803 r198746  
    22Contributors: geraldyeo
    33Donate link: http://fusedthought.com/donate/
    4 Tags: url-shortener, short-url, url, shorten, shortener, tinyurl, is.gd, su.pr, bit.ly, tr.im, short.ie, snipurl, snurl, cl.gs, short.to, ping.fm, chilp.it, smoosh, smsh.me, u.nu, unfake.it, awe.sm, social, tweet, twitter, goo.gl
     4Tags: url-shortener, short-url, url, shorten, shortener, tinyurl, is.gd, su.pr, bit.ly, tr.im, short.ie, snipurl, snurl, cl.gs, short.to, ping.fm, chilp.it, smoosh, smsh.me, u.nu, unfake.it, awe.sm, social, tweet, twitter, goo.gl, digg, Voizle
    55Requires at least: 2.7
    6 Tested up to: 2.9
    7 Stable tag: 1.7
     6Tested up to: 2.9.1
     7Stable tag: 2.0
    88
    99Use your own URL Shortener or integrate 3rd Party Services with WordPress. Allows generating of shorturl with various services upon post/page publishing.
     
    1919`<?php fts_show_shorturl($post); ?>`
    2020
    21 
    22 As of Version 1.5, I've added an on-demand shortening function for use in the templates:
     21On-demand shortening function (V1.5) is also for use in your templates:
    2322
    2423`<?php fts_shorturl('http://www.google.com', 'supr'); ?>`
    2524
    26 
    27 Version 1.5 also brings about an updated administration options page.
    28 
    29 
    30 Version 1.7 now enables the inclusion of a addon module which will enable URL Shortening Services which are undergoing testing but not official supported under this main plugin. For more information, visit the [URL Shortener Addon Module information page](http://fusedthought.com/downloads/addon-module-for-url-shortener-wordpress-plugin/ "URL Shortener Addon Module information page") 
    31 
    32 **Current supported services are:**
     25**Services currently supported are:**
    3326
    3427* tinyurl
     
    3831* tr.im
    3932* short.ie
    40 * snipurl (aka Snurl / Snipr / Sn.im)
     33* snipurl (aka Snurl / Snipr)
    4134* cl.gs
    4235* short.to
     
    5750
    5851*  goo.gl (Google URL Shortener)
     52*  Digg
     53*  Voizle
     54
     55
     56**Highlights:**
     57
     58Version 1.5 also brings about an updated administration options page.
     59
     60Version 1.7 now enables the inclusion of a addon module which will enable URL Shortening Services which are undergoing testing but not official supported under this main plugin. For more information, visit the [URL Shortener Addon Module information page](http://fusedthought.com/downloads/addon-module-for-url-shortener-wordpress-plugin/ "URL Shortener Addon Module information page") 
     61
     62Version 2.0 now supports bulk editing and generation of Short URLs.
    5963
    6064
    6165**Future Versions:**
    6266
    63 *  I am still looking into creating a URL Management page to manage all the generated URLs within the site.
    6467*  Twitter and Facebook posting integration?
    6568*  More services can be added upon request.
     
    82851. plugin admin interface (ver 1.4)
    83861. plugin admin interface (ver 1.5)
    84 
     871. bulk editing options (ver 2.0)
    8588
    8689== Changelog ==
     90
     91= 2.0 =
     92* Short URLs now generated using Post/Page IDs instead of Permalinks ensuring correct redirection even if post title/permalink changes.
     93* Bugfix: Blank screen when Shorten2Ping plugin is also activated. If Shorten2Ping is activated, URL Shortener will now detect and use the URL generated by Shorten2Ping. (http://code.google.com/p/url-shortener-plugin/issues/detail?id=2)
     94* Added support (via Addon Module) for Digg
     95* Added support request (via Addon Module) for Voizle (http://code.google.com/p/url-shortener-plugin/issues/detail?id=1)
     96* Added ability to generate and delete Short URL in bulk.
     97* Ported the URL Generation functions into a class, allowing re-use in other plugins.
     98* Sn.im service is found to be down and marked to be removed in the next version of this plugin.
    8799
    88100= 1.7 =
    89101* Included an Addon module option
    90102* Addon functions for additional service display
     103* Added support (via Addon Module) for Goo.gl
    91104* Directory structure cleanup
     105
    92106
    93107= 1.6.3 =
  • url-shortener/trunk/req/display/fts_shortenurl.js

    r185791 r198746  
    11jQuery(document).ready(function($){
    2 
    32   
    43    $('#urlservicesel').each(function(){
     
    4039            var target = $(this).val();
    4140            if (target == "yes"){
    42                 $('#enableownservice').fadeIn(300);
     41
     42            $('#enableownservice').fadeIn(300);
    4343            } else {
    4444                $('#enableownservice').fadeOut(300);   
     
    4747        });
    4848    });
    49 
    5049
    5150    $('#ownredirecttypeoption').each(function(){
     
    7473        });
    7574    });
    76 
     75    $('#aserv-des').hide();
     76    $('#aserv').click(function(){
     77        $('#aserv-des').toggle(300);
     78        return false;
     79    });
    7780   
    7881});
    79 
  • url-shortener/trunk/req/options.php

    r185792 r198746  
    11<?php
    2 
    3 function fts_shortenurl_init(){
    4     global $globe_fts_urlfx;
    5     //name - db
    6     register_setting('fts_shortenurl','fts_urlfx');
    7     $globe_fts_urlfx = get_option('fts_urlfx');
    8 
    9 }
    10 
    112function fts_shortenurl_cssjs(){
    123    //css JS
     
    189function draw_fts_shortenurl_page(){
    1910    global $addonurl;
    20     global $globe_fts_urlfx;
     11    global $fts_urlfx;
    2112    $plugin_loc = WP_PLUGIN_URL.'/'.plugin_basename( dirname(dirname(__FILE__)) );
    2213    $plugin_logo = '<img src="'.$plugin_loc.'/plugin-logo.jpg" alt="" />';
     
    2617        <div class="logo">
    2718            <a href="http://fusedthought.com/downloads/url-shortener-wordpress-plugin/">
    28                 <?php if($globe_fts_urlfx['urlbetaservices'] == 'yes' && function_exists('fts_url_beta_logo')){
     19                <?php if($fts_urlfx['urlbetaservices'] == 'yes' && function_exists('fts_url_beta_logo')){
    2920                    fts_url_beta_logo();
    3021                }else{echo $plugin_logo; }?>
     
    3728            </ul>
    3829        </p>
    39         <p>It bring's the one-click URL Shortening functionality of WordPress.com blogs to your WordPress.org installation.</p>
    40         <p>As WP.me is exclusive to WordPress.com users, this plugin supports a variety of other URL Shortening services. </p> 
     30        <p>It bring's the one-click/automated URL Shortening functionality to your WordPress.org installation.</p>
    4131       
    4232        <form id="shorturloptions" method="post" action="options.php">
    4333            <?php settings_fields('fts_shortenurl'); ?>
    44             <?php $fts_urlfx = get_option('fts_urlfx'); ?>
    4534           
    4635            <h4 class="sectheaders">Integration Options</h4>
     
    5645           
    5746                <div id="enableurlservice" class="sub <?php if ($fts_urlfx['urlserviceenable'] != 'yes'){ echo "mhideit";} else {echo "mshowit";} ?>">
    58        
     47
    5948                    <fieldset title="URL Shortening Service">
    6049                        <label for="urlservicesel">You're using:</label>
     
    6756                            <option value="bitly" <?php selected( 'bitly', $fts_urlfx['urlservice'] ); ?>>bit.ly &nbsp;</option>
    6857                            <option value="trim" <?php selected( 'trim', $fts_urlfx['urlservice'] ); ?>>tr.im &nbsp;</option>
    69                             <option value="snipurl" <?php selected( 'snipurl', $fts_urlfx['urlservice'] ); ?>>Sn.im / Snipr / Snipurl / Snurl &nbsp;</option>
     58                            <option value="snipurl" <?php selected( 'snipurl', $fts_urlfx['urlservice'] ); ?>>Snipr / Snipurl / Snurl &nbsp;</option>
    7059                            <option value="cligs" <?php selected( 'cligs', $fts_urlfx['urlservice'] ); ?>>Cligs (Cl.gs &nbsp;)</option>
    7160                            <option value="shortie" <?php selected( 'shortie', $fts_urlfx['urlservice'] ); ?>>Short.ie &nbsp;</option>
     
    8978                            </div>
    9079                        </div>
    91                        
     80
    9281                        <div class="APIConfig">
    9382                            <div id="userkey_tinyurl" class="<?php if ($fts_urlfx['urlservice'] != 'tinyurl'){ echo "hideit";} else {echo "showit";} ?>">
     
    223212                    <fieldset>
    224213                        <div class="nl">
    225                             <label class="betaserv">Enable Addon Module (for beta features): </label>
     214                            <label class="betaserv">Enable Addon Module (for bonus/beta services): </label>
    226215                            <select name="fts_urlfx[urlbetaservices]" id="urlbetaservices" >
    227216                                <option value="no" <?php selected( 'no', $fts_urlfx['betaservices'] ); ?>>No &nbsp;</option>                           
    228217                                <option class="betaservopt" value="yes" <?php selected( 'yes', $fts_urlfx['urlbetaservices'] ); ?>>Yes &nbsp;</option>             
    229                             </select>
    230                             <p><strong>Note: </strong>The <a href="<?php print $addonurl;?>">URL Shortener Addon Module</a>  has to be enabled.</p>
     218                            </select> <a id="aserv" href="#">[?]</a>
     219                            <p><strong>Note: </strong>The <a href="<?php print $addonurl;?>">URL Shortener Addon Module</a>  has to be installed and activated.</p><p id="aserv-des" class="none">The addon module provides bonus services (highlighted in green) and beta services (highlighted in red) which are not available in the main URL Shortener Plugin.</p>
    231220                        </div>
    232221                    </fieldset>
     
    248237           
    249238                <div id="enableownservice" class="sub <?php if ($fts_urlfx['ownservice'] != 'yes'){ echo "ehideit";} else {echo "eshowit";} ?>">
    250                     <fieldset title="Own Service Options">
    251                        
     239                    <fieldset title="Own Service Options"> 
    252240                        <div id="ownredirecttype"  class="nl" >
    253241                            <label>Select type of redirect: </label>       
     
    285273            <p class="submit">
    286274                <input type="submit" id="submit-button" class="button-primary" value="<?php _e('Save Changes') ?>" />
    287             </p>
    288            
    289         </form>
    290        
     275            </p>       
     276        </form>
    291277    </div>
    292 
    293278<?php
    294279}
     
    302287
    303288function fts_shorturl_posts_metabox($post){
    304     global $globe_fts_urlfx;
     289    global $fts_urlfx;
    305290    $postid = $post->ID;
    306291    $shorturl = get_post_meta($postid, 'shorturl', true);
     292    $anothershorturl = get_post_meta($postid, 'short_url', true);
     293    if ($fts_urlfx['urlserviceenable'] == 'yes'){
    307294   
    308     if ($globe_fts_urlfx['urlserviceenable'] == 'yes'){
    309         if($globe_fts_urlfx['urlservice'] != 'none' && !$shorturl){
     295        if($fts_urlfx['urlservice'] != 'none' && !$shorturl && !$anothershorturl){
    310296            wp_nonce_field( 'fts_shortenurl', '_ajax_ftsshorturl', false );
    311297           
    312             if($globe_fts_urlfx['urlautogen'] == 'yes'){?>
     298            if($fts_urlfx['urlautogen'] == 'yes'){?>
    313299                <h4>How To:</h4>
    314300                <p>Short URL will be generated upon publishing the post/page.</p>
     
    319305                jQuery(document).ready(function($){
    320306                    $('#misc-publishing-actions').append('<div class="misc-pub-section">Short URL Generation: <strong>Auto</strong></div>');
    321        
    322                 });//global
     307                });
    323308                /* ]]> */
    324309                </script>
     
    338323   
    339324            <?php }//sutogen
    340         } elseif($globe_fts_urlfx['urlservice'] != 'none') { ?>
     325
     326        } elseif($fts_urlfx['urlservice'] != 'none' ) {     
     327            if($shorturl){
     328                $displayshorturl = $shorturl;
     329            } else {
     330                $displayshorturl = $anothershorturl;
     331            }?>
    341332               
    342333            <div style="text-align: left;">
    343                 <p id="shortlinkstatus"><strong>Your current short URL is: </strong><br /><a href="<?php echo $shorturl;?>"><?php echo $shorturl;?></a></p>
    344                 <p style="text-align: right"><input type="submit" class="button" id="remove-shortlink-button" name="remove-shortlink" value="Remove Short URL" /></p>
     334                <p id="shortlinkstatus"><strong>Your current short URL is: </strong><br /><a href="<?php echo $displayshorturl;?>"><?php echo $displayshorturl;?></a></p><p style="text-align: right"><input type="submit" class="button" id="remove-shortlink-button" name="remove-shortlink" value="Remove Short URL" /></p>
    345335            </div>
    346336            <script type="text/javascript">
     
    348338            jQuery(document).ready(function($){
    349339                <?php if (!function_exists('get_shortlink') ){?>       
    350                     $('#edit-slug-box').append('<span id="show-shortlink-button"><a class="button" href="#">Show Short URL</a></span>');   
     340                    $('#edit-slug-box').append('<span class="show-shortlink-button"><a class="button" href="#">Show Short URL</a></span>');
    351341                <?php }?>
    352                 $('#misc-publishing-actions').append('<div class="misc-pub-section"><div id="shortlinkstatustop" style="display: inline;">Short URL Status: <strong id="show-shortlink-button"><a href="#">Generated</a></strong></div>&nbsp;<input type="submit" class="button" name="remove-shortlink" id="remove-shortlink-button1" value="Remove" /></div>');
     342                $('#misc-publishing-actions').append('<div class="misc-pub-section"><div id="shortlinkstatustop" style="display: inline;">Short URL Status: <strong class="show-shortlink-button"><a href="#">Generated</a></strong></div>&nbsp;<input type="submit" class="button" name="remove-shortlink" id="remove-shortlink-button1" value="Remove" /></div>');
    353343               
    354                 $('#show-shortlink-button a').click(function(){
    355                     prompt('Short URL:', '<?php echo $shorturl; ?>');
     344                $('.show-shortlink-button a').click(function(){
     345                    prompt('Short URL:', '<?php echo $displayshorturl; ?>');
    356346                    return false;
    357347                });
     
    364354                    $('#shortlinkstatustop').html('Shortlink Status: <strong>Removing....</strong>');
    365355                    return true;
    366                 });
    367                
     356                });     
    368357            });
    369358            /* ]]> */
    370359            </script>
    371360        <?php
     361       
    372362        } else {/*end urlservice else*/?>
    373363        <h4>Plugin Not Configured</h4>
     
    396386
    397387if ( is_admin() ){
    398     add_action('admin_init', 'fts_shortenurl_init');
    399388    add_action('load-post.php', 'fts_shorturl_posts_addons');
    400389    add_action('load-post-new.php', 'fts_shorturl_posts_addons');
Note: See TracChangeset for help on using the changeset viewer.