From 185c9d6fec894aa9b7a5ebabd5a31a8335620862 Mon Sep 17 00:00:00 2001 From: ozh Date: Sat, 25 Oct 2014 10:04:37 +0200 Subject: [PATCH] Readable JS code for bookmarklets, hell yeah. Fixes #1710. --- admin/tools.php | 245 ++++++++++++++++++++++++++++++++---- includes/functions-html.php | 21 ++++ 2 files changed, 244 insertions(+), 22 deletions(-) diff --git a/admin/tools.php b/admin/tools.php index e7f8483..ca775b4 100644 --- a/admin/tools.php +++ b/admin/tools.php @@ -31,10 +31,12 @@ ?>

+ +

- - + +
@@ -45,34 +47,235 @@ - - - + + + + + + - - + + + + +
 
+ + + +
+ + + +
- + +

+ +

+ + + -

- - - - - - - - - + +

@@ -98,10 +301,8 @@ yourls_e( "If you're worried about sending your credentials into the wild, you can also make API calls without using your login or your password, using a secret signature token." ); ?>

-

%s', yourls_auth_signature() ); - yourls_e( "(It's a secret. Keep it secret) "); - ?>

+

%s', yourls_auth_signature() ); ?> +

diff --git a/includes/functions-html.php b/includes/functions-html.php index 176829a..24c086e 100644 --- a/includes/functions-html.php +++ b/includes/functions-html.php @@ -928,3 +928,24 @@ function yourls_get_search_text() { return htmlspecialchars( trim( $search ) ); } + +/** + * Display or return HTML for a bookmarklet link + * + * @since 1.7.1 + * @param string $href bookmarklet link (presumably minified code with "javascript:" scheme) + * @param string $anchor link anchor + * @param bool $echo true to display, false to return the HTML + * @return string the HTML for a bookmarklet link + */ +function yourls_bookmarklet_link( $href, $anchor, $echo = true ) { + $alert = yourls_esc_attr__( 'Drag to your toolbar!' ); + $link = <<$anchor +LINK; + + if( $echo ) + echo $link; + return $link; +} + -- 2.45.0