';
21 |
22 | if ( ! empty( $data->files ) ) {
23 | $files_with_errors = 0;
24 | $path_components = array();
25 | $components = array();
26 |
27 | $largest_file = array(
28 | 'path' => null,
29 | 'size' => 0
30 | );
31 |
32 | foreach ( $data->files as &$file ) {
33 | $file['_path_components'] = array();
34 |
35 | foreach ( array_filter( explode( '/', str_replace( ABSPATH, '', dirname( $file['path'] ) ) ) ) as $path_component ) {
36 | $file['_path_components'][ $path_component ] = 1;
37 | $path_components[ $path_component ] = 1;
38 |
39 | foreach ( explode( '-', $path_component ) as $smaller_path_component ) {
40 | $file['_path_components'][ $smaller_path_component ] = 1;
41 | $path_components[ $smaller_path_component ] = 1;
42 | }
43 | }
44 |
45 | $filesize = @filesize( $file['path'] );
46 |
47 | if ( empty( $filesize ) ) {
48 | $filesize = 0;
49 | }
50 |
51 | if ( $filesize > $largest_file['size'] ) {
52 | $largest_file = array(
53 | 'path' => $file['path'],
54 | 'size' => filesize( $file['path'] ),
55 | );
56 | }
57 |
58 | $components[ ( string ) $file['component']->name ] = 1;
59 | }
60 |
61 | echo '
';
62 | echo '' . esc_html( $this->collector->name() ) . '';
63 | echo '';
64 | echo '';
65 |
66 | echo '';
67 | echo $this->build_sorter( __( '', 'query-monitor-extend' ) );
68 | echo ' | ';
69 |
70 | echo '';
71 | echo $this->build_filter( 'path', array_map( 'esc_attr', array_keys( $path_components ) ), __( 'Path', 'query-monitor-extend' ) );
72 | echo ' | ';
73 |
74 | echo '';
75 | echo $this->build_sorter( __( 'Filesize', 'query-monitor-extend' ) );
76 | echo ' | ';
77 |
78 | echo '';
79 | echo $this->build_filter( 'component', array_map( 'esc_attr', array_keys( $components ) ), __( 'Component', 'query-monitor-extend' ) );
80 | echo ' | ';
81 |
82 | echo '
';
83 | echo '';
84 |
85 | echo '';
86 |
87 | $total_file_size = 0;
88 |
89 | foreach ( $data->files as $i => $file ) {
90 |
91 | $filesize = @filesize( $file['path'] );
92 |
93 | if ( empty( $filesize ) ) {
94 | $filesize = 0;
95 | }
96 |
97 | $total_file_size += $filesize;
98 |
99 | if ( ! empty( $file['has_error'] ) ) {
100 | $files_with_errors++;
101 | }
102 |
103 | echo 'name ) . '" ' .
105 | 'data-qm-path="' . esc_attr( implode( ' ', array_keys( $file['_path_components'] ) ) ) . '" ' .
106 | ( ! empty( $file['has_error'] ) ? ' class="qm-warn"' : '' ) .
107 | '>';
108 |
109 | echo '' . ( $i + 1 ) . ' | ';
110 | echo '' . QM_Output_Html::output_filename( str_replace( ABSPATH, '', $file['path'] ), $file['path'] ) . ' | ';
111 | echo '';
112 | echo ! empty( $filesize ) ? $this->human_file_size( $filesize ) : '—';
113 | echo ' | ';
114 |
115 | echo '' . esc_html( $file['component']->name ) . ' | ';
116 | echo '
';
117 | }
118 |
119 | echo '';
120 | echo '';
121 |
122 | echo '';
123 | echo '';
124 | printf(
125 | esc_html__( 'Files in filter: %s', 'query-monitor-extend' ),
126 | '' . esc_html( number_format_i18n( count( $data->files ) ) ) . ''
127 | );
128 | echo ' | ';
129 | echo '
';
130 |
131 | echo '';
132 | echo '' .
133 | 'Total: ' . esc_html( number_format_i18n( count( $data->files ) ) ) . '' .
134 | (
135 | ! empty( $files_with_errors )
136 | ? ', With error(s): ' . esc_html( number_format_i18n( $files_with_errors ) ) . ''
137 | : ''
138 | ) .
139 | ' | ';
140 | echo '=' . $this->human_file_size( $total_file_size ) . ' | ';
141 | echo 'Components: ' . count( $components ) . ' | ';
142 | echo '
';
143 |
144 | echo '';
145 | echo '
';
146 |
147 | echo '';
148 |
149 | } else {
150 |
151 | echo '
';
152 | echo '
' . esc_html__( 'None', 'query-monitor' ) . '
';
153 | echo '
';
154 |
155 | }
156 |
157 | echo '
';
158 | }
159 |
160 | /**
161 | * @param string[] $title
162 | * @return string[]
163 | */
164 | public function admin_title( array $title ) {
165 | $data = $this->collector->get_data();
166 |
167 | if ( ! empty( $data->files ) ) {
168 | $_title = sprintf( esc_html_x( '%s F', 'Files count', 'query-monitor-extend' ), number_format_i18n( count( $data->files ) ) );
169 | $_title = preg_replace( '#\s?([^0-9,\.]+)#', '