| 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( 'MywpDeveloperModuleDevRequest' ) ) : |
| 12 |
|
| 13 |
final class MywpDeveloperModuleDevRequest extends MywpDeveloperAbstractModule { |
| 14 |
|
| 15 |
static protected $id = 'dev_request'; |
| 16 |
|
| 17 |
static protected $priority = 80; |
| 18 |
|
| 19 |
public static function mywp_debug_renders( $debug_renders ) { |
| 20 |
|
| 21 |
$debug_renders[ self::$id ] = array( |
| 22 |
'debug_type' => 'dev', |
| 23 |
'title' => __( 'Request' , 'my-wp' ), |
| 24 |
); |
| 25 |
|
| 26 |
return $debug_renders; |
| 27 |
|
| 28 |
} |
| 29 |
|
| 30 |
protected static function get_debug_lists() { |
| 31 |
|
| 32 |
global $wpdb; |
| 33 |
global $wp; |
| 34 |
global $wp_query; |
| 35 |
global $wp_rewrite; |
| 36 |
global $wp_locale; |
| 37 |
|
| 38 |
$debug_lists = array( |
| 39 |
'DOING_AJAX' => defined( 'DOING_AJAX' ), |
| 40 |
'DOING_CRON' => defined( 'DOING_CRON' ), |
| 41 |
'XMLRPC_REQUEST' => defined( 'XMLRPC_REQUEST' ), |
| 42 |
'REST_REQUEST' => defined( 'REST_REQUEST' ), |
| 43 |
'is_ssl()' => is_ssl(), |
| 44 |
'is_admin()' => is_admin(), |
| 45 |
'is_network_admin()' => is_network_admin(), |
| 46 |
'$_POST' => $_POST, |
| 47 |
'$_GET' => $_GET, |
| 48 |
'$_COOKIE' => $_COOKIE, |
| 49 |
'parse_url' => parse_url( $_SERVER['REQUEST_URI'] ), |
| 50 |
'$wp' => $wp, |
| 51 |
'$wp_query' => $wp_query, |
| 52 |
'$wp_rewrite' => $wp_rewrite, |
| 53 |
'$wp_locale' => $wp_locale, |
| 54 |
); |
| 55 |
|
| 56 |
$savequeries = MywpHelper::get_define( 'SAVEQUERIES' ); |
| 57 |
|
| 58 |
if( ! empty( $savequeries ) ) { |
| 59 |
|
| 60 |
$debug_lists['queries'] = $wpdb->queries; |
| 61 |
|
| 62 |
} else { |
| 63 |
|
| 64 |
$debug_lists['not_queries'] = __( 'Require the define( "SAVEQUERIES" , true ).' , 'my-wp' ); |
| 65 |
|
| 66 |
} |
| 67 |
|
| 68 |
return $debug_lists; |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
protected static function mywp_debug_render() { |
| 73 |
|
| 74 |
$debug_lists = self::get_debug_lists(); |
| 75 |
|
| 76 |
if( empty( $debug_lists ) ) { |
| 77 |
|
| 78 |
return false; |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
echo '<table class="debug-table">'; |
| 83 |
|
| 84 |
foreach( $debug_lists as $key => $val ) { |
| 85 |
|
| 86 |
echo '<tr>'; |
| 87 |
|
| 88 |
printf( '<th>%s</th>' , $key ); |
| 89 |
|
| 90 |
echo '<td>'; |
| 91 |
|
| 92 |
if( in_array( $key , array( '$_POST' , '$_GET' , '$_COOKIE' , 'parse_url' , 'queries' , '$wp' , '$wp_query' , '$wp_rewrite' , '$wp_locale' ) ) ) { |
| 93 |
|
| 94 |
if( is_array( $val ) ) { |
| 95 |
|
| 96 |
printf( 'Count: %s<br />' , number_format( count( $val ) ) ); |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
printf( '<textarea readonly="readonly">%s</textarea>' , print_r( map_deep( $val , 'esc_html' ) , true ) ); |
| 101 |
|
| 102 |
} else { |
| 103 |
|
| 104 |
echo $val; |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
echo '</td>'; |
| 109 |
|
| 110 |
echo '</tr>'; |
| 111 |
|
| 112 |
} |
| 113 |
|
| 114 |
echo '</table>'; |
| 115 |
|
| 116 |
} |
| 117 |
|
| 118 |
} |
| 119 |
|
| 120 |
MywpDeveloperModuleDevRequest::init(); |
| 121 |
|
| 122 |
endif; |
| 123 |
|