<!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>[25644] trunk/src/wp-includes/class-wp-walker.php: Improve inline documentation for the `Walker` class.</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/25644">25644</a></dd>
<dt>Author</dt> <dd>DrewAPicture</dd>
<dt>Date</dt> <dd>2013-09-28 21:28:03 +0000 (Sat, 28 Sep 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Improve inline documentation for the `Walker` class.
Includes previously undocumented parameters.
See <a href="http://core.trac.wordpress.org/ticket/23406">#23406</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpwalkerphp">trunk/src/wp-includes/class-wp-walker.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpwalkerphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/class-wp-walker.php (25643 => 25644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/class-wp-walker.php 2013-09-28 21:01:54 UTC (rev 25643)
+++ trunk/src/wp-includes/class-wp-walker.php 2013-09-28 21:28:03 UTC (rev 25644)
</span><span class="lines">@@ -2,14 +2,13 @@
</span><span class="cx"> /**
</span><span class="cx"> * A class for displaying various tree-like structures.
</span><span class="cx"> *
</span><del>- * Extend the Walker class to use it, see examples at the below. Child classes
</del><ins>+ * Extend the Walker class to use it, see examples below. Child classes
</ins><span class="cx"> * do not need to implement all of the abstract methods in the class. The child
</span><del>- * only needs to implement the methods that are needed. Also, the methods are
- * not strictly abstract in that the parameter definition needs to be followed.
- * The child classes can have additional parameters.
</del><ins>+ * only needs to implement the methods that are needed.
</ins><span class="cx"> *
</span><ins>+ * @since 2.1.0
+ *
</ins><span class="cx"> * @package WordPress
</span><del>- * @since 2.1.0
</del><span class="cx"> * @abstract
</span><span class="cx"> */
</span><span class="cx"> class Walker {
</span><span class="lines">@@ -43,57 +42,64 @@
</span><span class="cx"> /**
</span><span class="cx"> * Starts the list before the elements are added.
</span><span class="cx"> *
</span><del>- * Additional parameters are used in child classes. The args parameter holds
- * additional values that may be used with the child class methods. This
- * method is called at the start of the output list.
</del><ins>+ * The $args parameter holds additional values that may be used with the child
+ * class methods. This method is called at the start of the output list.
</ins><span class="cx"> *
</span><span class="cx"> * @since 2.1.0
</span><span class="cx"> * @abstract
</span><span class="cx"> *
</span><span class="cx"> * @param string $output Passed by reference. Used to append additional content.
</span><ins>+ * @param int $depth Depth of the item.
+ * @param array $args An array of additional arguments.
</ins><span class="cx"> */
</span><span class="cx"> function start_lvl( &$output, $depth = 0, $args = array() ) {}
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Ends the list of after the elements are added.
</span><span class="cx"> *
</span><del>- * Additional parameters are used in child classes. The args parameter holds
- * additional values that may be used with the child class methods. This
- * method finishes the list at the end of output of the elements.
</del><ins>+ * The $args parameter holds additional values that may be used with the child
+ * class methods. This method finishes the list at the end of output of the elements.
</ins><span class="cx"> *
</span><span class="cx"> * @since 2.1.0
</span><span class="cx"> * @abstract
</span><span class="cx"> *
</span><span class="cx"> * @param string $output Passed by reference. Used to append additional content.
</span><ins>+ * @param int $depth Depth of the item.
+ * @param array $args An array of additional arguments.
</ins><span class="cx"> */
</span><del>- function end_lvl( &$output, $depth = 0, $args = array() ) {}
</del><ins>+ function end_lvl( &$output, $depth = 0, $args = array() ) {}
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Start the element output.
</span><span class="cx"> *
</span><del>- * Additional parameters are used in child classes. The args parameter holds
- * additional values that may be used with the child class methods. Includes
- * the element output also.
</del><ins>+ * The $args parameter holds additional values that may be used with the child
+ * class methods. Includes the element output also.
</ins><span class="cx"> *
</span><span class="cx"> * @since 2.1.0
</span><span class="cx"> * @abstract
</span><span class="cx"> *
</span><del>- * @param string $output Passed by reference. Used to append additional content.
</del><ins>+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $object The data object.
+ * @param int $depth Depth of the item.
+ * @param array $args An array of additional arguments.
+ * @param int $current_object_id ID of the current item.
</ins><span class="cx"> */
</span><del>- function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
</del><ins>+ function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Ends the element output, if needed.
</span><span class="cx"> *
</span><del>- * Additional parameters are used in child classes. The args parameter holds
- * additional values that may be used with the child class methods.
</del><ins>+ * The $args parameter holds additional values that may be used with the child class methods.
</ins><span class="cx"> *
</span><span class="cx"> * @since 2.1.0
</span><span class="cx"> * @abstract
</span><span class="cx"> *
</span><span class="cx"> * @param string $output Passed by reference. Used to append additional content.
</span><ins>+ * @param object $object The data object.
+ * @param int $depth Depth of the item.
+ * @param array $args An array of additional arguments.
</ins><span class="cx"> */
</span><del>- function end_el( &$output, $object, $depth = 0, $args = array() ) {}
</del><ins>+ function end_el( &$output, $object, $depth = 0, $args = array() ) {}
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Traverse elements to create list from elements.
</span><span class="lines">@@ -103,16 +109,16 @@
</span><span class="cx"> * depth and no ignore elements under that depth. It is possible to set the
</span><span class="cx"> * max depth to include all depths, see walk() method.
</span><span class="cx"> *
</span><del>- * This method shouldn't be called directly, use the walk() method instead.
</del><ins>+ * This method should not be called directly, use the walk() method instead.
</ins><span class="cx"> *
</span><span class="cx"> * @since 2.5.0
</span><span class="cx"> *
</span><del>- * @param object $element Data object
- * @param array $children_elements List of elements to continue traversing.
- * @param int $max_depth Max depth to traverse.
- * @param int $depth Depth of current element.
- * @param array $args
- * @param string $output Passed by reference. Used to append additional content.
</del><ins>+ * @param object $element Data object.
+ * @param array $children_elements List of elements to continue traversing.
+ * @param int $max_depth Max depth to traverse.
+ * @param int $depth Depth of current element.
+ * @param array $args An array of arguments.
+ * @param string $output Passed by reference. Used to append additional content.
</ins><span class="cx"> * @return null Null on failure with no changes to parameters.
</span><span class="cx"> */
</span><span class="cx"> function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
</span><span class="lines">@@ -160,16 +166,17 @@
</span><span class="cx"> /**
</span><span class="cx"> * Display array of elements hierarchically.
</span><span class="cx"> *
</span><del>- * It is a generic function which does not assume any existing order of
- * elements. max_depth = -1 means flatly display every element. max_depth =
- * 0 means display all levels. max_depth > 0 specifies the number of
- * display levels.
</del><ins>+ * Does not assume any existing order of elements.
</ins><span class="cx"> *
</span><ins>+ * $max_depth = -1 means flatly display every element.
+ * $max_depth = 0 means display all levels.
+ * $max_depth > 0 specifies the number of display levels.
+ *
</ins><span class="cx"> * @since 2.1.0
</span><span class="cx"> *
</span><del>- * @param array $elements
- * @param int $max_depth
- * @return string
</del><ins>+ * @param array $elements An array of elements.
+ * @param int $max_depth The maximum hierarchical depth.
+ * @return string The hierarchical item output.
</ins><span class="cx"> */
</span><span class="cx"> function walk( $elements, $max_depth) {
</span><span class="cx">
</span><span class="lines">@@ -194,10 +201,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><del>- * need to display in hierarchical order
- * separate elements into two buckets: top level and children elements
- * children_elements is two dimensional array, eg.
- * children_elements[10][] contains all sub-elements whose parent is 10.
</del><ins>+ * Need to display in hierarchical order.
+ * Separate elements into two buckets: top level and children elements.
+ * Children_elements is two dimensional array, eg.
+ * Children_elements[10][] contains all sub-elements whose parent is 10.
</ins><span class="cx"> */
</span><span class="cx"> $top_level_elements = array();
</span><span class="cx"> $children_elements = array();
</span><span class="lines">@@ -209,8 +216,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><del>- * when none of the elements is top level
- * assume the first one must be root of the sub elements
</del><ins>+ * When none of the elements is top level.
+ * Assume the first one must be root of the sub elements.
</ins><span class="cx"> */
</span><span class="cx"> if ( empty($top_level_elements) ) {
</span><span class="cx">
</span><span class="lines">@@ -231,8 +238,8 @@
</span><span class="cx"> $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
</span><span class="cx">
</span><span class="cx"> /*
</span><del>- * if we are displaying all levels, and remaining children_elements is not empty,
- * then we got orphans, which should be displayed regardless
</del><ins>+ * If we are displaying all levels, and remaining children_elements is not empty,
+ * then we got orphans, which should be displayed regardless.
</ins><span class="cx"> */
</span><span class="cx"> if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
</span><span class="cx"> $empty_array = array();
</span><span class="lines">@@ -251,11 +258,14 @@
</span><span class="cx"> * and number of elements per page, this function first determines all top level root elements
</span><span class="cx"> * belonging to that page, then lists them and all of their children in hierarchical order.
</span><span class="cx"> *
</span><del>- * @package WordPress
- * @since 2.7
- * @param int $max_depth = 0 means display all levels; $max_depth > 0 specifies the number of display levels.
- * @param int $page_num the specific page number, beginning with 1.
- * @return XHTML of the specified page of elements
</del><ins>+ * $max_depth = 0 means display all levels.
+ * $max_depth > 0 specifies the number of display levels.
+ *
+ * @since 2.7.0
+ *
+ * @param int $max_depth The maximum hierarchical depth.
+ * @param int $page_num The specific page number, beginning with 1.
+ * @return string XHTML of the specified page of elements
</ins><span class="cx"> */
</span><span class="cx"> function paged_walk( $elements, $max_depth, $page_num, $per_page ) {
</span><span class="cx">
</span><span class="lines">@@ -309,9 +319,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><del>- * separate elements into two buckets: top level and children elements
- * children_elements is two dimensional array, eg.
- * children_elements[10][] contains all sub-elements whose parent is 10.
</del><ins>+ * Separate elements into two buckets: top level and children elements.
+ * Children_elements is two dimensional array, e.g.
+ * $children_elements[10][] contains all sub-elements whose parent is 10.
</ins><span class="cx"> */
</span><span class="cx"> $top_level_elements = array();
</span><span class="cx"> $children_elements = array();
</span><span class="lines">@@ -342,7 +352,7 @@
</span><span class="cx"> foreach ( $top_level_elements as $e ) {
</span><span class="cx"> $count++;
</span><span class="cx">
</span><del>- //for the last page, need to unset earlier children in order to keep track of orphans
</del><ins>+ // For the last page, need to unset earlier children in order to keep track of orphans.
</ins><span class="cx"> if ( $end >= $total_top && $count < $start )
</span><span class="cx"> $this->unset_children( $e, $children_elements );
</span><span class="cx">
</span><span class="lines">@@ -377,7 +387,7 @@
</span><span class="cx"> return $num;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // unset all the children for a given top level element
</del><ins>+ // Unset all the children for a given top level element.
</ins><span class="cx"> function unset_children( $e, &$children_elements ){
</span><span class="cx">
</span><span class="cx"> if ( !$e || !$children_elements )
</span><span class="lines">@@ -394,4 +404,5 @@
</span><span class="cx"> unset( $children_elements[$id] );
</span><span class="cx">
</span><span class="cx"> }
</span><del>-}
</del><ins>+
+} // Walker
</ins></span></pre>
</div>
</div>
</body>
</html>