WordPress.org

Make WordPress Core

Opened 12 months ago

Last modified 3 months ago

#24205 reopened enhancement

is_plugin_active() should return true for must-use/dropin plugins

Reported by: jrf Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5.1
Component: Plugins Keywords: has-patch
Focuses: Cc:

Description

As must-use plugins/dropins are automatically active, the expected behaviour for is_plugin_active() would be to return true. In reality it returns false.

Easy enough to reproduce and test - just add a plugin to the must-use directory and test with:

if( is_plugin_active( 'plugin-name.php' ) ) {
	echo 'plugin is active';
}
else {
	echo 'plugin does not seem to be active';
}

Hope this helps

Attachments (2)

24205.patch (1.0 KB) - added by rcoll 8 months ago.
add second arg and on true will search other locations
24205.2.patch (1.0 KB) - added by noam@… 3 months ago.
Sane default

Download all attachments as: .zip

Change History (10)

comment:1 nacin12 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

must-use plugins and drop-ins don't have a concept of "activation".

If you want to see if a plugin is active on a site, is_plugin_active() is a poor way to do it. The path can be anything. A plugin could be installed at test-plugin/test-plugin.php, test-plugin.php, or some-totally-different-name.php. You should look for a function, class, etc.

comment:2 follow-up: jrf12 months ago

Hi Nacin,

I totally agree that there are better ways to test for it, however that does *not* invalidate my report.
When someone uses the is_plugin_active() function, one would expect must-use plugins to report true as - like you say - they don't need activation, they are *always* active when loaded that way.

Smile,
Juliette

comment:3 in reply to: ↑ 2 MikeSchinkel12 months ago

Replying to jrf:

When someone uses the is_plugin_active() function, one would expect must-use plugins to report true as - like you say - they don't need activation, they are *always* active when loaded that way.

There's definitely some solid logic here...

comment:4 knutsp12 months ago

Because the must-use plugins and drop-ins can't be deactivated, once installed, the function should return true. It would make it more useful, telling that these extensions are installed, and therefore active.

But it isn't a bug. It's an enhancement. Suggest a new ticket.

comment:5 SergeyBiryukov12 months ago

  • Milestone set to Awaiting Review
  • Resolution wontfix deleted
  • Status changed from closed to reopened
  • Summary changed from is_plugin_active() returns false for must-use/dropin plugins to is_plugin_active() should return true for must-use/dropin plugins
  • Type changed from defect (bug) to enhancement

comment:6 jrf12 months ago

Call it whatever you like ;-) The re-open is much appreciated <3

rcoll8 months ago

add second arg and on true will search other locations

comment:7 rcoll8 months ago

  • Keywords has-patch added

Added patch will accept a second (optional) boolean argument and check mu-plugins and drop-ins on true. This way, we retain full backward-compatibility as well as accommodate the added functionality.

noam@…3 months ago

Sane default

comment:8 noam@…3 months ago

Added sane default.

$check_all now defaults to true.

Note: See TracTickets for help on using tickets.