<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[27904] trunk/src/wp-includes/class-wp-customize-widgets.php: Coding standards and readability spacing for WP_Customize_Widgets.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/27904">27904</a></dd>
<dt>Author</dt> <dd>DrewAPicture</dd>
<dt>Date</dt> <dd>2014-04-02 06:11:49 +0000 (Wed, 02 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Coding standards and readability spacing for WP_Customize_Widgets.

Also explicitly re-mark `_capture_filter_pre_update_option()` and `_capture_filter_pre_get_option()` as public.

See <a href="http://core.trac.wordpress.org/ticket/27534">#27534</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpcustomizewidgetsphp">trunk/src/wp-includes/class-wp-customize-widgets.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpcustomizewidgetsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/class-wp-customize-widgets.php (27903 => 27904)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/class-wp-customize-widgets.php     2014-04-02 05:44:54 UTC (rev 27903)
+++ trunk/src/wp-includes/class-wp-customize-widgets.php        2014-04-02 06:11:49 UTC (rev 27904)
</span><span class="lines">@@ -27,19 +27,9 @@
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $core_widget_id_bases = array(
</span><del>-               'archives',
-               'calendar',
-               'categories',
-               'links',
-               'meta',
-               'nav_menu',
-               'pages',
-               'recent-comments',
-               'recent-posts',
-               'rss',
-               'search',
-               'tag_cloud',
-               'text',
</del><ins>+                'archives', 'calendar', 'categories', 'links', 'meta',
+               'nav_menu', 'pages', 'recent-comments', 'recent-posts',
+               'rss', 'search', 'tag_cloud', 'text',
</ins><span class="cx">   );
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="lines">@@ -126,6 +116,7 @@
</span><span class="cx">   */
</span><span class="cx">  public function setup_widget_addition_previews() {
</span><span class="cx">          $is_customize_preview = false;
</span><ins>+
</ins><span class="cx">           if ( ! empty( $this->manager ) && ! is_admin() && 'on' === $this->get_post_value( 'wp_customize' ) ) {
</span><span class="cx">                  $is_customize_preview = check_ajax_referer( 'preview-customize_' . $this->manager->get_stylesheet(), 'nonce', false );
</span><span class="cx">          }
</span><span class="lines">@@ -148,10 +139,7 @@
</span><span class="cx">          // Input from customizer preview.
</span><span class="cx">          if ( isset( $_POST['customized'] ) ) {
</span><span class="cx">                  $customized = json_decode( $this->get_post_value( 'customized' ), true );
</span><del>-               }
-
-               // Input from ajax widget update request.
-               else {
</del><ins>+                } else { // Input from ajax widget update request.
</ins><span class="cx">                   $customized    = array();
</span><span class="cx">                  $id_base       = $this->get_post_value( 'id_base' );
</span><span class="cx">                  $widget_number = (int) $this->get_post_value( 'widget_number' );
</span><span class="lines">@@ -258,9 +246,7 @@
</span><span class="cx">                          if ( false === $instance && empty( $value ) ) {
</span><span class="cx">                                  $instance = array();
</span><span class="cx">                          }
</span><del>-                       }
-                       // Multi widget
-                       else if ( false === $instance || ! isset( $instance[$widget_number] ) ) {
</del><ins>+                        } else if ( false === $instance || ! isset( $instance[$widget_number] ) ) { // Multi widget
</ins><span class="cx">                           if ( empty( $instance ) ) {
</span><span class="cx">                                  $instance = array( '_multiwidget' => 1 );
</span><span class="cx">                          }
</span><span class="lines">@@ -351,9 +337,12 @@
</span><span class="cx">          foreach ( array_keys( $wp_registered_widgets ) as $widget_id ) {
</span><span class="cx">                  $setting_id   = $this->get_setting_id( $widget_id );
</span><span class="cx">                  $setting_args = $this->get_setting_args( $setting_id );
</span><ins>+
</ins><span class="cx">                   $setting_args['sanitize_callback']    = array( $this, 'sanitize_widget_instance' );
</span><span class="cx">                  $setting_args['sanitize_js_callback'] = array( $this, 'sanitize_widget_js_instance' );
</span><ins>+
</ins><span class="cx">                   $this->manager->add_setting( $setting_id, $setting_args );
</span><ins>+
</ins><span class="cx">                   $new_setting_ids[] = $setting_id;
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="lines">@@ -361,6 +350,7 @@
</span><span class="cx">                  if ( empty( $sidebar_widget_ids ) ) {
</span><span class="cx">                          $sidebar_widget_ids = array();
</span><span class="cx">                  }
</span><ins>+
</ins><span class="cx">                   $is_registered_sidebar = isset( $GLOBALS['wp_registered_sidebars'][$sidebar_id] );
</span><span class="cx">                  $is_inactive_widgets   = ( 'wp_inactive_widgets' === $sidebar_id );
</span><span class="cx">                  $is_active_sidebar     = ( $is_registered_sidebar && ! $is_inactive_widgets );
</span><span class="lines">@@ -369,14 +359,17 @@
</span><span class="cx">                  if ( $is_registered_sidebar || $is_inactive_widgets ) {
</span><span class="cx">                          $setting_id   = sprintf( 'sidebars_widgets[%s]', $sidebar_id );
</span><span class="cx">                          $setting_args = $this->get_setting_args( $setting_id );
</span><ins>+
</ins><span class="cx">                           $setting_args['sanitize_callback']    = array( $this, 'sanitize_sidebar_widgets' );
</span><span class="cx">                          $setting_args['sanitize_js_callback'] = array( $this, 'sanitize_sidebar_widgets_js_instance' );
</span><ins>+
</ins><span class="cx">                           $this->manager->add_setting( $setting_id, $setting_args );
</span><span class="cx">                          $new_setting_ids[] = $setting_id;
</span><span class="cx"> 
</span><span class="cx">                          // Add section to contain controls.
</span><span class="cx">                          $section_id = sprintf( 'sidebar-widgets-%s', $sidebar_id );
</span><span class="cx">                          if ( $is_active_sidebar ) {
</span><ins>+
</ins><span class="cx">                                   $section_args = array(
</span><span class="cx">                                          /* translators: %s: sidebar name */
</span><span class="cx">                                          'title' => sprintf( __( 'Widgets: %s' ), $GLOBALS['wp_registered_sidebars'][$sidebar_id]['name'] ),
</span><span class="lines">@@ -384,18 +377,16 @@
</span><span class="cx">                                          'priority' => 1000 + array_search( $sidebar_id, array_keys( $wp_registered_sidebars ) ),
</span><span class="cx">                                  );
</span><span class="cx">                                  $section_args = apply_filters( 'customizer_widgets_section_args', $section_args, $section_id, $sidebar_id );
</span><ins>+
</ins><span class="cx">                                   $this->manager->add_section( $section_id, $section_args );
</span><span class="cx"> 
</span><del>-                                       $control = new WP_Widget_Area_Customize_Control(
-                                               $this->manager,
-                                               $setting_id,
-                                               array(
-                                                       'section' => $section_id,
-                                                       'sidebar_id' => $sidebar_id,
-                                                       'priority' => count( $sidebar_widget_ids ), // place Add Widget & Reorder buttons at end
-                                               )
-                                       );
</del><ins>+                                        $control = new WP_Widget_Area_Customize_Control( $this->manager, $setting_id, array(
+                                               'section'    => $section_id,
+                                               'sidebar_id' => $sidebar_id,
+                                               'priority'   => count( $sidebar_widget_ids ), // place 'Add Widget' and 'Reorder' buttons at end.
+                                       ) );
</ins><span class="cx">                                   $new_setting_ids[] = $setting_id;
</span><ins>+
</ins><span class="cx">                                   $this->manager->add_control( $control );
</span><span class="cx">                          }
</span><span class="cx">                  }
</span><span class="lines">@@ -407,25 +398,24 @@
</span><span class="cx">                          if ( ! $is_active_sidebar || ! isset( $GLOBALS['wp_registered_widgets'][$widget_id] ) ) {
</span><span class="cx">                                  continue;
</span><span class="cx">                          }
</span><ins>+
</ins><span class="cx">                           $registered_widget = $GLOBALS['wp_registered_widgets'][$widget_id];
</span><del>-                               $setting_id = $this->get_setting_id( $widget_id );
-                               $id_base = $GLOBALS['wp_registered_widget_controls'][$widget_id]['id_base'];
</del><ins>+                                $setting_id        = $this->get_setting_id( $widget_id );
+                               $id_base           = $GLOBALS['wp_registered_widget_controls'][$widget_id]['id_base'];
+
</ins><span class="cx">                           assert( false !== is_active_widget( $registered_widget['callback'], $registered_widget['id'], false, false ) );
</span><del>-                               $control = new WP_Widget_Form_Customize_Control(
-                                       $this->manager,
-                                       $setting_id,
-                                       array(
-                                               'label' => $registered_widget['name'],
-                                               'section' => $section_id,
-                                               'sidebar_id' => $sidebar_id,
-                                               'widget_id' => $widget_id,
-                                               'widget_id_base' => $id_base,
-                                               'priority' => $i,
-                                               'width' => $wp_registered_widget_controls[$widget_id]['width'],
-                                               'height' => $wp_registered_widget_controls[$widget_id]['height'],
-                                               'is_wide' => $this->is_wide_widget( $widget_id ),
-                                       )
-                               );
</del><ins>+
+                               $control = new WP_Widget_Form_Customize_Control( $this->manager, $setting_id, array(
+                                       'label'          => $registered_widget['name'],
+                                       'section'        => $section_id,
+                                       'sidebar_id'     => $sidebar_id,
+                                       'widget_id'      => $widget_id,
+                                       'widget_id_base' => $id_base,
+                                       'priority'       => $i,
+                                       'width'          => $wp_registered_widget_controls[$widget_id]['width'],
+                                       'height'         => $wp_registered_widget_controls[$widget_id]['height'],
+                                       'is_wide'        => $this->is_wide_widget( $widget_id ),
+                               ) );
</ins><span class="cx">                           $this->manager->add_control( $control );
</span><span class="cx">                  }
</span><span class="cx">          }
</span><span class="lines">@@ -439,7 +429,6 @@
</span><span class="cx">                          $this->manager->get_setting( $new_setting_id )->preview();
</span><span class="cx">                  }
</span><span class="cx">          }
</span><del>-
</del><span class="cx">           $this->remove_prepreview_filters();
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -454,7 +443,8 @@
</span><span class="cx">   */
</span><span class="cx">  public function get_setting_id( $widget_id ) {
</span><span class="cx">          $parsed_widget_id = $this->parse_widget_id( $widget_id );
</span><del>-               $setting_id = sprintf( 'widget_%s', $parsed_widget_id['id_base'] );
</del><ins>+                $setting_id       = sprintf( 'widget_%s', $parsed_widget_id['id_base'] );
+
</ins><span class="cx">           if ( ! is_null( $parsed_widget_id['number'] ) ) {
</span><span class="cx">                  $setting_id .= sprintf( '[%d]', $parsed_widget_id['number'] );
</span><span class="cx">          }
</span><span class="lines">@@ -479,10 +469,11 @@
</span><span class="cx">   */
</span><span class="cx">  public function is_wide_widget( $widget_id ) {
</span><span class="cx">          global $wp_registered_widget_controls;
</span><ins>+
</ins><span class="cx">           $parsed_widget_id = $this->parse_widget_id( $widget_id );
</span><del>-               $width = $wp_registered_widget_controls[$widget_id]['width'];
-               $is_core = in_array( $parsed_widget_id['id_base'], $this->core_widget_id_bases );
-               $is_wide = ( $width > 250 && ! $is_core );
</del><ins>+                $width            = $wp_registered_widget_controls[$widget_id]['width'];
+               $is_core          = in_array( $parsed_widget_id['id_base'], $this->core_widget_id_bases );
+               $is_wide          = ( $width > 250 && ! $is_core );
</ins><span class="cx"> 
</span><span class="cx">          /**
</span><span class="cx">           * Filter whether the given widget is considered "wide".
</span><span class="lines">@@ -509,6 +500,7 @@
</span><span class="cx">                  'number' => null,
</span><span class="cx">                  'id_base' => null,
</span><span class="cx">          );
</span><ins>+
</ins><span class="cx">           if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) {
</span><span class="cx">                  $parsed['id_base'] = $matches[1];
</span><span class="cx">                  $parsed['number']  = intval( $matches[2] );
</span><span class="lines">@@ -536,6 +528,7 @@
</span><span class="cx"> 
</span><span class="cx">          $id_base = $matches[2];
</span><span class="cx">          $number  = isset( $matches[3] ) ? intval( $matches[3] ) : null;
</span><ins>+
</ins><span class="cx">           return compact( 'id_base', 'number' );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -554,6 +547,7 @@
</span><span class="cx">           * since plugins need templates to be in the DOM.
</span><span class="cx">           */
</span><span class="cx">          $available_widgets = array();
</span><ins>+
</ins><span class="cx">           foreach ( $this->get_available_widgets() as $available_widget ) {
</span><span class="cx">                  unset( $available_widget['control_tpl'] );
</span><span class="cx">                  $available_widgets[] = $available_widget;
</span><span class="lines">@@ -592,24 +586,26 @@
</span><span class="cx">           * and it forces values into strings.
</span><span class="cx">           */
</span><span class="cx">          global $wp_scripts;
</span><ins>+
</ins><span class="cx">           $exports = array(
</span><del>-                       'nonce' => wp_create_nonce( 'update-widget' ),
</del><ins>+                        'nonce'               => wp_create_nonce( 'update-widget' ),
</ins><span class="cx">                   'registered_sidebars' => array_values( $GLOBALS['wp_registered_sidebars'] ),
</span><del>-                       'registered_widgets' => $GLOBALS['wp_registered_widgets'],
-                       'available_widgets' => $available_widgets, // @todo Merge this with registered_widgets
</del><ins>+                        'registered_widgets'  => $GLOBALS['wp_registered_widgets'],
+                       'available_widgets'   => $available_widgets, // @todo Merge this with registered_widgets
</ins><span class="cx">                   'i18n' => array(
</span><del>-                               'save_btn_label' => __( 'Apply' ),
</del><ins>+                                'save_btn_label'     => __( 'Apply' ),
</ins><span class="cx">                           // @todo translate? do we want these tooltips?
</span><del>-                               'save_btn_tooltip' => ( 'Save and preview changes before publishing them.' ),
-                               'remove_btn_label' => __( 'Remove' ),
</del><ins>+                                'save_btn_tooltip'   => ( 'Save and preview changes before publishing them.' ),
+                               'remove_btn_label'   => __( 'Remove' ),
</ins><span class="cx">                           'remove_btn_tooltip' => ( 'Trash widget by moving it to the inactive widgets sidebar.' ),
</span><del>-                               'error' => __( 'An error has occurred. Please reload the page and try again.' ),
</del><ins>+                                'error'              => __( 'An error has occurred. Please reload the page and try again.' ),
</ins><span class="cx">                   ),
</span><del>-                       'tpl' => array(
</del><ins>+                        'tpl'                 => array(
</ins><span class="cx">                           'widget_reorder_nav' => $widget_reorder_nav_tpl,
</span><del>-                               'move_widget_area' => $move_widget_area_tpl,
</del><ins>+                                'move_widget_area'   => $move_widget_area_tpl,
</ins><span class="cx">                   ),
</span><span class="cx">          );
</span><ins>+
</ins><span class="cx">           foreach ( $exports['registered_widgets'] as &$registered_widget ) {
</span><span class="cx">                  unset( $registered_widget['callback'] ); // may not be JSON-serializeable
</span><span class="cx">          }
</span><span class="lines">@@ -657,10 +653,10 @@
</span><span class="cx">   */
</span><span class="cx">  public function get_setting_args( $id, $overrides = array() ) {
</span><span class="cx">          $args = array(
</span><del>-                       'type' => 'option',
</del><ins>+                        'type'       => 'option',
</ins><span class="cx">                   'capability' => 'edit_theme_options',
</span><del>-                       'transport' => 'refresh',
-                       'default' => array(),
</del><ins>+                        'transport'  => 'refresh',
+                       'default'    => array(),
</ins><span class="cx">           );
</span><span class="cx">          $args = array_merge( $args, $overrides );
</span><span class="cx"> 
</span><span class="lines">@@ -690,8 +686,10 @@
</span><span class="cx">   */
</span><span class="cx">  public function sanitize_sidebar_widgets( $widget_ids ) {
</span><span class="cx">          global $wp_registered_widgets;
</span><del>-               $widget_ids = array_map( 'strval', (array) $widget_ids );
</del><ins>+
+               $widget_ids           = array_map( 'strval', (array) $widget_ids );
</ins><span class="cx">           $sanitized_widget_ids = array();
</span><ins>+
</ins><span class="cx">           foreach ( $widget_ids as $widget_id ) {
</span><span class="cx">                  if ( array_key_exists( $widget_id, $wp_registered_widgets ) ) {
</span><span class="cx">                          $sanitized_widget_ids[] = $widget_id;
</span><span class="lines">@@ -739,24 +737,21 @@
</span><span class="cx">                  unset( $available_widget['callback'] ); // not serializable to JSON
</span><span class="cx"> 
</span><span class="cx">                  $args = array(
</span><del>-                               'widget_id' => $widget['id'],
</del><ins>+                                'widget_id'   => $widget['id'],
</ins><span class="cx">                           'widget_name' => $widget['name'],
</span><del>-                               '_display' => 'template',
</del><ins>+                                '_display'    => 'template',
</ins><span class="cx">                   );
</span><span class="cx"> 
</span><span class="cx">                  $is_disabled     = false;
</span><del>-                       $is_multi_widget = (
-                               isset( $wp_registered_widget_controls[$widget['id']]['id_base'] )
-                               &&
-                               isset( $widget['params'][0]['number'] )
-                       );
</del><ins>+                        $is_multi_widget = ( isset( $wp_registered_widget_controls[$widget['id']]['id_base'] ) && isset( $widget['params'][0]['number'] ) );
</ins><span class="cx">                   if ( $is_multi_widget ) {
</span><del>-                               $id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
</del><ins>+                                $id_base            = $wp_registered_widget_controls[$widget['id']]['id_base'];
</ins><span class="cx">                           $args['_temp_id']   = "$id_base-__i__";
</span><span class="cx">                          $args['_multi_num'] = next_widget_id_number( $id_base );
</span><span class="cx">                          $args['_add']       = 'multi';
</span><span class="cx">                  } else {
</span><span class="cx">                          $args['_add'] = 'single';
</span><ins>+
</ins><span class="cx">                           if ( $sidebar && 'wp_inactive_widgets' !== $sidebar ) {
</span><span class="cx">                                  $is_disabled = true;
</span><span class="cx">                          }
</span><span class="lines">@@ -767,21 +762,18 @@
</span><span class="cx">                  $control_tpl = $this->get_widget_control( $list_widget_controls_args );
</span><span class="cx"> 
</span><span class="cx">                  // The properties here are mapped to the Backbone Widget model.
</span><del>-                       $available_widget = array_merge(
-                               $available_widget,
-                               array(
-                                       'temp_id' => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
-                                       'is_multi' => $is_multi_widget,
-                                       'control_tpl' => $control_tpl,
-                                       'multi_number' => ( $args['_add'] === 'multi' ) ? $args['_multi_num'] : false,
-                                       'is_disabled' => $is_disabled,
-                                       'id_base' => $id_base,
-                                       'transport' => 'refresh',
-                                       'width' => $wp_registered_widget_controls[$widget['id']]['width'],
-                                       'height' => $wp_registered_widget_controls[$widget['id']]['height'],
-                                       'is_wide' => $this->is_wide_widget( $widget['id'] ),
-                               )
-                       );
</del><ins>+                        $available_widget = array_merge( $available_widget, array(
+                               'temp_id'      => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
+                               'is_multi'     => $is_multi_widget,
+                               'control_tpl'  => $control_tpl,
+                               'multi_number' => ( $args['_add'] === 'multi' ) ? $args['_multi_num'] : false,
+                               'is_disabled'  => $is_disabled,
+                               'id_base'      => $id_base,
+                               'transport'    => 'refresh',
+                               'width'        => $wp_registered_widget_controls[$widget['id']]['width'],
+                               'height'       => $wp_registered_widget_controls[$widget['id']]['height'],
+                               'is_wide'      => $this->is_wide_widget( $widget['id'] ),
+                       ) );
</ins><span class="cx"> 
</span><span class="cx">                  $available_widgets[] = $available_widget;
</span><span class="cx">          }
</span><span class="lines">@@ -814,13 +806,17 @@
</span><span class="cx">   */
</span><span class="cx">  public function get_widget_control( $args ) {
</span><span class="cx">          ob_start();
</span><ins>+
</ins><span class="cx">           call_user_func_array( 'wp_widget_control', $args );
</span><span class="cx">          $replacements = array(
</span><span class="cx">                  '<form action="" method="post">' => '<div class="form">',
</span><span class="cx">                  '</form>' => '</div><!-- .form -->',
</span><span class="cx">          );
</span><ins>+
</ins><span class="cx">           $control_tpl = ob_get_clean();
</span><ins>+
</ins><span class="cx">           $control_tpl = str_replace( array_keys( $replacements ), array_values( $replacements ), $control_tpl );
</span><ins>+
</ins><span class="cx">           return $control_tpl;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -899,6 +895,7 @@
</span><span class="cx">   * @access public
</span><span class="cx">   */
</span><span class="cx">  public function export_preview_data() {
</span><ins>+
</ins><span class="cx">           // Prepare customizer settings to pass to Javascript.
</span><span class="cx">          $settings = array(
</span><span class="cx">                  'renderedSidebars'   => array_fill_keys( array_unique( $this->rendered_sidebars ), true ),
</span><span class="lines">@@ -1019,21 +1016,21 @@
</span><span class="cx">          if ( $value === array() ) {
</span><span class="cx">                  return $value;
</span><span class="cx">          }
</span><del>-               $invalid = (
-                       empty( $value['is_widget_customizer_js_value'] )
-                       ||
-                       empty( $value['instance_hash_key'] )
-                       ||
-                       empty( $value['encoded_serialized_instance'] )
-               );
-               if ( $invalid ) {
</del><ins>+
+               if ( empty( $value['is_widget_customizer_js_value'] )
+                       || empty( $value['instance_hash_key'] )
+                       || empty( $value['encoded_serialized_instance'] ) )
+               {
</ins><span class="cx">                   return null;
</span><span class="cx">          }
</span><ins>+
</ins><span class="cx">           $decoded = base64_decode( $value['encoded_serialized_instance'], true );
</span><ins>+
</ins><span class="cx">           if ( false === $decoded ) {
</span><span class="cx">                  return null;
</span><span class="cx">          }
</span><span class="cx">          $instance = unserialize( $decoded );
</span><ins>+
</ins><span class="cx">           if ( false === $instance ) {
</span><span class="cx">                  return null;
</span><span class="cx">          }
</span><span class="lines">@@ -1055,11 +1052,12 @@
</span><span class="cx">  public function sanitize_widget_js_instance( $value ) {
</span><span class="cx">          if ( empty( $value['is_widget_customizer_js_value'] ) ) {
</span><span class="cx">                  $serialized = serialize( $value );
</span><ins>+
</ins><span class="cx">                   $value = array(
</span><del>-                               'encoded_serialized_instance' => base64_encode( $serialized ),
-                               'title' => empty( $value['title'] ) ? '' : $value['title'],
</del><ins>+                                'encoded_serialized_instance'   => base64_encode( $serialized ),
+                               'title'                         => empty( $value['title'] ) ? '' : $value['title'],
</ins><span class="cx">                           'is_widget_customizer_js_value' => true,
</span><del>-                               'instance_hash_key' => $this->get_instance_hash_key( $value ),
</del><ins>+                                'instance_hash_key'             => $this->get_instance_hash_key( $value ),
</ins><span class="cx">                   );
</span><span class="cx">          }
</span><span class="cx">          return $value;
</span><span class="lines">@@ -1166,14 +1164,17 @@
</span><span class="cx"> 
</span><span class="cx">          // Obtain the widget control with the updated instance in place.
</span><span class="cx">          ob_start();
</span><ins>+
</ins><span class="cx">           $form = $wp_registered_widget_controls[$widget_id];
</span><span class="cx">          if ( $form ) {
</span><span class="cx">                  call_user_func_array( $form['callback'], $form['params'] );
</span><span class="cx">          }
</span><ins>+
</ins><span class="cx">           $form = ob_get_clean();
</span><span class="cx"> 
</span><span class="cx">          // Obtain the widget instance.
</span><span class="cx">          $option = get_option( $option_name );
</span><ins>+
</ins><span class="cx">           if ( null !== $parsed_id['number'] ) {
</span><span class="cx">                  $instance = $option[$parsed_id['number']];
</span><span class="cx">          } else {
</span><span class="lines">@@ -1181,6 +1182,7 @@
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="cx">          $this->stop_capturing_option_updates();
</span><ins>+
</ins><span class="cx">           return compact( 'instance', 'form' );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -1314,19 +1316,22 @@
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="cx">          $this->_is_capturing_option_updates = true;
</span><ins>+
</ins><span class="cx">           add_filter( 'pre_update_option', array( $this, '_capture_filter_pre_update_option' ), 10, 3 );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Pre-filter captured option values before updating.
</span><span class="cx">   *
</span><del>-        * @access private
</del><ins>+         * @since 3.9.0
+        * @access public
+        *
</ins><span class="cx">    * @param mixed $new_value
</span><span class="cx">   * @param string $option_name
</span><span class="cx">   * @param mixed $old_value
</span><span class="cx">   * @return mixed
</span><span class="cx">   */
</span><del>-       private function _capture_filter_pre_update_option( $new_value, $option_name, $old_value ) {
</del><ins>+        public function _capture_filter_pre_update_option( $new_value, $option_name, $old_value ) {
</ins><span class="cx">           if ( $this->is_option_capture_ignored( $option_name ) ) {
</span><span class="cx">                  return;
</span><span class="cx">          }
</span><span class="lines">@@ -1343,12 +1348,15 @@
</span><span class="cx">  /**
</span><span class="cx">   * Pre-filter captured option values before retrieving.
</span><span class="cx">   *
</span><del>-        * @access private
</del><ins>+         * @since 3.9.0
+        * @access public
+        *
</ins><span class="cx">    * @param mixed $value Option
</span><span class="cx">   * @return mixed
</span><span class="cx">   */
</span><del>-       private function _capture_filter_pre_get_option( $value ) {
</del><ins>+        public function _capture_filter_pre_get_option( $value ) {
</ins><span class="cx">           $option_name = preg_replace( '/^pre_option_/', '', current_filter() );
</span><ins>+
</ins><span class="cx">           if ( isset( $this->_captured_options[$option_name] ) ) {
</span><span class="cx">                  $value = $this->_captured_options[$option_name];
</span><span class="cx">                  $value = apply_filters( 'option_' . $option_name, $value );
</span></span></pre>
</div>
</div>

</body>
</html>