/var/www/html_de/wp-content/plugins/query-monitor/output/html/languages.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php declare(strict_types 1);
/**
 * Language and locale output for HTML pages.
 *
 * @package query-monitor
 */

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

class 
QM_Output_Html_Languages extends QM_Output_Html {

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

    public function 
__constructQM_Collector $collector ) {
        
parent::__construct$collector );
        
add_filter'qm/output/menus', array( $this'admin_menu' ), 80 );
    }

    
/**
     * @return string
     */
    
public function name() {
        return 
__'Languages''query-monitor' );
    }

    
/**
     * @return void
     */
    
public function output() {
        
/** @var QM_Data_Languages $data */
        
$data $this->collector->get_data();

        
$this->before_non_tabular_output();

        echo 
'<section>';
        echo 
'<h3><code>get_locale()</code></h3>';
        echo 
'<p>' esc_html$data->locale ) . '</p>';
        echo 
'</section>';

        echo 
'<section>';
        echo 
'<h3><code>get_user_locale()</code></h3>';
        echo 
'<p>' esc_html$data->user_locale ) . '</p>';
        echo 
'</section>';

        echo 
'<section>';
        echo 
'<h3><code>determine_locale()</code></h3>';
        echo 
'<p>' esc_html$data->determined_locale ) . '</p>';
        echo 
'</section>';

        if ( isset( 
$data->mlp_language ) ) {
            echo 
'<section>';
            echo 
'<h3>';
            
printf(
                
/* translators: %s: Name of a multilingual plugin */
                
esc_html__'%s Language''query-monitor' ),
                
'MultilingualPress'
            
);
            echo 
'</h3>';
            echo 
'<p>' esc_html$data->mlp_language ) . '</p>';
            echo 
'</section>';
        }

        if ( isset( 
$data->pll_language ) ) {
            echo 
'<section>';
            echo 
'<h3>';
            
printf(
                
/* translators: %s: Name of a multilingual plugin */
                
esc_html__'%s Language''query-monitor' ),
                
'Polylang'
            
);
            echo 
'</h3>';
            echo 
'<p>' esc_html$data->pll_language ) . '</p>';
            echo 
'</section>';
        }

        echo 
'<section>';
        echo 
'<h3><code>get_language_attributes()</code></h3>';
        echo 
'<p><code>' esc_html$data->language_attributes ) . '</code></p>';
        echo 
'</section>';

        if ( ! empty( 
$data->languages ) ) {
            echo 
'<table class="qm-full-width">';
            echo 
'<thead>';
            echo 
'<tr>';
            echo 
'<th scope="col">' esc_html__'Text Domain''query-monitor' ) . '</th>';
            echo 
'<th scope="col">' esc_html__'Type''query-monitor' ) . '</th>';
            echo 
'<th scope="col">' esc_html__'Caller''query-monitor' ) . '</th>';
            echo 
'<th scope="col">' esc_html__'Translation File''query-monitor' ) . '</th>';
            echo 
'<th scope="col">' esc_html__'Size''query-monitor' ) . '</th>';
            echo 
'</tr>';
            echo 
'</thead>';

            echo 
'<tbody>';

            foreach ( 
$data->languages as $textdomain => $mofiles ) {
                foreach ( 
$mofiles as $mofile ) {
                    echo 
'<tr>';

                    if ( 
$mofile['handle'] ) {
                        echo 
'<td class="qm-ltr">' esc_html$mofile['domain'] ) . ' (' esc_html$mofile['handle'] ) . ')</td>';
                    } else {
                        echo 
'<td class="qm-ltr">' esc_html$mofile['domain'] ) . '</td>';
                    }

                    echo 
'<td>' esc_html$mofile['type'] ) . '</td>';

                    if ( 
self::has_clickable_links() ) {
                        echo 
'<td class="qm-nowrap qm-ltr">';
                        echo 
self::output_filename$mofile['caller']['display'], $mofile['caller']['file'], $mofile['caller']['line'] ); // WPCS: XSS ok.
                        
echo '</td>';
                    } else {
                        echo 
'<td class="qm-nowrap qm-ltr qm-has-toggle">';
                        echo 
self::build_toggler(); // WPCS: XSS ok;
                        
echo '<ol>';
                        echo 
'<li>';
                        
// undefined:
                        
echo self::output_filename$mofile['caller']['display'], $mofile['caller']['file'], $mofile['caller']['line'] ); // WPCS: XSS ok.
                        
echo '</li>';
                        echo 
'</ol></td>';
                    }

                    echo 
'<td class="qm-ltr">';
                    if ( 
$mofile['file'] ) {
                        if ( 
$mofile['found'] && 'gettext' !== $mofile['type'] && self::has_clickable_links() ) {
                            echo 
self::output_filenameQM_Util::standard_dir$mofile['file'], '' ), $mofile['file'], 1true ); // WPCS: XSS ok.
                        
} else {
                            echo 
esc_htmlQM_Util::standard_dir$mofile['file'], '' ) );
                        }
                    } else {
                        echo 
'<em>' esc_html__'None''query-monitor' ) . '</em>';
                    }
                    echo 
'</td>';

                    if ( 
$mofile['found'] ) {
                        echo 
'<td class="qm-nowrap qm-num">';
                        echo 
esc_htmlsprintf(
                            
/* translators: %s: Memory used in kilobytes */
                            
__'%s kB''query-monitor' ),
                            
number_format_i18n$mofile['found'] / 1024)
                        ) );
                        echo 
'</td>';
                    } else {
                        echo 
'<td class="qm-nowrap">';
                        echo 
esc_html__'Not Found''query-monitor' );
                        echo 
'</td>';
                    }

                    echo 
'</tr>';
                }
            }

            echo 
'</tbody>';

            echo 
'<tfoot>';
            echo 
'<tr>';
            echo 
'<td colspan="4">&nbsp;</td>';
            echo 
'<td class="qm-num">';

            echo 
esc_htmlsprintf(
                
/* translators: %s: Memory used in kilobytes */
                
__'%s kB''query-monitor' ),
                
number_format_i18n$data->total_size 1024)
            ) );

            echo 
'</td>';
            echo 
'</tr>';
            echo 
'</tfoot>';

            echo 
'</table>';
        }

        
$this->after_non_tabular_output();
    }

    
/**
     * @param array<string, mixed[]> $menu
     * @return array<string, mixed[]>
     */
    
public function admin_menu( array $menu ) {
        
$args = array(
            
'title' => esc_html$this->name() ),
        );

        
$menu$this->collector->id() ] = $this->menu$args );

        return 
$menu;

    }

}

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

add_filter'qm/outputter/html''register_qm_output_html_languages'81);