forked from YOURLS/random-keywords
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.php
42 lines (35 loc) · 982 Bytes
/
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
37
38
39
40
41
42
<?php
/*
Plugin Name: Random Keywords
Plugin URI: http://yourls.org/
Description: Assign random keywords to shorturls, like bitly (sho.rt/hJudjK)
Version: 1.1
Author: Ozh
Author URI: http://ozh.org/
*/
/* Release History:
*
* 1.0 Initial release
* 1.1 Added: don't increment sequential keyword counter & save one SQL query
* Fixed: plugin now complies to character set defined in config.php
*/
global $ozh_random_keyword;
/*
* CONFIG: EDIT THIS
*/
/* Length of random keyword */
$ozh_random_keyword['length'] = 5;
/*
* DO NOT EDIT FARTHER
*/
// Generate a random keyword
yourls_add_filter( 'random_keyword', 'ozh_random_keyword' );
function ozh_random_keyword() {
global $ozh_random_keyword;
return yourls_rnd_string( $ozh_random_keyword['length'] );
}
// Don't increment sequential keyword tracker
yourls_add_filter( 'get_next_decimal', 'ozh_random_keyword_next_decimal' );
function ozh_random_keyword_next_decimal( $next ) {
return ( $next - 1 );
}