WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#29564 closed defect (bug) (invalid)

wp_get_themes() returns empty array to Network-Activated Plugin code

Reported by: adiant Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Themes Keywords:
Focuses: Cc:

Description

Function wp_get_themes() returns an array of Themes when called within a plugin, except in one situation: when the plugin is Network Activated and the function is called in "open code", not in an add_action or add_filter function.

In this situation, an empty array is returned.

There are no issues when a plugin is Site Activated in a Network or Activated on a non-Network.

Although I just found this problem now, while using Version 4.0, I have also installed 3.9.2 and found it there, as well.

Attachments (1)

wp-get-themes.zip (337 bytes) - added by adiant 6 years ago.
Upload and Network Activate this plugin to demonstrate the problem on a Site page

Download all attachments as: .zip

Change History (2)

@adiant
6 years ago

Upload and Network Activate this plugin to demonstrate the problem on a Site page

#1 @obenland
6 years ago

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

The default theme directory doesn't get registered until after must-use and network-activated plugins were loaded, and only right before plugins are loaded (ref.).

WordPress should not expect to be ready before it is, which is the init hook, or—probably more appropriate—the wp_loaded hook.

Note: See TracTickets for help on using tickets.