/var/www/html_nl/wp-content/plugins/query-monitor/output/headers/overview.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php declare(strict_types 1);
/**
 * General overview output for HTTP headers.
 *
 * @package query-monitor
 */

if ( ! defined'ABSPATH' ) ) {
    exit;
}

class 
QM_Output_Headers_Overview extends QM_Output_Headers {

    
/**
     * Collector instance.
     *
     * @var QM_Collector_Overview Collector.
     */
    
protected $collector;

    
/**
     * @return array<string, mixed>
     */
    
public function get_output() {
        
/** @var QM_Data_Overview $data */
        
$data $this->collector->get_data();
        
$headers = array();

        
$headers['time_taken'] = number_format_i18n$data->time_taken);
        
$headers['time_usage'] = sprintf(
            
/* translators: 1: Percentage of time limit used, 2: Time limit in seconds */
            
__'%1$s%% of %2$ss limit''query-monitor' ),
            
number_format_i18n$data->time_usage),
            
number_format_i18n$data->time_limit )
        );

        if ( ! empty( 
$data->memory ) ) {
            
$headers['memory'] = sprintf(
                
/* translators: %s: Memory usage in megabytes with a decimal fraction. Note the space between value and unit symbol. */
                
__'%s MB''query-monitor' ),
                
number_format_i18n( ( $data->memory 1024 1024 ), )
            );

            if ( 
$data->memory_limit ) {
                
$headers['memory_usage'] = sprintf(
                    
/* translators: 1: Percentage of memory limit used, 2: Memory limit in megabytes */
                    
__'%1$s%% of %2$s MB server limit''query-monitor' ),
                    
number_format_i18n$data->memory_usage),
                    
number_format_i18n$data->memory_limit 1024 1024 )
                );
            }
        }

        return 
$headers;

    }

}

/**
 * @param array<string, QM_Output> $output
 * @param QM_Collectors $collectors
 * @return array<string, QM_Output>
 */
function register_qm_output_headers_overview( array $outputQM_Collectors $collectors ) {
    
$collector QM_Collectors::get'overview' );
    if ( 
$collector ) {
        
$output['overview'] = new QM_Output_Headers_Overview$collector );
    }
    return 
$output;
}

add_filter'qm/outputter/headers''register_qm_output_headers_overview'10);