Initial commit

This commit is contained in:
Felix Förtsch
2020-10-20 14:39:50 +02:00
commit 648ded8896
1225 changed files with 216511 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
<?php
/**
* Constants output for HTML pages.
*
* @package query-monitor-extend
*/
class QMX_Output_Html_Constants extends QMX_Output_Html {
public function __construct( QMX_Collector $collector ) {
parent::__construct( $collector );
add_filter( 'qm/output/panel_menus', array( &$this, 'panel_menu' ), 60 );
}
public function output() {
$data = $this->collector->get_data();
echo '<div class="qm" id="' . esc_attr( $this->collector->id() ) . '">';
if ( !empty( $data['constants'] ) ) {
echo '<table class="qm-sortable">';
echo '<caption class="qm-screen-reader-text">' . esc_html( $this->collector->name() ) . '</caption>';
echo '<thead>';
echo '<tr>';
echo '<th scope="col" class="qm-num qm-sorted-asc qm-sortable-column">';
echo $this->build_sorter( __( '', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-sortable-column">';
echo $this->build_sorter( __( 'Constant', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-ltr">';
echo __( 'Value', 'query-monitor-extend' );
echo '</th>';
echo '<th scope="col" class="qm-sortable-column">';
echo $this->build_sorter( __( 'Type', 'query-monitor-extend' ) );
echo '</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
$i = 1;
$bools = array( true => 'true', false => 'false' );
foreach ( $data['constants'] as $constant => $value ) {
echo '<tr>';
echo '<td class="qm-num">' . $i++ . '</td>';
echo '<td class="qm-ltr" data-qm-sort-weight="' . strtolower( esc_attr( $constant ) ) . '"><code style="user-select: all;">' . esc_html( $constant ) . '</code></td>';
echo '<td ' . ( is_bool( $value ) ? ' class="qm-' . $bools[$value] . '"' : '' ) . '>' . ( is_bool( $value ) ? strtoupper( $bools[$value] ) : esc_html( $value ) ) . '</td>';
echo '<td class="qm-ltr">' . esc_html( gettype( $value ) ) . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '<tfoot>';
echo '</tfoot>';
echo '</table>';
} else {
echo '<div class="qm-none">';
echo '<p>' . esc_html__( 'None', 'query-monitor' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
public function panel_menu( array $menu ) {
$menu['constants'] = $this->menu( array(
'title' => esc_html__( 'Constants', 'query-monitor-extend' ),
'id' => 'query-monitor-extend-constants',
) );
return $menu;
}
}
function register_qmx_output_html_constants( array $output ) {
if ( $collector = QMX_Collectors::get( 'constants' ) ) {
$output['constants'] = new QMX_Output_Html_Constants( $collector );
}
return $output;
}
add_filter( 'qmx/outputter/html', 'register_qmx_output_html_constants', 70 );

View File

@@ -0,0 +1,173 @@
<?php
/**
* Files output for HTML pages.
*
* @package query-monitor-extend
*/
class QMX_Output_Html_Files extends QMX_Output_Html {
public function __construct( QMX_Collector $collector ) {
parent::__construct( $collector );
add_filter( 'qm/output/title', array( &$this, 'admin_title' ), 40 );
add_filter( 'qm/output/panel_menus', array( &$this, 'panel_menu' ), 60 );
}
public function output() {
$data = $this->collector->get_data();
echo '<div class="qm" id="' . esc_attr( $this->collector->id() ) . '">';
if ( !empty( $data['files'] ) ) {
$files_with_errors = 0;
$path_components = $components = array();
$largest_file = array(
'path' => null,
'size' => 0
);
foreach ( $data['files'] as &$file ) {
$file['_path_components'] = array();
foreach ( array_filter( explode( '/', str_replace( ABSPATH, '', dirname( $file['path'] ) ) ) ) as $path_component ) {
$path_components[$path_component]
= $file['_path_components'][$path_component]
= 1;
foreach ( explode( '-', $path_component ) as $smaller_path_component )
$path_components[$smaller_path_component]
= $file['_path_components'][$smaller_path_component]
= 1;
}
$components[$file['component']->name] = 1;
}
echo '<table class="qm-sortable">';
echo '<caption class="qm-screen-reader-text">' . esc_html( $this->collector->name() ) . '</caption>';
echo '<thead>';
echo '<tr>';
echo '<th scope="col" class="qm-num qm-sorted-asc qm-sortable-column">';
echo $this->build_sorter( __( '', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-filterable-column">';
echo $this->build_filter( 'path', array_map( 'esc_attr', array_keys( $path_components ) ), __( 'Path', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-ltr qm-sortable-column">';
echo $this->build_sorter( __( 'Filesize', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-filterable-column">';
echo $this->build_filter( 'component', array_map( 'esc_attr', array_keys( $components ) ), __( 'Component', 'query-monitor-extend' ) );
echo '</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach ( $data['files'] as $i => $file ) {
if ( filesize( $file['path'] ) > $largest_file['size'] )
$largest_file = array(
'path' => $file['path'],
'size' => filesize( $file['path'] ),
);
if ( !empty( $file['has_error'] ) )
$files_with_errors++;
echo '<tr ' .
'data-qm-component="' . esc_attr( $file['component']->name ) . '"' .
'data-qm-path="' . esc_attr( implode( ' ', array_keys( $file['_path_components'] ) ) ) . '"' .
( !empty( $file['has_error'] ) ? ' class="qm-warn"' : '' ) .
'>';
echo '<td class="qm-num">' . ( $i + 1 ) . '</td>';
echo '<td title="' . esc_attr( $file['path'] ) . '">' . esc_html( str_replace( ABSPATH, '/', $file['path'] ) ) . '</td>';
echo '<td data-qm-sort-weight="' . filesize( $file['path'] ) . '">' . $this->human_file_size( filesize( $file['path'] ) ) . '</td>';
echo '<td>' . esc_html( $file['component']->name ) . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '<tfoot>';
echo '<tr class="qm-items-shown qm-hide">';
echo '<td colspan="4">';
printf(
esc_html__( 'Files in filter: %s', 'query-monitor-extend' ),
'<span class="qm-items-number">' . esc_html( number_format_i18n( count( $data['files']) ) ) . '</span>'
);
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan="2">' .
'Total: <span class="qm-items-number">' . esc_html( number_format_i18n( count( $data['files'] ) ) ) . '</span>' .
(
!empty( $files_with_errors )
? ', With error(s): <span>' . esc_html( number_format_i18n( $files_with_errors ) ) . '</span>'
: ''
) .
'</td>';
echo '<td>Largest: <abbr title="' . esc_attr( $largest_file['path'] ) . '">' . $this->human_file_size( $largest_file['size'] ) . '</td>';
echo '<td>Components: ' . count( $components ) . '</td>';
echo '</tr>';
echo '</tfoot>';
echo '</table>';
echo '<style type="text/css">.qm-hide-path { display: none; }</style>';
} else {
echo '<div class="qm-none">';
echo '<p>' . esc_html__( 'None', 'query-monitor' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
public function admin_title( array $title ) {
$data = $this->collector->get_data();
if ( !empty( $data['files'] ) ) {
$_title = sprintf( esc_html_x( '%s F', 'Files count', 'query-monitor-extend' ), number_format_i18n( count( $data['files'] ) ) );
$_title = preg_replace( '#\s?([^0-9,\.]+)#', '<small>$1</small>', $_title );
$title[] = $_title;
}
return $title;
}
public function panel_menu( array $menu ) {
$menu['files'] = $this->menu( array(
'title' => esc_html__( 'Files', 'query-monitor-extend' ),
'id' => 'query-monitor-extend-files',
) );
return $menu;
}
private function human_file_size( $bytes ) {
$filesize_units = 'BKMGTP';
$factor = floor( ( strlen( $bytes ) - 1 ) / 3 );
return sprintf( "%.2f", $bytes / pow( 1024, $factor ) ) . @$filesize_units[$factor];
}
}
function register_qmx_output_html_files( array $output ) {
if ( $collector = QMX_Collectors::get( 'files' ) ) {
$output['files'] = new QMX_Output_Html_Files( $collector );
}
return $output;
}
add_filter( 'qmx/outputter/html', 'register_qmx_output_html_files', 70 );

View File

@@ -0,0 +1,83 @@
<?php
/**
* Heartbeat output for HTML pages.
*
* @package query-monitor-extend
*/
class QMX_Output_Html_Heartbeat extends QMX_Output_Html {
public function __construct( QMX_Collector $collector ) {
parent::__construct( $collector );
add_filter( 'qm/output/panel_menus', array( &$this, 'panel_menu' ), 60 );
}
public function output() {
$data = $this->collector->get_data();
echo '<div class="qm" id="' . esc_attr( $this->collector->id() ) . '">';
if ( $this->collector->qm_no_jquery() ) {
echo '<div class="qm-none">';
echo '<p>Heartbeat logging requires jQuery, which has been prevented by <code>QM_NO_JQUERY</code>.</p>';
echo '</div>';
} else if ( wp_script_is( 'heartbeat', 'done' ) ) {
echo '<table class="qm-sortable">';
echo '<caption class="qm-screen-reader-text">' . esc_html( $this->collector->name() ) . '</caption>';
echo '<thead>';
echo '<tr>';
echo '<th scope="col" class="qm-num qm-sorted-asc qm-sortable-column"></th>';
echo '<th scope="col">Lub</th>';
echo '<th scope="col">Dub</th>';
echo '<th scope="col">Time since last</th>';
echo '<th scope="col">Duration</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
echo '<tr class="listening">';
echo '<td colspan="5">';
echo '<div class="qm-none"><p>Listening for first heartbeat...</p></div>';
echo '</td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '<script type="text/javascript">qmx_heartbeat.populate_table();</script>';
} else {
echo '<div class="qm-none">';
echo '<p>' . esc_html__( 'No heartbeat detected.', 'query-monitor' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
public function panel_menu( array $menu ) {
$data = $this->collector->get_data();
$menu['heartbeat'] = $this->menu( array(
'title' => esc_html__( 'Heartbeats (0)' ),
'id' => 'query-monitor-extend-heartbeat',
) );
return $menu;
}
}
function register_qmx_output_html_heartbeat( array $output ) {
if ( $collector = QMX_Collectors::get( 'heartbeat' ) ) {
$output['heartbeat'] = new QMX_Output_Html_Heartbeat( $collector );
}
return $output;
}
add_filter( 'qmx/outputter/html', 'register_qmx_output_html_heartbeat', 70 );

View File

@@ -0,0 +1,134 @@
<?php
/**
* Image sizes output for HTML pages.
*
* @package query-monitor-extend
*/
class QMX_Output_Html_Image_Sizes extends QMX_Output_Html {
public function __construct( QMX_Collector $collector ) {
parent::__construct( $collector );
add_filter( 'qm/output/panel_menus', array( &$this, 'panel_menu' ), 60 );
}
public function output() {
$data = $this->collector->get_data();
echo '<div class="qm" id="' . esc_attr( $this->collector->id() ) . '">';
if ( !empty( $data['sizes'] ) ) {
echo '<table class="qm-sortable">';
echo '<caption class="qm-screen-reader-text">' . esc_html( $this->collector->name() ) . '</caption>';
echo '<thead>';
echo '<tr>';
echo '<th scope="col" class="qm-num qm-sorted-asc qm-sortable-column">';
echo $this->build_sorter( __( '', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-sortable-column">';
echo $this->build_sorter( __( 'ID', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-num qm-sortable-column">';
echo $this->build_sorter( __( 'Width', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-num qm-sortable-column">';
echo $this->build_sorter( __( 'Height', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-num qm-sortable-column">';
echo $this->build_sorter( __( 'Ratio', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-num">';
echo __( 'Cropped', 'query-monitor-extend' );
echo '</th>';
echo '<th scope="col" class="qm-sortable-column">';
echo $this->build_sorter( __( 'Source', 'query-monitor-extend' ) );
echo '</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
$sources = array();
foreach ( $data['sizes'] as $id => $row ) {
$ratio = array( $row['width'], $row['height'] );
if (
!empty( $row['width'] )
&& !empty( $row['height'] )
)
$ratio = array( $row['width'] / $row['_gcd'], $row['height'] / $row['_gcd'] );
if ( $ratio === array( $row['width'], $row['height'] ) )
$ratio = array( '&mdash;' );
echo '<tr data-qmx-image-size-width="' . esc_attr( $row['width'] ) . '" data-qmx-image-size-height="' . esc_attr( $row['height'] ) . '" data-qmx-image-size-ratio="' . esc_attr( $row['ratio'] ) . '">';
echo '<td class="qm-num">' . esc_html( $row['num'] ) . '</td>';
echo '<td class="qm-ltr">' . esc_html( $id ) . '</td>';
echo '<td class="qm-num" data-qmx-image-size-width="' . esc_attr( $row['width'] ) . '">' . esc_html( $row['width'] ) . '</td>';
echo '<td class="qm-num" data-qmx-image-size-height="' . esc_attr( $row['height'] ) . '">' . esc_html( $row['height'] ) . '</td>';
echo '<td class="qm-num" data-qmx-image-size-ratio="' . esc_attr( $row['ratio'] ) . '" data-qm-sort-weight="' . esc_attr( $row['ratio'] ) . '">' . esc_html( implode( ':', $ratio ) ) . '</td>';
echo '<td class="qm-num qm-true">' . ( $row['crop'] ? '<span class="dashicons dashicons-yes"></span>' : '' ) . '</td>';
echo '<td class="qm-ltr">' . esc_html( $row['source'] ) . '</td>';
echo '</tr>';
array_key_exists( $row['source'], $sources ) ? $sources[$row['source']]++ : $sources[$row['source']] = 1;
}
echo '</tbody>';
echo '<tfoot>';
if ( !empty( $sources ) )
$sources = array_map( function( $k, $v ) { return ucwords( $k ) . ': ' . $v; }, array_keys( $sources ), $sources );
echo '<tr>';
echo '<td class="qm-num">Total: <span class="qm-items-number">' . esc_html( number_format_i18n( count( $data['sizes'] ) ) ) . '</span></td>';
echo '<td>&nbsp;</td>';
echo '<td colspan="2">Duplicates: <span class="qm-items-number">' . esc_html( number_format_i18n( array_sum( $data['_duplicates']['dimensions'] ) ) ) . '</span></td>';
echo '<td colspan="2">Duplicates: <span class="qm-items-number">' . esc_html( number_format_i18n( array_sum( $data['_duplicates']['ratios'] ) ) ) . '</span></td>';
echo '<td>' . implode( ', ', $sources ) . '</td>';
echo '</tr>';
echo '</tfoot>';
echo '</table>';
} else {
echo '<div class="qm-none">';
echo '<p>' . esc_html__( 'None', 'query-monitor' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
public function panel_menu( array $menu ) {
$menu['image_sizes'] = $this->menu( array(
'title' => esc_html__( 'Image Sizes', 'query-monitor-extend' ),
'id' => 'query-monitor-extend-image_sizes',
) );
return $menu;
}
}
function register_qmx_output_html_image_sizes( array $output ) {
if ( $collector = QMX_Collectors::get( 'image_sizes' ) ) {
$output['image_sizes'] = new QMX_Output_Html_Image_Sizes( $collector );
}
return $output;
}
add_filter( 'qmx/outputter/html', 'register_qmx_output_html_image_sizes', 70 );

View File

@@ -0,0 +1,94 @@
<?php
/**
* Paths output for HTML pages.
*
* @package query-monitor-extend
*/
class QMX_Output_Html_Paths extends QMX_Output_Html {
public function __construct( QMX_Collector $collector ) {
parent::__construct( $collector );
add_filter( 'qm/output/panel_menus', array( &$this, 'panel_menu' ), 60 );
}
public function output() {
$data = $this->collector->get_data();
echo '<div class="qm" id="' . esc_attr( $this->collector->id() ) . '">';
if ( !empty( $data['paths'] ) ) {
echo '<table class="qm-sortable">';
echo '<caption class="qm-screen-reader-text">' . esc_html( $this->collector->name() ) . '</caption>';
echo '<thead>';
echo '<tr>';
echo '<th scope="col" class="qm-sorted-asc qm-sortable-column">';
echo $this->build_sorter( __( 'Constant/Function', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-ltr">';
echo __( 'Path', 'query-monitor-extend' );
echo '</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach ( $data['paths'] as $var => $value ) {
echo '<tr>';
echo '<td class="qm-ltr"><code style="user-select: all;">' . esc_html( $var ) . '</code></td>';
if ( is_string( $value ) ) {
echo '<td>' . esc_html( $value ) . '</td>';
} else {
echo '<td class="qm-has-inner qm-ltr">';
self::output_inner( $value );
echo '</td>';
}
echo '</tr>';
}
echo '</tbody>';
echo '<tfoot>';
echo '</tfoot>';
echo '</table>';
} else {
echo '<div class="qm-none">';
echo '<p>' . esc_html__( 'None', 'query-monitor' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
public function panel_menu( array $menu ) {
$menu['paths'] = $this->menu( array(
'title' => esc_html__( 'Paths', 'query-monitor-extend' ),
'id' => 'query-monitor-extend-paths',
) );
return $menu;
}
}
function register_qmx_output_html_paths( array $output ) {
if ( $collector = QMX_Collectors::get( 'paths' ) ) {
$output['paths'] = new QMX_Output_Html_Paths( $collector );
}
return $output;
}
add_filter( 'qmx/outputter/html', 'register_qmx_output_html_paths', 70 );

View File

@@ -0,0 +1,132 @@
<?php
/**
* Paths output for HTML pages.
*
* @package query-monitor-extend
*/
class QMX_Output_Html_Time extends QMX_Output_Html {
public function __construct( QMX_Collector $collector ) {
parent::__construct( $collector );
add_filter( 'qm/output/panel_menus', array( &$this, 'panel_menu' ), 60 );
}
public function output() {
$data = $this->collector->get_data();
$wp_offset = get_option( 'gmt_offset' );
echo '<div class="qm qm-non-tabular" id="' . esc_attr( $this->collector->id() ) . '">' .
'<div class="qm-boxed">';
foreach ( $data['functions'] as $label => $function ) {
if ( is_callable( array( $this->collector, $function ) ) )
echo '<div class="qm-section">' .
'<h2>' . esc_html( $label ) . '</h2>' .
'<p><code id="qm-time-' . sanitize_title( $label ) . '">' . $this->collector->$function() . '</code></p>' .
'</div>';
}
echo '</div>';
?>
<script type="text/javascript">
( function() {
if ( 'function' !== typeof IntersectionObserver )
return;
var qmx_time_interval = 0;
var observer = new IntersectionObserver( function( entries, observer ) {
if ( !entries[0].isIntersecting ) {
clearInterval( qmx_time_interval );
return;
}
var qmx_time_months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var qmx_time_days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
var qmx_time_container = document.getElementById( 'qm-time' );
var qmx_time_utc = document.getElementById( 'qm-time-utc' );
var qmx_time_server = document.getElementById( 'qm-time-server' );
var qmx_time_wp = document.getElementById( 'qm-time-wordpress' );
var qmx_time_browser = document.getElementById( 'qm-time-browser' );
if ( qmx_time_container ) {
qmx_time_interval = setInterval( function() {
var d = new Date();
var UTC_string = d.toUTCString();
var utc_time = d.getTime() + ( d.getTimezoneOffset() * 60 * 1000 );
var server = new Date( utc_time + ( <?php echo esc_js( $this->collector->get_server_offset() ) ?> * 1000 ) );
var wp = new Date( utc_time + ( <?php echo esc_js( $this->collector->get_wp_offset() * HOUR_IN_SECONDS ) ?> * 1000 ) );
qmx_time_utc.innerHTML =
qmx_time_days[d.getUTCDay()] + ', '
+ qmx_time_months[d.getUTCMonth()] + ' '
+ d.getUTCDate() + ', '
+ d.getUTCFullYear() + ' '
+ ( 10 > d.getUTCHours() ? '0' : '' ) + d.getUTCHours()
+ ':' + ( 10 > d.getUTCMinutes() ? '0' : '' ) + d.getUTCMinutes()
+ ':' + ( 10 > d.getUTCSeconds() ? '0' : '' ) + d.getUTCSeconds();
qmx_time_server.innerHTML =
qmx_time_days[server.getDay()] + ', '
+ qmx_time_months[server.getMonth()] + ' '
+ server.getDate() + ', '
+ server.getFullYear() + ' '
+ ( 10 > server.getHours() ? '0' : '' ) + server.getHours()
+ ':' + ( 10 > server.getMinutes() ? '0' : '' ) + server.getMinutes()
+ ':' + ( 10 > server.getSeconds() ? '0' : '' ) + server.getSeconds();
qmx_time_wp.innerHTML =
qmx_time_days[wp.getDay()] + ', '
+ qmx_time_months[wp.getMonth()] + ' '
+ wp.getDate() + ', '
+ wp.getFullYear() + ' '
+ ( 10 > wp.getHours() ? '0' : '' ) + wp.getHours()
+ ':' + ( 10 > wp.getMinutes() ? '0' : '' ) + wp.getMinutes()
+ ':' + ( 10 > wp.getSeconds() ? '0' : '' ) + wp.getSeconds();
qmx_time_browser.innerHTML =
qmx_time_days[d.getDay()] + ', '
+ qmx_time_months[d.getMonth()] + ' '
+ d.getDate() + ', '
+ d.getFullYear() + ' '
+ ( 10 > d.getHours() ? '0' : '' ) + d.getHours()
+ ':' + ( 10 > d.getMinutes() ? '0' : '' ) + d.getMinutes()
+ ':' + ( 10 > d.getSeconds() ? '0' : '' ) + d.getSeconds();
}, 1000 );
}
} );
observer.observe( document.getElementById( 'qm-time' ) );
} () );
</script>
<?php
echo '</div>';
}
public function panel_menu( array $menu ) {
$menu['time'] = $this->menu( array(
'title' => esc_html__( 'Time', 'query-monitor-extend' ),
'id' => 'query-monitor-extend-time',
) );
return $menu;
}
}
function register_qmx_output_html_time( array $output ) {
if ( $collector = QMX_Collectors::get( 'time' ) ) {
$output['time'] = new QMX_Output_Html_Time( $collector );
}
return $output;
}
add_filter( 'qmx/outputter/html', 'register_qmx_output_html_time', 70 );

View File

@@ -0,0 +1,92 @@
<?php
/**
* Var dumps output for HTML pages.
*
* @package query-monitor-extend
*/
class QMX_Output_Html_Var_Dumps extends QMX_Output_Html {
public function __construct( QMX_Collector $collector ) {
parent::__construct( $collector );
add_filter( 'qm/output/panel_menus', array( &$this, 'panel_menu' ), 60 );
}
public function output() {
$data = $this->collector->get_data();
echo '<div class="qm" id="' . esc_attr( $this->collector->id() ) . '">';
if ( !empty( $data['vars'] ) ) {
echo '<table class="qm-sortable">';
echo '<caption class="qm-screen-reader-text">' . esc_html( $this->collector->name() ) . '</caption>';
echo '<thead>';
echo '<tr>';
echo '<th scope="col" class="qm-num qm-sorted-asc qm-sortable-column">';
echo $this->build_sorter( __( '', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col" class="qm-sortable-column">';
echo $this->build_sorter( __( 'ID', 'query-monitor-extend' ) );
echo '</th>';
echo '<th scope="col">';
echo 'Value';
echo '</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
$i = 1;
foreach ( $data['vars'] as $label => $value ) {
echo '<tr>';
echo '<td class="qm-num">' . $i++ . '</td>';
echo '<td class="qm-ltr">' . esc_html( $label ) . '</td>';
echo '<td>';
echo '<textarea style="font-family: Consolas, Monaco, monospace; width: 100%; height: 200px; background-color: rgba( 255, 255, 255, 0.25 ); font-size: inherit;" readonly="readonly">';
print_r( $value );
echo '</textarea>';
echo '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
} else {
echo '<div class="qm-none">';
echo '<p>' . esc_html__( 'None', 'query-monitor' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
public function panel_menu( array $menu ) {
$data = $this->collector->get_data();
$menu['var_dumps'] = $this->menu( array(
'title' => esc_html__( 'Var Dumps' . ( !empty( $data['vars'] ) ? ' (' . count( $data['vars'] ) . ')' : '' ), 'query-monitor-extend' ),
'id' => 'query-monitor-extend-var-dumps',
) );
return $menu;
}
}
function register_qmx_output_html_var_dumps( array $output ) {
if ( $collector = QMX_Collectors::get( 'var_dumps' ) ) {
$output['var_dumps'] = new QMX_Output_Html_Var_Dumps( $collector );
}
return $output;
}
add_filter( 'qmx/outputter/html', 'register_qmx_output_html_var_dumps', 70 );