Skip to content
Merged
Changes from 4 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
39 changes: 39 additions & 0 deletions includes/admin/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ function perflab_load_features_page() {

// Handle style for settings page.
add_action( 'admin_head', 'perflab_print_features_page_style' );

// Handle script for settings page.
add_action( 'admin_footer', 'perflab_print_plugin_progress_indicator_script' );
}

/**
Expand Down Expand Up @@ -393,3 +396,39 @@ static function ( $name ) {
);
}
}

/**
* Callback function that print plugin progress indicator script.
*
* @since n.e.x.t
*/
function perflab_print_plugin_progress_indicator_script() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, per #1188, might as well explicitly make this return void:

function perflab_print_plugin_progress_indicator_script(): void {

$js_function = <<<JS
function addPluginProgressIndicator( message ) {
document.addEventListener( 'DOMContentLoaded', function () {
document.addEventListener( 'click', function ( event ) {
if (
event.target.classList.contains(
'perflab-install-active-plugin'
)
) {
const target = event.target;
target.classList.add( 'updating-message' );
target.textContent = message;

wp.a11y.speak(message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add spacing around the message param

}
} );
} );
}
JS;

wp_print_inline_script_tag(
sprintf(
'( %s )( %s );',
$js_function,
wp_json_encode( __( 'Activating…', 'default' ) )
Copy link
Member

@westonruter westonruter Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that this is 'Activating…' when the core string appears to rather be 'Activating...' (not using the ellipsis):

https://github.com/WordPress/wordpress-develop/blob/f9e5c6fb22a331746a1821e393c9ea6a6e6d70a0/src/js/_enqueues/wp/updates.js#L1090

Does this need to be amended?

),
array( 'type' => 'module' )
);
}