-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathwp-less-admin.class.php
More file actions
70 lines (59 loc) · 1.6 KB
/
wp-less-admin.class.php
File metadata and controls
70 lines (59 loc) · 1.6 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
class wp_less_admin {
/**
* @static
* @var \wp_less_admin Reusable object instance.
*/
protected static $instance = null;
/**
* Creates a new instance. Called on 'after_setup_theme'.
* May be used to access class methods from outside.
*
* @see __construct()
* @static
* @return \wp_less_admin
*/
public static function instance() {
null === self :: $instance AND self :: $instance = new self;
return self :: $instance;
}
public function __construct() {
add_action( 'admin_menu', array( $this, 'add_pages' ) );
}
public function add_pages() {
add_management_page( 'WP LESS', 'WP LESS', 'manage_options', 'wpless', array( $this, 'display' ) );
}
public function display() {
?>
<div class="wrap">
<h2>WP-LESS</h2>
<p>Here are messages from attempts to build/rebuild stylesheets. Only the last 20 messages are kept.</p>
<table class="wp-list-table widefat fixed">
<thead>
<th width="120px">Time</th>
<th>Message</th>
</thead>
<tbody>
<?php
$recent_messages = get_option('wpless-recent-messages');
if ( !empty( $recent_messages ) ) {
foreach ( $recent_messages as $message ) {
echo '<tr>';
if ( is_array( $message ) ) {
echo '<td>'.date( 'D, d M Y H:i:s', absint( $message['time'] ) ).'</td>';
echo '<td>'.wp_strip_all_tags( $message['payload'] ).'</td>';
} else {
echo '<td colspan="2">'.wp_strip_all_tags( $message ).'</td>';
}
echo '</tr>';
}
} else {
echo '<tr><td colspan="2">No messages</td></tr>';
}
?>
</tbody>
</table>
</div>
<?php
}
}