[wp-trac] [WordPress Trac] #27770: Can't save a widget that uses a namespace
WordPress Trac
noreply at wordpress.org
Mon Aug 21 13:46:56 UTC 2017
#27770: Can't save a widget that uses a namespace
-------------------------------------------------+-------------------------
Reporter: pcfreak30 | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone:
Component: Widgets | Version: 3.8.2
Severity: normal | Resolution:
Keywords: good-first-bug 2nd-opinion needs- | Focuses:
testing |
-------------------------------------------------+-------------------------
Changes (by ZanderZ):
* status: closed => reopened
* resolution: invalid =>
Comment:
I also ran into this problem today and can give more info on what's
causing it.
This is my code:
{{{#!php
<?php
register_widget(new OurNamespace\SocialWidget);
}}}
When adding this widget to a sidebar, a POST call is made to
`admin_ajax.php`, with payload (Example)
{
"widget_id": "widget-ournamespace\socialwidget-2",
"id_base": "ournamespace\socialwidget"
}
The slash is causing the problem. When you call `parent::__construct` with
an `id_base` without a slash (I used `ournamespace_socialwidget`), the
problem is gone.
Hope that helps you! If more info is useful, feel free to ask :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27770#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list