| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if( ! class_exists( 'MywpDeveloperAbstractModule' ) ) { |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
if ( ! class_exists( 'MywpDeveloperModuleMywpCache' ) ) : |
| 12 |
|
| 13 |
final class MywpDeveloperModuleMywpCache extends MywpDeveloperAbstractModule { |
| 14 |
|
| 15 |
static protected $id = 'mywp_cache'; |
| 16 |
|
| 17 |
static protected $priority = 120; |
| 18 |
|
| 19 |
public static function mywp_debug_renders( $debug_renders ) { |
| 20 |
|
| 21 |
$debug_renders[ self::$id ] = array( |
| 22 |
'debug_type' => 'mywp', |
| 23 |
'title' => __( 'Cache' , 'my-wp' ), |
| 24 |
); |
| 25 |
|
| 26 |
return $debug_renders; |
| 27 |
|
| 28 |
} |
| 29 |
|
| 30 |
private static function get_caches() { |
| 31 |
|
| 32 |
$mywp_cache = new MywpCache( 'all_cache' ); |
| 33 |
|
| 34 |
return $mywp_cache->get_cache(); |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
protected static function mywp_developer_debug() { |
| 39 |
|
| 40 |
if( ! MywpDeveloper::is_debug_item( 'mywp_cache' ) ) { |
| 41 |
|
| 42 |
echo esc_html( __( 'Not activated.' , 'my-wp' ) ); |
| 43 |
|
| 44 |
return false; |
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
$caches = self::get_caches(); |
| 49 |
|
| 50 |
echo 'Mywp caches = '; |
| 51 |
|
| 52 |
foreach( $caches as $cache_key => $cache ) { |
| 53 |
|
| 54 |
echo esc_html( $cache_key . ' = ' ); |
| 55 |
echo esc_html( print_r( $cache , true ) ); |
| 56 |
echo "\n"; |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
protected static function mywp_debug_render() { |
| 63 |
|
| 64 |
if( ! MywpDeveloper::is_debug_item( 'mywp_cache' ) ) { |
| 65 |
|
| 66 |
echo esc_html( __( 'Not activated.' , 'my-wp' ) ); |
| 67 |
|
| 68 |
return false; |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
$caches = self::get_caches(); |
| 74 |
|
| 75 |
if( empty( $caches ) ) { |
| 76 |
|
| 77 |
return false; |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
echo '<ul>'; |
| 82 |
|
| 83 |
foreach( $caches as $cache_key => $cache ) { |
| 84 |
|
| 85 |
printf( '<li>%s = <textarea readonly="readonly">%s</textarea></li>' , esc_html($cache_key ) , esc_textarea( print_r( $cache , true ) ) ); |
| 86 |
|
| 87 |
} |
| 88 |
|
| 89 |
echo '</ul>'; |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
MywpDeveloperModuleMywpCache::init(); |
| 96 |
|
| 97 |
endif; |
| 98 |
|