forked from staylor/minify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
46 lines (42 loc) · 1.15 KB
/
admin.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
43
44
45
46
<?php
class MinifyAdmin {
function __construct() {
add_action( 'admin_menu', array( $this, 'page' ) );
}
/* @TODO use the options API */
function page() {
$hook = add_menu_page(
__( 'Minify', MINIFY_SLUG ),
__( 'Minify', MINIFY_SLUG ),
'manage_options',
MINIFY_SLUG,
array( $this, 'admin' )
);
add_action( 'load-' . $hook, array( $this, 'load' ) );
}
/* @TODO: Nonce */
/* @TODO: Sanitize input */
function load() {
if ( !empty( $_POST[ 'incr' ] ) ) {
$incr = get_site_option( MINIFY_INCR_KEY );
update_site_option( MINIFY_INCR_KEY_PREV, $incr );
update_site_option( MINIFY_INCR_KEY, trim( $_POST[ 'incr' ] ) );
wp_redirect( menu_page_url( MINIFY_SLUG, false ) );
exit();
}
}
function admin() {
$incr = get_site_option( MINIFY_INCR_KEY );
?>
<div class="wrap">
<h2>Minify</h2>
<form action="<?php menu_page_url( MINIFY_SLUG ) ?>" method="post">
<p>Cache-buster value<p>
<p><input type="text" name="incr" class="widefat" value="<?php echo esc_attr( $incr ) ?>" /></p>
<p><input type="submit" value="Change Cache Buster"/></p>
</form>
</div>
<?php
}
}
new MinifyAdmin;