Skip to content

Commit f6f648f

Browse files
committed
Add extra column to assets
1 parent 5281b10 commit f6f648f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

classes/Collector_Assets.php

+7
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ public function process() {
197197
}
198198
}
199199

200+
$extra = array();
201+
202+
foreach ( $dependency->extra as $key => $value ) {
203+
$extra[ $key ] = is_array( $value ) ? count( $value ) : true;
204+
}
205+
200206
$this->data->assets[ $position ][ $handle ] = array(
201207
'host' => $host,
202208
'port' => $port,
@@ -207,6 +213,7 @@ public function process() {
207213
'display' => $display,
208214
'dependents' => $dependents,
209215
'dependencies' => $dependencies,
216+
'extra' => $extra,
210217
);
211218

212219
$this->data->counts[ $position ]++;

output/html/assets.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function output() {
8282
echo $this->build_filter( $type . '-dependents', $data->dependents, __( 'Dependents', 'query-monitor' ) ); // WPCS: XSS ok.
8383
echo '</th>';
8484
echo '<th scope="col">' . esc_html__( 'Version', 'query-monitor' ) . '</th>';
85+
echo '<th scope="col">' . esc_html__( 'Extra', 'query-monitor' ) . '</th>';
8586
echo '</tr>';
8687
echo '</thead>';
8788

@@ -101,7 +102,7 @@ public function output() {
101102

102103
echo '<tr>';
103104
printf(
104-
'<td colspan="7">%1$s</td>',
105+
'<td colspan="8">%1$s</td>',
105106
sprintf(
106107
esc_html( $type_label['total'] ),
107108
'<span class="qm-items-number">' . esc_html( number_format_i18n( $data->counts['total'] ) ) . '</span>'
@@ -151,6 +152,14 @@ protected function dependency_row( $handle, array $asset, $label ) {
151152

152153
$qm_host = ( $asset['local'] ) ? 'local' : __( 'Other', 'query-monitor' );
153154

155+
$extra = array();
156+
157+
if ( ! empty( $asset['extra'] ) ) {
158+
foreach ( $asset['extra'] as $key => $count ) {
159+
$extra[] = $key . ( is_numeric( $count ) ? ' (' . $count . ')' : '' );
160+
}
161+
}
162+
154163
$class = '';
155164

156165
if ( $asset['warning'] ) {
@@ -222,6 +231,7 @@ protected function dependency_row( $handle, array $asset, $label ) {
222231
echo '</td>';
223232
echo '<td class="qm-ltr qm-highlighter" data-qm-highlight="' . esc_attr( implode( ' ', $highlight_dependents ) ) . '">' . implode( ', ', array_map( 'esc_html', $asset['dependents'] ) ) . '</td>';
224233
echo '<td class="qm-ltr">' . esc_html( $asset['ver'] ) . '</td>';
234+
echo '<td>' . implode( ', ', array_map( 'esc_html', $extra ) ) . '</td>';
225235

226236
echo '</tr>';
227237
}

0 commit comments

Comments
 (0)