Skip to content

Commit

Permalink
Merge pull request #72 from UTCWeb/develop
Browse files Browse the repository at this point in the history
20240110-1329
  • Loading branch information
UTCGilligan authored Jan 10, 2024
2 parents 38c629d + 1d96a61 commit 89cdd6a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions user/plugins/case-insensitive/plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/*
Plugin Name: Case Insensitive
Plugin URI: https://github.com/seandrickson/YOURLS-Case-Insensitive
Description: Makes all keywords case-insensitive (creates all keywords and calls lowercase.) Just a copy of Ozh's version, but made to work with <a href="https://github.com/seandrickson/YOURLS-QRCode-Plugin">Sean's QR Code plugin</a>
Version: 1.0
Author: Sean Hendrickson
Author URI: https://github.com/seandrickson
*/

// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();


// Redirection: http://sho.rt/ABC first converted to http://sho.rt/abc
yourls_add_filter( 'get_request', 'sean_convert_to_lowercase' );
function sean_convert_to_lowercase( $keyword ) {
return (YOURLS_URL_CONVERT==36) ? $keyword=strtolower($keyword) : $keyword;
}


// Short URL creation: custom keyword 'ABC' converted to 'abc'
yourls_add_action( 'add_new_link_custom_keyword', 'sean_case_insensitive_add_filter' );
function sean_case_insensitive_add_filter() {
yourls_add_filter( 'get_shorturl_charset', 'sean_allow_capitals' );
yourls_add_filter( 'custom_keyword', 'sean_convert_to_lowercase' );
}

function sean_allow_capitals( $charset ) {
return (YOURLS_URL_CONVERT==36) ? $charset=$charset.strtoupper($charset) : $charset;
}

0 comments on commit 89cdd6a

Please sign in to comment.