[wp-trac] [WordPress Trac] #38723: Widget correct number is not displayed into the global $wp_registered_widgets array

WordPress Trac noreply at wordpress.org
Wed Nov 9 22:25:49 UTC 2016


#38723: Widget correct number is not displayed into the global
$wp_registered_widgets array
-------------------------------------+-----------------------
 Reporter:  alexvorn2                |       Owner:
     Type:  defect (bug)             |      Status:  reopened
 Priority:  normal                   |   Milestone:
Component:  Widgets                  |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  close reporter-feedback  |     Focuses:  template
-------------------------------------+-----------------------
Changes (by westonruter):

 * keywords:   => close reporter-feedback


Comment:

 @alexvorn2 ok, in that case the issue is that all of the widgets of a
 given type re-use the underlying `WP_Widget` instance as their callback
 class. So if you have 10 `pages` widgets, you'll have widgets with numbers
 2 through 11, and each will have a `callback` that references the same
 `WP_Widget_Pages` class. The `id` property of the class gets set by
 `WP_Widget::_set()` before the widget is in
 `\WP_Widget::display_callback()`. So the `id` will be correct when the
 widget is processed. It doesn't clean up after itself to empty out clear
 out the `id` by doing something like `$this->_set( -1 )`.

 Is this behavior actually causing a problem for any functionality or is it
 just that the property doesn't have the value you expect? If the latter,
 then just call the `_set( $number )` method before to ensure it has the
 proper number context.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38723#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list