#60992
closed
defect (bug)
( fixed )
Plugin management: AJAX plugin activation consequences
|
|
|
|
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Description
-
The plugin's feature may be available right away. -
The plugin may require some configuration before it can be used ; this is often handled via options on a custom Settings screen created with the Settings API.
-
Upon activating the plugin, they are redirected to the settings screen. This is often done via the activated_plugin hook ( reference ). It has been around since WP 2.9. -
Upon activating the plugin, they are redirected to the Plugins list table, where they see a "Settings" link next to the plugin they just activated. This is often done via the plugin_action_links_{$plugin_file} hook ( reference ), introduced in WP 2.7. -
Upon activating the plugin, they are redirected to the Plugins list table and scan their WordPress navigation menu to search for the new menu item, and thus the next step in the setup.
Attachments (2)
Change History (109)
#1
follow-ups:
↓ 2
↓ 4
@
2 months ago
#3
@
8 weeks ago
#4
in reply to: ↑ 1
@
8 weeks ago
I'd argue that we'd need to consider alternatives for options 2 and 3, but 1 interrupts bulk activations and is imho quite obnoxious.
#5
@
8 weeks ago
#6
follow-up:
↓ 8
@
8 weeks ago
-
The plugin tells the user by sending the user to the configuration screen. -
The plugin tells the user by adding a small piece of text in the middle of a long table. -
The plugin expects the user to find the plugin's entry in the Dashboard menu, click on it, and locate the configuration screen.
-
Option 1 is bad because, as most commonly implemented, it breaks bulk activation. -
Option 2 is bad for discoverability reasons. -
Option 3 is bad for discoverability reasons, especially for plugins which don't implement a top-level Dashboard menu item. -
Option 4, the admin notice, is in my opinion the most-reliable method of getting a message to the user, because it creates a persistent to-do list item at the top of the Dashboard.
-
Add a WP-REST API endpoint to return admin notices, building upon #57791 -
On the frontend JS handler for AJAX plugin activation success/error, add a post-activation check for Admin Notices. This should run after the activation check as a separate request to the new REST API endpoint, in order to ensure that plugins' code is loaded at runtime. -
Dynamically insert Admin Notices in the usual spot.
-
gives the post-AJAX-activation screen feature parity with the screen shown after a page reload: notices are now displayed -
doesn't add any new APIs for plugin developers -
doesn't require developers who rely on Admin Notices for configuration nags to change anything -
does effectively endorse the use of Admin Notices for configuration nags -
does create a new REST API endpoint
#7
@
8 weeks ago
<a class="button button-disabled" data-slug="duplicate-post" href=" http://activation.local/wp-admin/plugins.php?_wpnonce=89f0a7c70e& ; action=activate&plugin=duplicate-post/duplicate-post.php" aria-label="Yoast Duplicate Post 4.5 activated successfully." data-name="Yoast Duplicate Post" data-plugin="duplicate-post/duplicate-post.php">Active</a>
<button type="button" class="button button-disabled" disabled="disabled">Active</button>
#8
in reply to: ↑ 6
@
8 weeks ago
I'm going to propose a way forward, which doesn't involve reverting #22316 , but which involves adding additional functionality to WordPress. I'm not prepared to implement this, so please consider it as a seed crystal for discussion, not as an actual proposal.
Consider the three scenarios in this ticket, and how plugins handled telling the user in non-AJAX that configuration is needed:
The plugin tells the user by sending the user to the configuration screen. The plugin tells the user by adding a small piece of text in the middle of a long table. The plugin expects the user to find the plugin's entry in the Dashboard menu, click on it, and locate the configuration screen.
I'll add a fourth communication method, which has been controversial in the past: an Admin Notice nag which only goes away once the plugin is configured or deactivated.
Of these:
Option 1 is bad because, as most commonly implemented, it breaks bulk activation. Option 2 is bad for discoverability reasons. Option 3 is bad for discoverability reasons, especially for plugins which don't implement a top-level Dashboard menu item. Option 4, the admin notice, is in my opinion the most-reliable method of getting a message to the user, because it creates a persistent to-do list item at the top of the Dashboard.
Here's my proposal:
Add a WP-REST API endpoint to return admin notices, building upon #57791 On the frontend JS handler for AJAX plugin activation success/error, add a post-activation check for Admin Notices. This should run after the activation check as a separate request to the new REST API endpoint, in order to ensure that plugins' code is loaded at runtime. Dynamically insert Admin Notices in the usual spot.
This approach:
gives the post-AJAX-activation screen feature parity with the screen shown after a page reload: notices are now displayed doesn't add any new APIs for plugin developers doesn't require developers who rely on Admin Notices for configuration nags to change anything does effectively endorse the use of Admin Notices for configuration nags does create a new REST API endpoint
#9
@
8 weeks ago
#10
follow-up:
↓ 12
@
8 weeks ago
#11
@
8 weeks ago
#12
in reply to: ↑ 10 ; follow-up:
↓ 14
@
8 weeks ago
With redirect hijacking aside, we're now left with the justifiable issue of guiding people to the next actionable step from the plugin activation screen.
-
If your plugin registers a CPT, the dedicated admin menu will not appear until you refresh. -
If your plugin registers a settings page, that page will not be visible or accessible until you refresh.
A step up from this would be allowing users to provide an
activation_success_message that could be displayed on the screen. This would also fill the gap caused by the lack of new links in the Admin Menu/Bar
A simple, non-intrusive solve that's also forward-compatible with whatever other reactive Admin UI updates would be changing the success notices to add something along the lines of 'Go to your <link>Dashboard</link> to see the changes'.
-
If the plugin has a declared dependency, keep the behavior introduced in WordPress 6.5 ; site owners remain on the Plugin install screen and install other plugins. -
If the plugin does not declare dependency, redirect site owners to the Plugins screen like we did in WordPress 6.4 and earlier. This option would offer a similar result to your proposal, except site owners would not have to read and click to be redirected and thus refresh the screen.
This ticket was mentioned in Slack in #core-test by ankit-k-gupta. View the logs .
8 weeks ago
#14
in reply to: ↑ 12
@
8 weeks ago
Replying to justlevine :
A step up from this would be allowing users to provide an
activation_success_message that could be displayed on the screen. This would also fill the gap caused by the lack of new links in the Admin Menu/Bar
I'm afraid the current implementation will not allow us to do that, since even if plugin authors were to hook into a potential new filter, that code would not run until a page refresh.
#15
follow-up:
↓ 17
@
8 weeks ago
#16
@
8 weeks ago
#17
in reply to: ↑ 15
@
8 weeks ago
I am finding this discussion very frustrating, The solutions offered here, should have been discussed before someone took it upon themselves to make this major change. I am befuddled to say the least. Just revert it, if it's good enough for Woo after making a bad decision, its good enough for us, right?
#18
@
8 weeks ago
-
Whether to revert the entire AJAX activation feature -
What features would be needed to support plugin activation workflows in an AJAX activation workflow — and whether it would be easier to add those features instead of first reverting the AJAX activation feature.
#19
@
8 weeks ago
#20
@
8 weeks ago
@flixos90
@afragen @costdev Can you share any context here you may have? Activating plugins via AJAX without reloading the page is breaking expected behavior, and I'm not sure whether this was considered when plugin dependencies were introduced.
So far I tend to think the AJAX activation part needs to be reverted.
#21
@
8 weeks ago
#22
follow-up:
↓ 44
@
8 weeks ago
#23
@
8 weeks ago
Follow up question: Why does any of the functionalities need AJAX? I would think anything we do via AJAX we could also do via hitting a specific "action URL" and then redirecting back (like was done before)?
This ticket was mentioned in Slack in #core by jorbin. View the logs .
8 weeks ago
#25
@
8 weeks ago
-
Milestone changed from Awaiting Review to 6.5.3
#26
@
8 weeks ago
-
Can or should WordPress facilitate a more seamless entry into an onboarding flow? If so, how? -
Should/can WordPress be doing more to reflect successful activation, such as by refreshing menus, etc.?
#27
@
8 weeks ago
#28
follow-up:
↓ 29
@
8 weeks ago
#29
in reply to: ↑ 28
@
8 weeks ago
@flixos90 @DrewAPicture What do you think about re-enabling the redirect only for the
Activate buttons in the plugin cards to resolve this for 6.5.3, and address redirect removal in favour of "live" (AJAX/Interactivity API basically) admin menus, notices, pointers, etc as part of / a follow-up to the admin redesign project?
This ticket was mentioned in PR #6398 on WordPress/wordpress-develop by @costdev .
8 weeks ago
#30
-
Keywords has-patch added
#31
@
8 weeks ago
-
Keywords needs-testing added
#32
follow-up:
↓ 33
@
8 weeks ago
-
Keywords has-testing-info added
Testing Instructions
Steps to Reproduce
-
Navigate to Plugins > Add New . -
Search for WooCommerce . -
Click Install Now . -
🐞 Click Activate . -
Deactivate and delete WooCommerce. -
Apply the patch . -
Build core. -
Navigate to Plugins > Add New . -
Search for WooCommerce. -
Perform a hard refresh to ensure the cache is cleared. -
Click Activate .
Expected Results
-
❌ The Activate button should activate WooCommerce without refreshing the page.
-
✅ The Activate button should activate WooCommerce and redirect, either to the WooCommerce onboarding experience, or to Plugins > Installed plugins , depending on whether the _wc_activation_redirect transient is set to one (1 = show, 0 = don't show)
#33
in reply to: ↑ 32
@
8 weeks ago
#34
@
7 weeks ago
#35
@
7 weeks ago
-
In the PHP AJAX callback: apply_filters( 'wp_plugin_activated_message', '', $status['plugin'] ) and add a non-empty message to the response (sanitized/escaped as needed) -
In wp.updates.activatePluginSuccess() : If not inside a modal and a message is present, output the message via wp.updates.addAdminNotice( { className: 'notice notice-success', message: response.message } )
@costdev commented on PR #6398 :
7 weeks ago
#36
@webdevmattcrom commented on PR #6398 :
7 weeks ago
#37
@costdev commented on PR #6398 :
7 weeks ago
#38
@jeherve commented on PR #6398 :
7 weeks ago
#39
this creates a very cumbersome flow.
-
Search > Install > Activate -
Search > Install > Activate > Configure (create new post in CPT, change settings, ...) -
Search > Install > Activate > Search > Install > Activate > ... > Configure (create new post in CPT, change settings, ...)
What we need is a way for users to know how to move forward.
In that regard, I think this is where the
wp.updates.addAdminNotice() could come in.
@costdev commented on PR #6398 :
7 weeks ago
#40
The notice seems like a nice way to let the user know about the next step without interrupting the flow. With that in mind, maybe this PR should be abandoned in favor of just the notice, displayed after each AJAX plugin installation.
@
7 weeks ago
#41
@
7 weeks ago
This ticket was mentioned in Slack in #core-upgrade-install by afragen. View the logs .
7 weeks ago
This ticket was mentioned in Slack in #core by jorbin. View the logs .
7 weeks ago
#44
in reply to: ↑ 22
@
7 weeks ago
Regarding the plugins redirecting, I tend to agree this is a poor pattern.
IMO the more pressing reason to fix this is that plugins with a new admin menu item, admin notice, or admin pointer no longer can show these right after activation.
This ticket was mentioned in PR #6401 on WordPress/wordpress-develop by @costdev .
7 weeks ago
#45
-
AJAX-based activation remains as was intended by the Plugin Dependencies feature, and originally intended by the Shiny Updates feature. -
The user is informed that changes may not occur until the page is refreshed. -
The user's flow isn't assumed, and the user retains the choice of whether to continue installing and activating plugins, or to refresh the page.
#46
@
7 weeks ago
#47
@
7 weeks ago
Testing Instructions for PR 6401
Steps to Reproduce/Test
-
Navigate to Plugins > Add New . -
Search for WooCommerce . -
Click Install Now . -
🐞 Click Activate . -
Navigate to Plugins > Installed Plugins . -
Deactivate WooCommerce. -
Apply the patch . -
Build core. -
Navigate to Plugins > Add New . -
Search for WooCommerce. -
Perform a hard refresh to ensure the cache is cleared. -
Click Activate .
Expected Results
-
❌ The Activate button should activate WooCommerce without refreshing the page, but doesn't inform the user of what they may need to do next.
-
✅ The Activate button should activate WooCommerce without refreshing the page, and a notice should appear to inform the user of what they may need to do next.
Additional testing option
-
Deactivate WooCommerce, then instead of clicking the Activate button in its plugin card, click its More Details link and click the Activate button inside the modal. The admin notice should appear on the screen behind the modal.
@jeherve commented on PR #6401 :
7 weeks ago
#48
@costdev commented on PR #6401 :
7 weeks ago
#49
#50
@
7 weeks ago
-
Keywords needs-design-feedback added
#52
@
7 weeks ago
#53
@
7 weeks ago
#54
@
7 weeks ago
register_activation_hook( $file, $callback, $url = '' )
#55
@
7 weeks ago
We really should create a ticket for any onboarding solutions as this would be an enhancement.
This ticket was mentioned in Slack in #core by jorbin. View the logs .
7 weeks ago
#57
@
7 weeks ago
#58
follow-up:
↓ 59
@
7 weeks ago
#59
in reply to: ↑ 58
@
7 weeks ago
It was mentioned in a support ticket I have on WordPress.org that this ticket may be related to my issue.
#60
@
7 weeks ago
#61
@
7 weeks ago
-
After clicking Activate in a plugin's card. -
After clicking More details to open a plugin's modal, then clicking Activate . -
After clicking on a dependency's More details to open the dependency's modal, then clicking Activate .
#62
@
7 weeks ago
This ticket was mentioned in Slack in #core by jorbin. View the logs .
7 weeks ago
#64
@
7 weeks ago
@costdev commented on PR #6401 :
7 weeks ago
#65
-
A notice is added to the top of Plugins > Add New , with a button to refresh the page.
-
A notice is added to the bottom of a plugin's modal, which replaces the previous Active button, and the notice contains a button to refresh the page.
@jeherve commented on PR #6401 :
6 weeks ago
#67
A notice is added to the bottom of a plugin's modal, which replaces the previous Active button, and the notice contains a button to refresh the page.
@costdev commented on PR #6401 :
6 weeks ago
#68
@jeherve What would you think about aligning the button to the right, so it effectively replaces the "Active" button?
@jeherve commented on PR #6401 :
6 weeks ago
#69
I'm not sure that the notice at the top of the page is going to be sufficient to inform users. It feels easy to miss, especially on small screens where you are most likely to have scrolled down the page. I wonder if it would be best to be brought inline to the card?
@costdev commented on PR #6401 :
6 weeks ago
#70
#71
@
6 weeks ago
#72
@
6 weeks ago
#73
follow-up:
↓ 76
@
6 weeks ago
#74
follow-up:
↓ 77
@
6 weeks ago
This ticket was mentioned in Slack in #core by jorbin. View the logs .
6 weeks ago
#76
in reply to: ↑ 73 ; follow-up:
↓ 79
@
6 weeks ago
If the "Refresh Now" button accomplishes the redirect just by triggering the activation hook on the next page load, then we still have an issue of user control. Say the user does not refresh the page and instead decides they are going to view their Posts, Pages, or any other screen in WP Admin. That choice is going to trigger the redirect into an onboarding screen they explicitly chose not to visit (which is how WP 6.5.2 behaves today). Alternatively if they do choose to "Refresh Now" then the expectation is that the current page actually refreshes, not that it it might lead to an onboarding experience depending on which plugin was last installed. In an attempt to halfway cater to the use of redirects, we now have multiple situations where a user ends up somewhere they didn't expect to go.
#77
in reply to: ↑ 74
@
6 weeks ago
Additionally, The reason why auto-redirecting isn't a good option right now is the question of when do you do that in a multi install process? If your goal is to install a plugin with a dependency, should that dependency redirect you away from installing the plugin you wanted to install to begin with?
#78
@
6 weeks ago
Maybe I don't quite get the reasoning behind multiinstall in the first place.
Please correct me if I'm wrong, but it seems pretty niche to me.
However, I'd love to know how many plugins of the 60,000 use or plan to use multi plugin dependencies.
#79
in reply to: ↑ 76
@
6 weeks ago
This is true, what the 'user' expects is when they hit 'activate' that the plugin 'activates' which from a user persepctive includes the onboarding experience.
#80
follow-up:
↓ 81
@
6 weeks ago
var noticeData = { id: 'plugin-activated-successfully', className: 'notice notice-success', message: sprintf( /* translators: %s: The plugin's name. */ __( 'Your custom %s was activated successfully. Some changes may not occur until you refresh the page.' ), response.pluginName ) };
#81
in reply to: ↑ 80
@
6 weeks ago
is there, will there, can there be an easy, consistent method to overide the noticeData.message so specific plugins can override?
#82
@
6 weeks ago
{ "core": "WordPress/wordpress-develop#6401",
#83
@
6 weeks ago
#84
@
6 weeks ago
This ticket was mentioned in Slack in #core by jorbin. View the logs .
6 weeks ago
#86
follow-up:
↓ 87
@
6 weeks ago
-
Keywords commit added
#87
in reply to: ↑ 86
@
6 weeks ago
-
Keywords i18n-change added
Once it's committed and backported, #polyglots should be given a heads-up about the new string so it can get translated before 6.5.3
#88
@
5 weeks ago
Test Report
Environment
-
Hardware: MacBook Pro Apple M1 Pro -
OS: macOS 14.4.1 -
Browser: Safari 17.4.1, Google Chrome 124.0.6367.94 -
Server: nginx/1.25.5 -
PHP: 8.2.18 -
MySQL: 8.0.27 -
WordPress: 6.6-alpha-57778-src -
Plugin used for testing: WooCommerce (WC)
Actual Results
-
✅ Activation from Installed Plugins page (main list) redirects to WC setup. -
✅ Activation from Add Plugins page shows admin notice to refresh ( Figure 1 ), -
✅ Activation from Add Plugins > More Details modal shows notice to refresh in footer of modal ( Figure 2 ). -
✅ Clicking the notices' "Refresh Now" buttons began the WC plugin setup, or refreshed the page when setup had already been started/completed. -
⚠️ After new WC activation, opening the More Details modal before "refreshing" (via notice button, navigation, or manual refresh) results in the WC plugin setup wizard starting inside the modal. This could affect compatibility with plugin post-install redirects, though, to be honest, I'm unsure if this is an implementation bug or should be resolved by extenders. See this link for a demonstration of this unexpected behavior .
Additional Notes
-
Used wp transient set _wc_activation_redirect 1 between tests to mimic a new WC install . -
Safari + 1Password extension users may experience an issue whereby the new notice does NOT appear. If your JS console has the error Retrieving "b5x-stateful-inline-icon" flag errored: timed out - falling back , this is due to a known 1P extension bug . Disable the extension to work around the issue.
Supplemental Artifacts
#89
@
5 weeks ago
#90
@
5 weeks ago
#92
@
5 weeks ago
-
Keywords fixed-major dev-feedback added -
Resolution fixed deleted -
Status changed from closed to reopened
#95
@
5 weeks ago
#96
@
4 weeks ago
@johnbillion commented on PR #6401 :
4 weeks ago
#97
This ticket was mentioned in Slack in #hosting by javier. View the logs .
3 weeks ago
#101
@
9 days ago
-
Keywords commit fixed-major dev-reviewed removed -
Resolution fixed deleted -
Status changed from closed to reopened
Sure, 68081 (trunk) and 68083 (6.5) should be reverted. They are part of a solution that did not achieve the intended result fully, and have been replaced, not extended, with a different solution for 6.5. If we want to introduce them later, then we still have the code stored in history to save us some time.
I'm not sure if it will be a clean revert since [58250] also changed some of these lines, but I would support reverting the functionality
This ticket was mentioned in Slack in #core by jorbin. View the logs .
9 days ago
#104
@
9 days ago
-
Keywords commit dev-reviewed fixed-major added -
Resolution set to fixed -
Status changed from reopened to closed
Since #60992 was completed on a closed milestone my thought is a new ticket for historical tracking purposes. (with a see to the original ticket on the commit)