Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
crstauf committed Jul 29, 2024
1 parent bf628d2 commit cb2da1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
9 changes: 2 additions & 7 deletions classes/Collector_Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ public function process() {

$this->data->registered = array_keys( $raw->registered );

sort( $this->data->registered );

// A broken asset is one which has been deregistered without also being dequeued
if ( ! empty( $broken ) ) {
foreach ( $broken as $key => $handle ) {
Expand Down Expand Up @@ -173,18 +171,14 @@ public function process() {
}

/** @var string $handle */
foreach ( $this->data->{$position} as $handle ) {
foreach ( $this->data->{$position} as $index => $handle ) {
/** @var _WP_Dependency|false $dependency */
$dependency = $raw->query( $handle );

if ( ! $dependency ) {
continue;
}

if ( 'registered' === $position && in_array( $handle, $processed ) ) {
continue;
}

$all_dependencies = array_merge( $all_dependencies, $dependency->deps );
$dependents = $this->get_dependents( $dependency, $raw );
$all_dependents = array_merge( $all_dependents, $dependents );
Expand Down Expand Up @@ -215,6 +209,7 @@ public function process() {
}

$this->data->assets[ $position ][ $handle ] = array(
'index' => $index,
'host' => $host,
'port' => $port,
'source' => $source,
Expand Down
29 changes: 15 additions & 14 deletions output/html/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function output() {
echo '<thead>';
echo '<tr>';
echo '<th scope="col">' . esc_html__( 'Position', 'query-monitor' ) . '</th>';
echo '<th scope="col">' . esc_html__( 'Handle', 'query-monitor' ) . '</th>';
echo '<th scope="col" class="qm-sorted-asc qm-sortable-column" role="columnheader" aria-sort="ascending">';
echo $this->build_sorter( 'Handle' ); // WPCS: XSS ok;
echo '</th>';
echo '<th scope="col" class="qm-filterable-column">';
$args = array(
'prepend' => array(
Expand Down Expand Up @@ -115,18 +117,14 @@ public function output() {

$this->before_tabular_output( $this->collector->id() . '-registered', __( 'Registered', 'query-monitor' ) );

/* translators: %s: "styles" or "scripts" */
$caption_format = esc_html__( 'Enqueued %s are not included.', 'query-monitor' );

printf(
'<caption><h2 id="%1$s-caption">%2$s</h2></caption>',
esc_attr( $this->collector->id() . '-registered' ),
esc_html( sprintf( $caption_format, strtolower( $type_label['plural'] ) ) )
);

echo '<thead>';
echo '<tr>';
echo '<th scope="col">' . esc_html__( 'Handle', 'query-monitor' ) . '</th>';
echo '<th scope="col" class="qm-sorted-asc qm-sortable-column" role="columnheader" aria-sort="ascending">';
echo $this->build_sorter( '#' ); // WPCS: XSS ok;
echo '</th>';
echo '<th scope="col" class="qm-sorted-asc qm-sortable-column" role="columnheader" aria-sort="ascending">';
echo $this->build_sorter( 'Handle' ); // WPCS: XSS ok;
echo '</th>';
echo '<th scope="col" class="qm-filterable-column">';
$args = array(
'prepend' => array(
Expand All @@ -150,7 +148,7 @@ public function output() {

if ( ! empty( $data->assets['registered'] ) ) {
foreach ( $data->assets['registered'] as $handle => $asset ) {
$this->dependency_row( $handle, $asset, '' );
$this->dependency_row( $handle, $asset, $asset['index'] );
}
}

Expand Down Expand Up @@ -221,7 +219,7 @@ protected function dependency_row( $handle, array $asset, $label ) {

echo '<tr data-qm-subject="' . esc_attr( $type . '-' . $handle ) . '" data-qm-' . esc_attr( $type ) . '-host="' . esc_attr( $qm_host ) . '" data-qm-' . esc_attr( $type ) . '-dependents="' . esc_attr( $dependents_list ) . '" data-qm-' . esc_attr( $type ) . '-dependencies="' . esc_attr( $dependencies_list ) . '" class="' . esc_attr( $class ) . '">';

if ( $label !== '' ) {
if ( is_string( $label ) ) {
echo '<td class="qm-nowrap">';

$warning = QueryMonitor::icon( 'warning' );
Expand All @@ -233,6 +231,9 @@ protected function dependency_row( $handle, array $asset, $label ) {

echo esc_html( $label );
echo '</td>';
} else if ( is_numeric( $label ) ) {

Check failure on line 234 in output/html/assets.php

View workflow job for this annotation

GitHub Actions / PHP / PHP 8.2 / PHP / PHP 8.2

Else branch is unreachable because previous condition is always true.

Check failure on line 234 in output/html/assets.php

View workflow job for this annotation

GitHub Actions / PHP / PHP 7.4 / PHP / PHP 7.4

Else branch is unreachable because previous condition is always true.
$label = absint( $label ) + 1;
echo '<th scope="row" class="qm-row-num qm-num">' . $label . '</th>';
}

$host = $asset['host'];
Expand All @@ -250,7 +251,7 @@ protected function dependency_row( $handle, array $asset, $label ) {
$host = "{$host}:{$asset['port']}";
}

echo '<td class="qm-nowrap qm-ltr">' . esc_html( $handle ) . '</td>';
echo '<td class="qm-nowrap qm-ltr" data-qm-sort-weight="' . esc_attr( $handle ) . '">' . esc_html( $handle ) . '</td>';
echo '<td class="qm-nowrap qm-ltr">' . esc_html( $host ) . '</td>';
echo '<td class="qm-ltr">';
if ( $asset['source'] instanceof WP_Error ) {
Expand Down

0 comments on commit cb2da1e

Please sign in to comment.