Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra column to assets #793

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions classes/Collector_Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ public function process() {
}
}

$extra = array();

foreach ( $dependency->extra as $key => $value ) {
$extra[ $key ] = is_array( $value ) ? count( $value ) : true;
}

$this->data->assets[ $position ][ $handle ] = array(
'host' => $host,
'port' => $port,
Expand All @@ -213,6 +219,7 @@ public function process() {
'display' => $display,
'dependents' => $dependents,
'dependencies' => $dependencies,
'extra' => $extra,
);

$this->data->counts[ $position ]++;
Expand Down
12 changes: 11 additions & 1 deletion output/html/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function output() {
echo $this->build_filter( $type . '-dependents', $data->dependents, __( 'Dependents', 'query-monitor' ) ); // WPCS: XSS ok.
echo '</th>';
echo '<th scope="col">' . esc_html__( 'Version', 'query-monitor' ) . '</th>';
echo '<th scope="col">' . esc_html__( 'Extra', 'query-monitor' ) . '</th>';
echo '</tr>';
echo '</thead>';

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

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

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

$extra = array();

if ( ! empty( $asset['extra'] ) ) {
foreach ( $asset['extra'] as $key => $count ) {
$extra[] = $key . ( is_numeric( $count ) ? ' (' . $count . ')' : '' );
}
}

$class = '';

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

echo '</tr>';
}
Expand Down