Bug register_widgets using php namespaces
-
Seems to be a bug in WordPress core:
Tested in many ways. The following code example can allways reproduced.
Registering is working in both cases. But when using namespaces the widget won’t be saved after inserting in a widgets area. After reloading the design/widgets page (admin backend) it has disappeared.This code works (not using namespace):
File RPWidget:class RPWidget extends WP_Widget { .. } add_action( 'widgets_init', 'tcrp_register_rpwidget');
plugin file:
require_once 'classes/Widgets/RPWidget.php'; new RPWidget (); function tcrp_register_rpwidget(){ register_widget( 'RPWidget' ); }
This code doesn’t work (using namespace)
File RPWidget:
namespace TC_RP\Widgets; class RPWidget extends \WP_Widget { .. } add_action( 'widgets_init', 'tcrp_register_rpwidget');
plugin file:
new \TC_RP\Widgets\RPWidget(); function tcrp_register_rpwidget(){ register_widget( '\TC_RP\Widgets\RPWidget' ); }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Bug register_widgets using php namespaces’ is closed to new replies.