Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#46541 new defect (bug)

widget class name sent in headers is incorrect when the widget has a namespace

Reported by: dlorre's profile dlorre Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.1
Component: Widgets Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

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:

        $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']

Change History (1)

#1 @SergeyBiryukov
5 years ago

  • Component changed from General to Widgets
  • Description modified (diff)
Note: See TracTickets for help on using tickets.