-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-bypass-transients-debug-bar.php
55 lines (49 loc) · 1.78 KB
/
class-bypass-transients-debug-bar.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
47
48
49
50
51
52
53
54
55
<?php
class Bypass_Transients_Debug_Bar extends \Debug_Bar_Panel {
public function init() {
$this->title( __( 'Bypass Transients' ) );
}
/**
* Renders the page
*/
public function render() {
?>
<div id="bypass-transient-information">
<?php
$this->output_transients( 'suspended' );
$this->output_transients( 'found' );
$this->output_transients( 'known' );
?>
</div>
<?php
}
function output_transients( $type = 'known' ) {
global $bypass_transients;
switch ( $type ) {
case 'suspended':
$transients = $bypass_transients->get_bypassed_transients();
$number_of_transients = count( $transients );
$message = sprintf( _n( 'There was %s transient bypassed for this page load.', 'There were %s transients bypassed for this page load.', $number_of_transients ), $number_of_transients );
break;
case 'found':
$transients = $bypass_transients->get_found_transients();
$number_of_transients = count( $transients );
$message = sprintf( _n( 'There was %s transient found for this page load.', 'There were %s transients found for this page load.', $number_of_transients ), $number_of_transients );
break;
case 'known':
$transients = $bypass_transients->get_known_transients();
$number_of_transients = count( $transients );
$message = sprintf( _n( 'There is %s known transient for the active theme/plugins.', 'There are %s known transients for the active theme/plugins.', $number_of_transients ), $number_of_transients );
break;
default:
$message = 'Unknown $type parameter';
$transients = array();
}
?>
<h4><?php echo esc_html( $message );?></h4>
<?php
if ( ! empty( $transients ) ) {
echo "<pre>\n" . print_r( $transients,1 ) .'</pre>';
}
}
}