[wp-trac] [WordPress Trac] #40951: New Text Widget - Switching Between Visual/Text Editor Strips Out Code

WordPress Trac noreply at wordpress.org
Mon Jul 17 19:29:56 UTC 2017


#40951: New Text Widget - Switching Between Visual/Text Editor Strips Out Code
-------------------------------------------------+-------------------------
 Reporter:  dwrippe                              |       Owner:
     Type:  defect (bug)                         |  westonruter
 Priority:  normal                               |      Status:  reopened
Component:  Widgets                              |   Milestone:  4.8.1
 Severity:  major                                |     Version:  4.8
 Keywords:  needs-testing has-unit-tests has-    |  Resolution:
  patch commit fixed-major needs-dev-note        |     Focuses:
-------------------------------------------------+-------------------------

Comment (by westonruter):

 Replying to [comment:148 FolioVision]:
 > > This will not have the desired effect for some advanced users because
 it will change the widget's ID that contains the content, and this will
 break CSS selectors that target the widget. It can also have negative
 impacts for plugins that have existing references to Text widget IDs for
 placement in contexts outside normal dynamic_sidebar() calls.
 >
 > So why not then just keep the Widget ID for the converted widget.

 Widget IDs are different from post IDs. Given how widgets are
 (unfortunately) stored in a single serialized array in options, there is
 no auto-incremented number from MySQL. The number part of a widget's ID is
 the ''index'' in the array. Then in order to disambiguate the number from
 other widget types, a widget ID is prefixed by the widget type (id_base)
 for example `text-123`. So converting such a widget over to Custom HTML
 would not only change the type prefix but it would also get a different
 array index, both breaking any CSS selector.

 See also #35669 where widgets are proposed to be stored in a custom post
 type, so they ''would'' get an auto-incremented post ID. This will
 probably be implemented as part of blocks in Gutenberg.

 > Why should people have to go through painful manual moves when we could
 just do it for them automatically and seamlessly. That's what computers
 are for Weston, lightening the burden of pointless manual labour.

 Per above, we can't automatically move them as the migration would result
 in ID changes.

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


More information about the wp-trac mailing list