diff --git a/user/plugins/case-insensitive/plugin.php b/user/plugins/case-insensitive/plugin.php new file mode 100644 index 0000000..97f4d75 --- /dev/null +++ b/user/plugins/case-insensitive/plugin.php @@ -0,0 +1,31 @@ +Sean's QR Code plugin +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; +}