<!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>[27870] trunk/src/wp-includes/widgets.php: Inline documentation for hooks in wp-includes/widgets.php.</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/27870">27870</a></dd>
<dt>Author</dt> <dd>DrewAPicture</dd>
<dt>Date</dt> <dd>2014-03-31 07:29:29 +0000 (Mon, 31 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Inline documentation for hooks in wp-includes/widgets.php.

Props eliorivero and Nessworthy for the initial patches. Props kpdesign.
Fixes <a href="http://core.trac.wordpress.org/ticket/27129">#27129</a>.</pre>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludeswidgetsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/widgets.php (27869 => 27870)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/widgets.php        2014-03-31 05:15:39 UTC (rev 27869)
+++ trunk/src/wp-includes/widgets.php   2014-03-31 07:29:29 UTC (rev 27870)
</span><span class="lines">@@ -176,8 +176,19 @@
</span><span class="cx"> 
</span><span class="cx">          if ( array_key_exists( $this->number, $instance ) ) {
</span><span class="cx">                  $instance = $instance[$this->number];
</span><del>-                       // filters the widget's settings, return false to stop displaying the widget
-                       $instance = apply_filters('widget_display_callback', $instance, $this, $args);
</del><ins>+
+                       /**
+                        * Filter the settings for a particular widget instance.
+                        *
+                        * Returning false will effectively short-circuit display of the widget.
+                        *
+                        * @since 2.8.0
+                        *
+                        * @param array     $instance The current widget instance's settings.
+                        * @param WP_Widget $this     The current widget instance.
+                        * @param array     $args     An array of default widget arguments.
+                        */
+                       $instance = apply_filters( 'widget_display_callback', $instance, $this, $args );
</ins><span class="cx">                   if ( false !== $instance )
</span><span class="cx">                          $this->widget($args, $instance);
</span><span class="cx">          }
</span><span class="lines">@@ -232,8 +243,20 @@
</span><span class="cx"> 
</span><span class="cx">                          $instance = $this->update($new_instance, $old_instance);
</span><span class="cx"> 
</span><del>-                               // filters the widget's settings before saving, return false to cancel saving (keep the old settings if updating)
-                               $instance = apply_filters('widget_update_callback', $instance, $new_instance, $old_instance, $this);
</del><ins>+                                /**
+                                * Filter a widget's settings before saving.
+                                *
+                                * Returning false will effectively short-circuit the widget's ability
+                                * to update settings.
+                                *
+                                * @since 2.8.0
+                                *
+                                * @param array     $instance     The current widget instance's settings.
+                                * @param array     $new_instance Array of new widget settings.
+                                * @param array     $old_instance Array of old widget settings.
+                                * @param WP_Widget $this         The current widget instance.
+                                */
+                               $instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this );
</ins><span class="cx">                           if ( false !== $instance )
</span><span class="cx">                                  $all_instances[$number] = $instance;
</span><span class="cx"> 
</span><span class="lines">@@ -245,8 +268,11 @@
</span><span class="cx">          $this->updated = true;
</span><span class="cx">  }
</span><span class="cx"> 
</span><del>-       /** Generate the control form.
-        *      Do NOT over-ride this function. */
</del><ins>+        /**
+        * Generate the control form.
+        *
+        * Do NOT over-ride this function.
+        */
</ins><span class="cx">   function form_callback( $widget_args = 1 ) {
</span><span class="cx">          if ( is_numeric($widget_args) )
</span><span class="cx">                  $widget_args = array( 'number' => $widget_args );
</span><span class="lines">@@ -263,15 +289,39 @@
</span><span class="cx">                  $instance = $all_instances[ $widget_args['number'] ];
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               // filters the widget admin form before displaying, return false to stop displaying it
-               $instance = apply_filters('widget_form_callback', $instance, $this);
</del><ins>+                /**
+                * Filter the widget instance's settings before displaying the control form.
+                *
+                * Returning false effectively short-circuits display of the control form.
+                *
+                * @since 2.8.0
+                *
+                * @param array     $instance The current widget instance's settings.
+                * @param WP_Widget $this     The current widget instance.
+                */
+               $instance = apply_filters( 'widget_form_callback', $instance, $this );
</ins><span class="cx"> 
</span><span class="cx">          $return = null;
</span><span class="cx">          if ( false !== $instance ) {
</span><span class="cx">                  $return = $this->form($instance);
</span><del>-                       // add extra fields in the widget form - be sure to set $return to null if you add any
-                       // if the widget has no form the text echoed from the default form method can be hidden using css
-                       do_action_ref_array( 'in_widget_form', array(&$this, &$return, $instance) );
</del><ins>+
+                       /**
+                        * Fires at the end of the widget control form.
+                        *
+                        * Use this hook to add extra fields to the widget form. The hook
+                        * is only fired if the value passed to the 'widget_form_callback'
+                        * hook is not false.
+                        *
+                        * Note: If the widget has no form, the text echoed from the default
+                        * form method can be hidden using CSS.
+                        *
+                        * @since 2.8.0
+                        *
+                        * @param WP_Widget $this     The widget instance, passed by reference.
+                        * @param null      $return   Return null if new fields are added.
+                        * @param array     $instance An array of the widget's settings.
+                        */
+                       do_action_ref_array( 'in_widget_form', array( &$this, &$return, $instance ) );
</ins><span class="cx">           }
</span><span class="cx">          return $return;
</span><span class="cx">  }
</span><span class="lines">@@ -572,6 +622,13 @@
</span><span class="cx"> 
</span><span class="cx">  add_theme_support('widgets');
</span><span class="cx"> 
</span><ins>+       /**
+        * Fires once a sidebar has been registered.
+        *
+        * @since 3.0.0
+        *
+        * @param array $sidebar Parsed arguments for the registered sidebar.
+        */
</ins><span class="cx">   do_action( 'register_sidebar', $sidebar );
</span><span class="cx"> 
</span><span class="cx">  return $sidebar['id'];
</span><span class="lines">@@ -645,6 +702,14 @@
</span><span class="cx">  $widget = array_merge($widget, $options);
</span><span class="cx"> 
</span><span class="cx">  if ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || did_action( 'widgets_init' ) ) ) {
</span><ins>+
+               /**
+                * Fires once for each registered widget.
+                *
+                * @since 3.0.0
+                *
+                * @param array $widget An array of default widget arguments.
+                */
</ins><span class="cx">           do_action( 'wp_register_sidebar_widget', $widget );
</span><span class="cx">          $wp_registered_widgets[$id] = $widget;
</span><span class="cx">  }
</span><span class="lines">@@ -701,6 +766,14 @@
</span><span class="cx">  * @param int|string $id Widget ID.
</span><span class="cx">  */
</span><span class="cx"> function wp_unregister_sidebar_widget($id) {
</span><ins>+
+       /**
+        * Fires just before a widget is removed from a sidebar.
+        *
+        * @since 3.0.0
+        *
+        * @param int $id The widget ID.
+        */
</ins><span class="cx">   do_action( 'wp_unregister_sidebar_widget', $id );
</span><span class="cx"> 
</span><span class="cx">  wp_register_sidebar_widget($id, '', '');
</span><span class="lines">@@ -1128,7 +1201,14 @@
</span><span class="cx">  if ( is_array( $sidebars_widgets ) && isset($sidebars_widgets['array_version']) )
</span><span class="cx">          unset($sidebars_widgets['array_version']);
</span><span class="cx"> 
</span><del>-       $sidebars_widgets = apply_filters('sidebars_widgets', $sidebars_widgets);
</del><ins>+        /**
+        * Filter the list of sidebars and their widgets.
+        *
+        * @since 2.7.0
+        *
+        * @param array $sidebars_widgets An associative array of sidebars and their widgets.
+        */
+       $sidebars_widgets = apply_filters( 'sidebars_widgets', $sidebars_widgets );
</ins><span class="cx">   return $sidebars_widgets;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1224,7 +1304,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Output an arbitrary widget as a template tag
</del><ins>+ * Output an arbitrary widget as a template tag.
</ins><span class="cx">  *
</span><span class="cx">  * @since 2.8.0
</span><span class="cx">  *
</span><span class="lines">@@ -1246,6 +1326,15 @@
</span><span class="cx">  $args = wp_parse_args($args, $default_args);
</span><span class="cx">  $instance = wp_parse_args($instance);
</span><span class="cx"> 
</span><ins>+       /**
+        * Fires before rendering the requested widget.
+        *
+        * @since 3.0.0
+        *
+        * @param string $widget   The widget's class name.
+        * @param array  $instance The current widget instance's settings.
+        * @param array  $args     An array of the widget's sidebar arguments.
+        */
</ins><span class="cx">   do_action( 'the_widget', $widget, $instance, $args );
</span><span class="cx"> 
</span><span class="cx">  $widget_obj->_set(-1);
</span></span></pre>
</div>
</div>

</body>
</html>