Skip to content
Merged
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
42 changes: 42 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 @@ -224,6 +227,9 @@ function perflab_enqueue_features_page_scripts() {
wp_enqueue_script( 'thickbox' );
wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'plugin-install' );

// Enqueue the a11y script.
wp_enqueue_script( 'wp-a11y' );
}

/**
Expand Down Expand Up @@ -393,3 +399,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
Copy Markdown
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;
Comment thread
mukeshpanchal27 marked this conversation as resolved.

wp.a11y.speak(message);
Comment thread
mukeshpanchal27 marked this conversation as resolved.

Copy link
Copy Markdown
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' ) )

@westonruter westonruter Apr 30, 2024

Copy link
Copy Markdown
Member

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' )
);
}