Changeset 198746
- Timestamp:
- 01/27/2010 12:47:39 PM (16 years ago)
- Location:
- url-shortener/trunk
- Files:
-
- 11 added
- 1 deleted
- 4 edited
-
fts-shortenurl-logic.php (added)
-
fts-shortenurl.php (modified) (4 diffs)
-
readme.txt (modified) (5 diffs)
-
req/addtable.php (added)
-
req/class.FTShorten.php (added)
-
req/components (added)
-
req/components/class.json.php (added)
-
req/components/fx.snipurl.php (added)
-
req/components/inc.FTShortenShared.php (added)
-
req/display/editcolumn.js (added)
-
req/display/fts_shortenurl.js (modified) (4 diffs)
-
req/options.php (modified) (16 diffs)
-
req/services (deleted)
-
req/templateredirect.php (added)
-
req/wprewriteredirect.php (added)
-
screenshot-4.jpg (added)
Legend:
- Unmodified
- Added
- Removed
-
url-shortener/trunk/fts-shortenurl.php
r185791 r198746 6 6 Author: Gerald Yeo 7 7 Author URI: http://fusedthought.com 8 Version: 1.78 Version: 2.0 9 9 */ 10 10 … … 14 14 */ 15 15 16 global $ globe_fts_urlfx;16 global $fts_urlfx; 17 17 global $addonurl; 18 18 $addonurl = "http://fusedthought.com/downloads/addon-module-for-url-shortener-wordpress-plugin/"; 19 19 20 require_once( dirname(__FILE__) . '/req/urlservices.php' ); 20 function 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 } 26 if ( is_admin() ){ 27 add_action('admin_init', 'fts_shortenurl_init'); 28 } 29 require_once( dirname(__FILE__) . '/req/class.FTShorten.php' ); 21 30 require_once( dirname(__FILE__) . '/req/options.php' ); 22 require_once( dirname(__FILE__) . '/req/services/wprewriteredirect.php' ); 23 require_once( dirname(__FILE__) . '/req/services/templateredirect.php' ); 31 require_once( dirname(__FILE__) . '/req/wprewriteredirect.php' ); 32 require_once( dirname(__FILE__) . '/req/templateredirect.php' ); 33 require_once( dirname(__FILE__) . '/req/addtable.php' ); 24 34 25 35 function fts_show_shorturl($post){ 26 36 $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 } 28 41 echo $the_shorturl; 29 42 } 30 43 31 function fts_shorturl($ url, $api){44 function fts_shorturl($posturl, $api){ 32 45 $api = strip_tags($api); 33 46 $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; 36 50 } 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 testing50 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 65 51 66 52 function fts_shortenurl_remove($post_ID){ … … 75 61 } 76 62 77 function fts_shortenurl_future($post){ 78 $fts_urlfx = get_option('fts_urlfx'); 63 function 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 } 90 function fts_shortenurl_gateway($post){ 91 global $fts_urlfx; 79 92 $postid = $post->ID; 80 93 $customyes = $_POST['get-shortlink']; 94 $typeofpost = $_POST['post_type']; 81 95 $shorturl = get_post_meta($postid, 'shorturl', true); 82 96 if ($fts_urlfx['urlserviceenable'] == 'yes'){ 83 97 if($fts_urlfx['urlservice'] != 'none' && !$shorturl){ 84 98 if($fts_urlfx['urlautogen'] == 'yes'){ 85 fts_shortenurl($postid );99 fts_shortenurl($postid, $typeofpost); 86 100 } elseif($fts_urlfx['urlautogen'] == 'no' && $customyes == 'Enabled'){ 87 fts_shortenurl($postid );101 fts_shortenurl($postid, $typeofpost); 88 102 }else{}; 89 103 } … … 92 106 93 107 // Hooks 94 add_action('wp_ajax_getshortlink', 'fts_shortenurl_get' );95 add_action('wp_ajax_removeshortlink', 'fts_shortenurl_remove' );96 108 add_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'); 109 add_action('publish_to_publish', 'fts_shortenurl_gateway', 15); 110 add_action('draft_to_publish', 'fts_shortenurl_gateway', 15); 111 add_action('private_to_publish', 'fts_shortenurl_gateway', 15); 112 add_action('future_to_publish', 'fts_shortenurl_gateway', 15); 113 add_action('pending_to_publish', 'fts_shortenurl_gateway', 15); 114 add_action('new_to_publish', 'fts_shortenurl_gateway', 15); 105 115 add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'fts_shortenurl_actions', -10); 106 116 ?> -
url-shortener/trunk/readme.txt
r185803 r198746 2 2 Contributors: geraldyeo 3 3 Donate 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 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, digg, Voizle 5 5 Requires at least: 2.7 6 Tested up to: 2.9 7 Stable tag: 1.76 Tested up to: 2.9.1 7 Stable tag: 2.0 8 8 9 9 Use your own URL Shortener or integrate 3rd Party Services with WordPress. Allows generating of shorturl with various services upon post/page publishing. … … 19 19 `<?php fts_show_shorturl($post); ?>` 20 20 21 22 As of Version 1.5, I've added an on-demand shortening function for use in the templates: 21 On-demand shortening function (V1.5) is also for use in your templates: 23 22 24 23 `<?php fts_shorturl('http://www.google.com', 'supr'); ?>` 25 24 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:** 33 26 34 27 * tinyurl … … 38 31 * tr.im 39 32 * short.ie 40 * snipurl (aka Snurl / Snipr / Sn.im)33 * snipurl (aka Snurl / Snipr) 41 34 * cl.gs 42 35 * short.to … … 57 50 58 51 * goo.gl (Google URL Shortener) 52 * Digg 53 * Voizle 54 55 56 **Highlights:** 57 58 Version 1.5 also brings about an updated administration options page. 59 60 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") 61 62 Version 2.0 now supports bulk editing and generation of Short URLs. 59 63 60 64 61 65 **Future Versions:** 62 66 63 * I am still looking into creating a URL Management page to manage all the generated URLs within the site.64 67 * Twitter and Facebook posting integration? 65 68 * More services can be added upon request. … … 82 85 1. plugin admin interface (ver 1.4) 83 86 1. plugin admin interface (ver 1.5) 84 87 1. bulk editing options (ver 2.0) 85 88 86 89 == 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. 87 99 88 100 = 1.7 = 89 101 * Included an Addon module option 90 102 * Addon functions for additional service display 103 * Added support (via Addon Module) for Goo.gl 91 104 * Directory structure cleanup 105 92 106 93 107 = 1.6.3 = -
url-shortener/trunk/req/display/fts_shortenurl.js
r185791 r198746 1 1 jQuery(document).ready(function($){ 2 3 2 4 3 $('#urlservicesel').each(function(){ … … 40 39 var target = $(this).val(); 41 40 if (target == "yes"){ 42 $('#enableownservice').fadeIn(300); 41 42 $('#enableownservice').fadeIn(300); 43 43 } else { 44 44 $('#enableownservice').fadeOut(300); … … 47 47 }); 48 48 }); 49 50 49 51 50 $('#ownredirecttypeoption').each(function(){ … … 74 73 }); 75 74 }); 76 75 $('#aserv-des').hide(); 76 $('#aserv').click(function(){ 77 $('#aserv-des').toggle(300); 78 return false; 79 }); 77 80 78 81 }); 79 -
url-shortener/trunk/req/options.php
r185792 r198746 1 1 <?php 2 3 function fts_shortenurl_init(){4 global $globe_fts_urlfx;5 //name - db6 register_setting('fts_shortenurl','fts_urlfx');7 $globe_fts_urlfx = get_option('fts_urlfx');8 9 }10 11 2 function fts_shortenurl_cssjs(){ 12 3 //css JS … … 18 9 function draw_fts_shortenurl_page(){ 19 10 global $addonurl; 20 global $ globe_fts_urlfx;11 global $fts_urlfx; 21 12 $plugin_loc = WP_PLUGIN_URL.'/'.plugin_basename( dirname(dirname(__FILE__)) ); 22 13 $plugin_logo = '<img src="'.$plugin_loc.'/plugin-logo.jpg" alt="" />'; … … 26 17 <div class="logo"> 27 18 <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')){ 29 20 fts_url_beta_logo(); 30 21 }else{echo $plugin_logo; }?> … … 37 28 </ul> 38 29 </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> 41 31 42 32 <form id="shorturloptions" method="post" action="options.php"> 43 33 <?php settings_fields('fts_shortenurl'); ?> 44 <?php $fts_urlfx = get_option('fts_urlfx'); ?>45 34 46 35 <h4 class="sectheaders">Integration Options</h4> … … 56 45 57 46 <div id="enableurlservice" class="sub <?php if ($fts_urlfx['urlserviceenable'] != 'yes'){ echo "mhideit";} else {echo "mshowit";} ?>"> 58 47 59 48 <fieldset title="URL Shortening Service"> 60 49 <label for="urlservicesel">You're using:</label> … … 67 56 <option value="bitly" <?php selected( 'bitly', $fts_urlfx['urlservice'] ); ?>>bit.ly </option> 68 57 <option value="trim" <?php selected( 'trim', $fts_urlfx['urlservice'] ); ?>>tr.im </option> 69 <option value="snipurl" <?php selected( 'snipurl', $fts_urlfx['urlservice'] ); ?>>Sn .im / Snipr / Snipurl / Snurl </option>58 <option value="snipurl" <?php selected( 'snipurl', $fts_urlfx['urlservice'] ); ?>>Snipr / Snipurl / Snurl </option> 70 59 <option value="cligs" <?php selected( 'cligs', $fts_urlfx['urlservice'] ); ?>>Cligs (Cl.gs )</option> 71 60 <option value="shortie" <?php selected( 'shortie', $fts_urlfx['urlservice'] ); ?>>Short.ie </option> … … 89 78 </div> 90 79 </div> 91 80 92 81 <div class="APIConfig"> 93 82 <div id="userkey_tinyurl" class="<?php if ($fts_urlfx['urlservice'] != 'tinyurl'){ echo "hideit";} else {echo "showit";} ?>"> … … 223 212 <fieldset> 224 213 <div class="nl"> 225 <label class="betaserv">Enable Addon Module (for b eta features): </label>214 <label class="betaserv">Enable Addon Module (for bonus/beta services): </label> 226 215 <select name="fts_urlfx[urlbetaservices]" id="urlbetaservices" > 227 216 <option value="no" <?php selected( 'no', $fts_urlfx['betaservices'] ); ?>>No </option> 228 217 <option class="betaservopt" value="yes" <?php selected( 'yes', $fts_urlfx['urlbetaservices'] ); ?>>Yes </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> 231 220 </div> 232 221 </fieldset> … … 248 237 249 238 <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"> 252 240 <div id="ownredirecttype" class="nl" > 253 241 <label>Select type of redirect: </label> … … 285 273 <p class="submit"> 286 274 <input type="submit" id="submit-button" class="button-primary" value="<?php _e('Save Changes') ?>" /> 287 </p> 288 289 </form> 290 275 </p> 276 </form> 291 277 </div> 292 293 278 <?php 294 279 } … … 302 287 303 288 function fts_shorturl_posts_metabox($post){ 304 global $ globe_fts_urlfx;289 global $fts_urlfx; 305 290 $postid = $post->ID; 306 291 $shorturl = get_post_meta($postid, 'shorturl', true); 292 $anothershorturl = get_post_meta($postid, 'short_url', true); 293 if ($fts_urlfx['urlserviceenable'] == 'yes'){ 307 294 308 if ($globe_fts_urlfx['urlserviceenable'] == 'yes'){ 309 if($globe_fts_urlfx['urlservice'] != 'none' && !$shorturl){ 295 if($fts_urlfx['urlservice'] != 'none' && !$shorturl && !$anothershorturl){ 310 296 wp_nonce_field( 'fts_shortenurl', '_ajax_ftsshorturl', false ); 311 297 312 if($ globe_fts_urlfx['urlautogen'] == 'yes'){?>298 if($fts_urlfx['urlautogen'] == 'yes'){?> 313 299 <h4>How To:</h4> 314 300 <p>Short URL will be generated upon publishing the post/page.</p> … … 319 305 jQuery(document).ready(function($){ 320 306 $('#misc-publishing-actions').append('<div class="misc-pub-section">Short URL Generation: <strong>Auto</strong></div>'); 321 322 });//global 307 }); 323 308 /* ]]> */ 324 309 </script> … … 338 323 339 324 <?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 }?> 341 332 342 333 <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> 345 335 </div> 346 336 <script type="text/javascript"> … … 348 338 jQuery(document).ready(function($){ 349 339 <?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>'); 351 341 <?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> <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> <input type="submit" class="button" name="remove-shortlink" id="remove-shortlink-button1" value="Remove" /></div>'); 353 343 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; ?>'); 356 346 return false; 357 347 }); … … 364 354 $('#shortlinkstatustop').html('Shortlink Status: <strong>Removing....</strong>'); 365 355 return true; 366 }); 367 356 }); 368 357 }); 369 358 /* ]]> */ 370 359 </script> 371 360 <?php 361 372 362 } else {/*end urlservice else*/?> 373 363 <h4>Plugin Not Configured</h4> … … 396 386 397 387 if ( is_admin() ){ 398 add_action('admin_init', 'fts_shortenurl_init');399 388 add_action('load-post.php', 'fts_shorturl_posts_addons'); 400 389 add_action('load-post-new.php', 'fts_shorturl_posts_addons');
Note: See TracChangeset
for help on using the changeset viewer.