WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 7 months ago

#40454 new feature request

Make plugin activation method constant

Reported by: tazotodua Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Plugins Keywords:
Focuses: administration Cc:

Description (last modified by SergeyBiryukov)

for example, there are plugins, that redirect to it's setting spage imediately after that plugin is activated (with 'activated_plugin' hook if i correctly remember).
however, when I activate plugin in bulk, bulk activation is stopped at that specific plugin, then it redirects to its settings page.

I think, there should be something like this:

if(!BULK_PLUGIN_ACTIVATION){
    redirect.....
}

so, make something , as developer could differentiate between individual and bulk activation.

Change History (4)

#1 @soulseekah
7 months ago

Right now this is possible by doing:

<?php
$bulk_activation = (new WP_Plugins_List_Table())->current_action() == 'activate-selected';

if ( ! $bulk_activation ) {
    /** Redirect, etc. */
}

One obvious issue is that "activate-selected" might change as an action name in the future.

Same can be done with 'deactivate-selected'.

Just an idea.

Another option is to check the function call backtrace, all the way up to activate_plugin and then one more step up to see if it's activate_plugins or not.

A bit hacky, but will work, as well.

#2 @SergeyBiryukov
7 months ago

  • Component changed from General to Plugins
  • Description modified (diff)
  • Focuses administration added

#3 @SergeyBiryukov
7 months ago

Related/duplicate: #40252

#4 @johnbillion
7 months ago

  • Summary changed from Make plugin ACTIVATION method constant to Make plugin activation method constant
Note: See TracTickets for help on using tickets.