Update plugin.php
This commit is contained in:
parent
a80a7acc93
commit
accd027915
14
plugin.php
14
plugin.php
@ -11,25 +11,25 @@ Author URI: https://dennydai.github.io
|
||||
// EDIT THIS
|
||||
|
||||
// Character to add to a short URL to trigger the preview interruption
|
||||
define( 'OZH_PREVIEW_CHAR', '~' );
|
||||
define( 'DD_PREVIEW_CHAR', '~' );
|
||||
|
||||
// DO NO EDIT FURTHER
|
||||
|
||||
// Handle failed loader request and check if there's a ~
|
||||
yourls_add_action( 'loader_failed', 'ozh_preview_loader_failed' );
|
||||
function ozh_preview_loader_failed( $args ) {
|
||||
yourls_add_action( 'loader_failed', 'dd_preview_loader_failed' );
|
||||
function dd_preview_loader_failed( $args ) {
|
||||
$request = $args[0];
|
||||
$pattern = yourls_make_regexp_pattern( yourls_get_shorturl_charset() );
|
||||
if( preg_match( "@^([$pattern]+)".OZH_PREVIEW_CHAR."$@", $request, $matches ) ) {
|
||||
if( preg_match( "@^([$pattern]+)".DD_PREVIEW_CHAR."$@", $request, $matches ) ) {
|
||||
$keyword = isset( $matches[1] ) ? $matches[1] : '';
|
||||
$keyword = yourls_sanitize_keyword( $keyword );
|
||||
ozh_preview_show( $keyword );
|
||||
dd_preview_show( $keyword );
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// Show the preview screen for a short URL
|
||||
function ozh_preview_show( $keyword ) {
|
||||
function dd_preview_show( $keyword ) {
|
||||
require_once( YOURLS_INC.'/functions-html.php' );
|
||||
|
||||
yourls_html_head( 'preview', 'Short URL preview' );
|
||||
@ -38,7 +38,7 @@ function ozh_preview_show( $keyword ) {
|
||||
$title = yourls_get_keyword_title( $keyword );
|
||||
$url = yourls_get_keyword_longurl( $keyword );
|
||||
$base = YOURLS_SITE;
|
||||
$char = OZH_PREVIEW_CHAR;
|
||||
$char = DD_PREVIEW_CHAR;
|
||||
$qrcode = 'data:image/png;base64,'.base64_encode(file_get_contents('http://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=M&chl='.YOURLS_SITE.'/'.$keyword));
|
||||
|
||||
echo <<<HTML
|
||||
|
Loading…
Reference in New Issue
Block a user