[wp-trac] [WordPress Trac] #46541: widget class name sent in headers is incorrect when the widget has a namespace
WordPress Trac
noreply at wordpress.org
Sat Mar 16 19:56:30 UTC 2019
#46541: widget class name sent in headers is incorrect when the widget has a
namespace
--------------------------+-----------------------------
Reporter: dlorre | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
It looks like WordPress is removing the '\' from a class name in the
headers, this leads to difficulties making Oxygen to function with
Multisite Language Switcher for instance.
Here is what is done in Oxygen to integrate a widget:
{{{#!php
<?php
$component_json = file_get_contents('php://input');
$component = json_decode( $component_json, true );
$options = $component['options']['original'];
...
if (
$GLOBALS['wp_widget_factory']->widgets[$options['class_name']] ) {
... do stuff
}
else {
printf( __("<b>Error!</b><br/> No '%s' widget registered
in this installation", "component-theme"), $options['class_name'] );
}
}}}
This does not work with multisite language switcher plugin since it is
registered as "llocMslsMslsWidget" in $options and "lloc\Msls\MslsWidget"
in $GLOBALS.
I think it is a WordPress bug because there is no reason to register a
class name without the '\'. Alternatively you may want to replace the '\'
with '_' but then you'd have to do the same in
$GLOBALS['wp_widget_factory']
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46541>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list