Make WordPress Core

Opened 10 years ago

Last modified 5 years ago

#30459 new defect (bug)

is_child_theme() cannot be used during plugin activation as is

Reported by: cais's profile cais Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Themes Keywords: has-patch bulk-reopened
Focuses: Cc:

Description

I was developing a plugin that was based on a specific theme (or any child-theme of the theme) and tried to use is_child_theme() as part of the activation/compatibility tests.

It appears is_child_theme() is trying to use undefined constants at this point, this being the case the easiest solution I am seeing is to use the constant definitions in is_child_theme() versus using the constants themselves.

With the constants an error is thrown when the plugin is activated, with the function calls no errors are thrown.

See simple patch to change is_child_theme() from using constants to using the actual function calls.

Attachments (1)

30459.patch (330 bytes) - added by cais 10 years ago.
Patch of ../wp-includes/theme.php

Download all attachments as: .zip

Change History (4)

@cais
10 years ago

Patch of ../wp-includes/theme.php

#1 @johnbillion
10 years ago

  • Component changed from General to Themes
  • Keywords has-patch added
  • Version changed from trunk to 3.0

#2 @obenland
9 years ago

We should probably find another solution, see https://core.trac.wordpress.org/ticket/18298#comment:31.

#5 @rramo012
5 years ago

  • Keywords bulk-reopened added

This is still a valid ticket as of WordPress 5.2. If this function is used within the setup_theme hook or earlier, the warning will be thrown.

Warning: Use of undefined constant TEMPLATEPATH - assumed 'TEMPLATEPATH' (this will throw an Error in a future version of PHP) in
wp-includes\theme.php on line 152
Note: See TracTickets for help on using tickets.