1 | <?php |
||
2 | /* |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
3 | Plugin Name: Random Backgrounds |
||
0 ignored issues
–
show
|
|||
4 | Plugin URI: http://yourls.org/ |
||
0 ignored issues
–
show
|
|||
5 | Description: Pretty random background patterns |
||
0 ignored issues
–
show
|
|||
6 | Version: 1.0 |
||
0 ignored issues
–
show
|
|||
7 | Author: Ozh |
||
0 ignored issues
–
show
|
|||
8 | Author URI: http://ozh.org/ |
||
0 ignored issues
–
show
|
|||
9 | */ |
||
10 | |||
11 | // No direct call |
||
12 | if( !defined( 'YOURLS_ABSPATH' ) ) die(); |
||
13 | |||
14 | // Add the inline style |
||
15 | yourls_add_action( 'html_head', 'ozh_yourls_randombg' ); |
||
16 | function ozh_yourls_randombg() { |
||
17 | $bg = glob( __DIR__.'/img/*png' ); |
||
18 | $url = yourls_plugin_url( __DIR__ ); |
||
19 | $rnd = yourls_plugin_url( $bg[ mt_rand( 0, count( $bg ) - 1 ) ] ); |
||
20 | echo <<<CSS |
||
21 | <style type="text/css"> |
||
22 | body {background:#e3f3ff url($rnd) repeat;} |
||
23 | </style> |
||
24 | |||
25 | CSS; |
||
26 | } |
||
27 | |||
28 |