-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
plugin.php
37 lines (32 loc) · 1.58 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/*
Plugin Name: Force Lowercase
Plugin URI: http://yourls.org/
Description: Force lowercase so http://sho.rt/ABC == http://sho.rt/abc
Version: 1.0
Author: Ozh
Author URI: http://ozh.org/
*/
/*********************************************************************************
* DISCLAIMER *
* This is stupid. The web is case sensitive and http://bit.ly/BLAH is different *
* from http://bit.ly/blah. Deal with it. More about this: see *
* http://www.w3.org/TR/WD-html40-970708/htmlweb.html *
* *
* This said, lots of users are pestering me for that kind of plugin, so there *
* it is. Have fun breaking the web! :) *
*********************************************************************************/
// Redirection: http://sho.rt/ABC first converted to http://sho.rt/abc
yourls_add_filter( 'get_request', 'ozh_break_the_web_lowercase' );
function ozh_break_the_web_lowercase( $keyword ){
return strtolower( $keyword );
}
// Short URL creation: custom keyword 'ABC' converted to 'abc'
yourls_add_action( 'add_new_link_custom_keyword', 'ozh_break_the_web_add_filter' );
function ozh_break_the_web_add_filter() {
yourls_add_filter( 'get_shorturl_charset', 'ozh_break_the_web_add_uppercase' );
yourls_add_filter( 'custom_keyword', 'ozh_break_the_web_lowercase' );
}
function ozh_break_the_web_add_uppercase( $charset ) {
return $charset . strtoupper( $charset );
}