[wp-trac] [WordPress Trac] #39693: Fix missing assignment of widgets on theme switch

WordPress Trac noreply at wordpress.org
Wed Mar 1 22:12:01 UTC 2017


#39693: Fix missing assignment of widgets on theme switch
-------------------------+-----------------------
 Reporter:  melchoyce    |       Owner:
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  4.8
Component:  Widgets      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+-----------------------

Comment (by westonruter):

 A very helpful way for hosts to provide support on this issue would be to
 share some statistics on the widget sidebars for the sites the host.
 WordPress stores the widget configurations for the sidebars in a PHP-
 serialized `sidebars_widgets` option in the DB that looks like:

 {{{#!php
 <?php
 array(
     'sidebar-1' => array(
         'search-2',
         'meta-2',
     ),
     'sidebar-2' => array(
         'archives-5',
         'calendar-10',
     ),
     'wp_inactive_widgets' => array(
         'text-3',
         'recent-comments-3',
     )
 )
 }}}

 A host could run a script that iterates over each WP site, grabs out the
 `sidebars_widgets` option, and then collect stats on:

 1. Logs the sidebar IDs for the site (the array keys)
 2. Counts the number of widgets in each sidebar (the count for each nested
 array).

 Then given that a script has done:

 {{{#!php
 <?php
 $sidebars_widgets = get_option( 'sidebars_widgets', array() );
 if ( empty( $sidebars_widgets['array_version'] ) || 3 !==
 $sidebars_widgets['array_version'] ) {
     return;
 }
 unset( $sidebars_widgets['array_version'] );
 }}}

 Then, if we can get stats on:

 1. The most commonly used sidebar IDs (`array_keys( $sidebars_widgets )`)
 2. The number of sidebars registered (`count( $sidebars_widgets )`)
 3. Counts the number of widgets in each sidebar (`array_map( 'count',
 $sidebars_widgets ) )`) and perhaps a sum of them (`call_user_func_array(
 'array_sum', array_map( 'count', $sidebars_widgets ) ) )`).

 The `wp_inactive_widgets` sidebar is also a special case which will help
 with designing #27404.

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


More information about the wp-trac mailing list