From a3e8146d1d2888d98dd520dbf1084124a1fe2fae Mon Sep 17 00:00:00 2001 From: ozhozh Date: Tue, 29 Dec 2009 10:26:20 +0000 Subject: [PATCH] Cleaner function: yourls_link() git-svn-id: http://yourls.googlecode.com/svn/trunk@255 12232710-3e20-11de-b438-597f59cd7555 --- includes/functions.php | 10 ++++++++++ yourls-infos.php | 12 ++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 31307c2..207502d 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -32,6 +32,11 @@ function yourls_sanitize_string($in) { return substr(preg_replace('/[^a-zA-Z0-9]/', '', $in), 0, 199); } +// Alias function. I was always getting it wrong. +function yourls_sanitize_keyword( $keyword ) { + return yourls_sanitize_string( $keyword ); +} + // A few sanity checks on the URL function yourls_sanitize_url($url) { // make sure there's only one 'http://' at the beginning (prevents pasting a URL right after the default 'http://') @@ -1218,4 +1223,9 @@ function yourls_has_interface() { if( yourls_is_API() or yourls_is_GO() or yourls_is_Ajax() ) return false; return true; +} + +// Converts keyword into short link +function yourls_link( $keyword = '' ) { + return YOURLS_SITE . '/' . yourls_sanitize_keyword( $keyword ); } \ No newline at end of file diff --git a/yourls-infos.php b/yourls-infos.php index 096bca3..4ab36d4 100644 --- a/yourls-infos.php +++ b/yourls-infos.php @@ -176,17 +176,17 @@ foreach( $keyword_list as $k ) { $i++; if ( $i == 1 ) { - yourls_html_link( YOURLS_SITE."/$k" ); + yourls_html_link( yourls_link($k) ); } else { - yourls_html_link( YOURLS_SITE."/$k", "/$k" ); + yourls_html_link( yourls_link($k), "/$k" ); } if ( $i < count( $keyword_list ) ) echo ' + '; } } else { - yourls_html_link( YOURLS_SITE."/$keyword" ); + yourls_html_link( yourls_link($keyword) ); if( count( $keyword_list ) > 1 ) - echo ' '; + echo ' '; } ?>

Long URL:

@@ -522,11 +522,11 @@

Share

- Short link', '

Quick Share

'); ?> + Short link', '

Quick Share

'); ?>
- \ No newline at end of file + -- 2.45.0