-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ | |
'heartbeat', | ||
'image-sizes', | ||
'paths', | ||
'server-get-post', | ||
'time', | ||
) ); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |