Skip to content

Commit ce0e220

Browse files
committed
Add extra column to assets
1 parent b7dadca commit ce0e220

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

classes/Collector_Assets.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ public function process() {
203203
}
204204
}
205205

206+
$extra = array();
207+
208+
foreach ( $dependency->extra as $key => $value ) {
209+
$extra[ $key ] = is_array( $value ) ? count( $value ) : true;
210+
}
211+
206212
$this->data->assets[ $position ][ $handle ] = array(
207213
'host' => $host,
208214
'port' => $port,
@@ -213,6 +219,7 @@ public function process() {
213219
'display' => $display,
214220
'dependents' => $dependents,
215221
'dependencies' => $dependencies,
222+
'extra' => $extra,
216223
);
217224

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

output/html/assets.php

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

@@ -102,7 +103,7 @@ public function output() {
102103

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

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

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

157166
if ( $asset['warning'] ) {
@@ -223,6 +232,7 @@ protected function dependency_row( $handle, array $asset, $label ) {
223232
echo '</td>';
224233
echo '<td class="qm-ltr qm-highlighter" data-qm-highlight="' . esc_attr( implode( ' ', $highlight_dependents ) ) . '">' . implode( ', ', array_map( 'esc_html', $asset['dependents'] ) ) . '</td>';
225234
echo '<td class="qm-ltr">' . esc_html( $asset['ver'] ) . '</td>';
235+
echo '<td>' . implode( ', ', array_map( 'esc_html', $extra ) ) . '</td>';
226236

227237
echo '</tr>';
228238
}

0 commit comments

Comments
 (0)