[wp-trac] [WordPress Trac] #62244: Just-in-time translation loading for plugins/themes not in the directory
WordPress Trac
noreply at wordpress.org
Tue Nov 26 12:46:04 UTC 2024
#62244: Just-in-time translation loading for plugins/themes not in the directory
--------------------------------------+-------------------------
Reporter: swissspidy | Owner: swissspidy
Type: enhancement | Status: reopened
Priority: normal | Milestone: 6.8
Component: I18N | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-dev-note | Focuses:
--------------------------------------+-------------------------
Comment (by swissspidy):
I couldn't reproduce this at first, but then I realized you are using the
[https://github.com/norcross/airplane-
mode/tree/a8a8047853dbacf417c723f46a7a3dc0c2c71aee current version from
GitHub] (0.2.7), which is newer than the one from the plugin directory
(0.2.5).
The problem in that plugin is that it does the following:
{{{
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
if ( is_plugin_active( 'jetpack/jetpack.php' ) ) {
$jetpack_plugin = get_plugin_data( trailingslashit( WP_PLUGIN_DIR
) . 'jetpack/jetpack.php' );
}
}}}
The problem is that `get_plugin_data()` is now already defined, so the
file isn't included. However, `get_plugin_data` is only defined in that
file, hence the fatal error about the function not existing.
The proper way would be:
{{{
if ( ! function_exists( 'get_plugin_data' ) || ! function_exists(
'is_plugin_active' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
}}}
I'll try find out if more plugins do it wrong like this (e.g. with GitHub
Search), but that's gonna be difficult I think.
Patching Airplane Mode with the above change makes sense either way.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62244#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list