Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
crstauf committed Oct 9, 2023
1 parent c30c499 commit 0e52f16
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions query-monitor-extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
'heartbeat',
'image-sizes',
'paths',
'server-get-post',
'time',
) );

Expand Down
42 changes: 42 additions & 0 deletions server-get-post/qmx-server-get-post-collector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php declare(strict_types=1);

defined( 'WPINC' ) || die();

/**
* @extends QM_DataCollector<QMX_Data_Server_Get_Post>
*/
class QMX_Collector_Server_Get_Post extends QM_DataCollector {

public $id = 'server-get-post';

public function name() : string {
return __( 'SERVER, GET, POST', 'query-monitor-extend' );
}

public function get_storage(): QM_Data {
require_once 'qmx-server-get-post-data.php';
return new QMX_Data_Server_Get_Post();
}

public function process() : void {
if ( did_action( 'qm/cease' ) ) {
return;
}

$this->data['server'] = $_SERVER;

if ( ! empty( $_GET ) ) {
$this->data['get'] = $_GET;
}

if ( ! empty( $_POST ) ) {
$this->data['post'] = $_POST;
}
}

}

add_filter( 'qm/collectors', static function ( array $collectors ) : array {
$collectors['server-get-post'] = new QMX_Collector_Server_Get_Post;
return $collectors;
} );
22 changes: 22 additions & 0 deletions server-get-post/qmx-server-get-post-data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types=1);

defined( 'WPINC' ) || die();

class QMX_Data_Server_Get_Post extends QM_Data {

/**
* @var array<string, scalar>
*/
public $server;

/**
* @var array<string, scalar>
*/
public $get;

/**
* @var array<string, scalar>
*/
public $post;

}
46 changes: 46 additions & 0 deletions server-get-post/qmx-server-get-post-output.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php declare(strict_types=1);

defined( 'WPINC' ) || die();

/**
* @property-read QMX_Collector_Server_Get_Post $collector
*/
class QMX_Output_Html_Server_Get_Post extends QM_Output_Html {

public function __construct( QM_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() ) . '">';

var_dump( $data );

echo '</div>';
}

/**
* @param array<string, array<string, mixed>> $menu
* @return array<string, array<string, mixed>>
*/
public function panel_menu( array $menu ) {
$menu['server-get-post'] = $this->menu( array(
'title' => esc_html__( 'SERVER, GET, POST', 'query-monitor-extend' ),
'id' => 'query-monitor-extend-server-get-post',
) );

return $menu;
}

}

add_filter( 'qm/outputter/html', static function ( array $output ) : array {
if ( $collector = QM_Collectors::get( 'server-get-post' ) ) {
$output['server-get-post'] = new QMX_Output_Html_Server_Get_Post( $collector );
}

return $output;
}, 70 );

0 comments on commit 0e52f16

Please sign in to comment.