-
Notifications
You must be signed in to change notification settings - Fork 138
Add Progress indicator when activating a feature #1190
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -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() { | ||
| $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; | ||
mukeshpanchal27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| wp.a11y.speak(message); | ||
mukeshpanchal27 marked this conversation as resolved.
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Add spacing around the |
||
| } | ||
| } ); | ||
| } ); | ||
| } | ||
| JS; | ||
|
|
||
| wp_print_inline_script_tag( | ||
| sprintf( | ||
| '( %s )( %s );', | ||
| $js_function, | ||
| wp_json_encode( __( 'Activating…', 'default' ) ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized that this is Does this need to be amended? |
||
| ), | ||
| array( 'type' => 'module' ) | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
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: