Class Walker

Description

A class for displaying various tree-like structures.

Extend the Walker class to use it, see examples at the below. Child classes do not need to implement all of the abstract methods in the class. The child 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.

Located in /wp-includes/class-wp-walker.php (line 15)


	
			
Direct descendents
Class Description
Walker_Page Create HTML list of pages.
Walker_PageDropdown Create HTML dropdown list of pages.
Walker_Category Create HTML list of categories.
Walker_CategoryDropdown Create HTML dropdown list of Categories.
Walker_Nav_Menu Create HTML list of nav menu items.
Walker_Comment HTML comment list class.
Walker_Category_Checklist Walker to output an unordered list of category checkbox <input> elements.
Variable Summary
array $db_fields
string $tree_type
Method Summary
null display_element (object $element,  &$children_elements, int $max_depth, int $depth, array $args,  &$output, array $children_elements, string $output)
void end_el ( &$output,  $object, [ $depth = 0], [ $args = array()], string $output)
void end_lvl ( &$output, [ $depth = 0], [ $args = array()], string $output)
void get_number_of_root_elements ( $elements)
XHTML paged_walk ( $elements, int $max_depth, int $page_num,  $per_page)
void start_el ( &$output,  $object,  $depth,  $args, [ $current_object_id = 0], string $output)
void start_lvl ( &$output, [ $depth = 0], [ $args = array()], string $output)
void unset_children ( $e,  &$children_elements)
string walk (array $elements, int $max_depth)
Variables
int $max_pages = 1 (line 41)

Max number of pages walked by the paged walker

  • since: 2.7.0
  • access: protected
Methods
display_element (line 118)

Traverse elements to create list from elements.

Display one element if the element doesn't have any children otherwise, display the element and its children. Will only traverse up to the max depth and no ignore elements under that depth. It is possible to set the max depth to include all depths, see walk() method.

This method shouldn't be called directly, use the walk() method instead.

  • return: Null on failure with no changes to parameters.
  • since: 2.5.0
null display_element (object $element,  &$children_elements, int $max_depth, int $depth, array $args,  &$output, array $children_elements, string $output)
  • object $element: Data object
  • array $children_elements: List of elements to continue traversing.
  • int $max_depth: Max depth to traverse.
  • int $depth: Depth of current element.
  • array $args
  • string $output: Passed by reference. Used to append additional content.
  • &$children_elements
  • &$output

Redefined in descendants as:
  • Walker_Comment::display_element() : This function is designed to enhance Walker::display_element() to display children of higher nesting levels than selected inline on the highest depth level displayed. This prevents them being orphaned at the end of the comment list.
end_el (line 96)

Ends the element output, if needed.

Additional parameters are used in child classes. The args parameter holds additional values that may be used with the child class methods.

  • abstract:
  • since: 2.1.0
void end_el ( &$output,  $object, [ $depth = 0], [ $args = array()], string $output)
  • string $output: Passed by reference. Used to append additional content.
  • &$output
  • $object
  • $depth
  • $args

Redefined in descendants as:
end_lvl (line 69)

Ends the list of after the elements are added.

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.

  • abstract:
  • since: 2.1.0
void end_lvl ( &$output, [ $depth = 0], [ $args = array()], string $output)
  • string $output: Passed by reference. Used to append additional content.
  • &$output
  • $depth
  • $args

Redefined in descendants as:
get_number_of_root_elements (line 368)
void get_number_of_root_elements ( $elements)
  • $elements
paged_walk (line 260)

paged_walk() - produce a page of nested elements

Given an array of hierarchical elements, the maximum depth, a specific page number, and number of elements per page, this function first determines all top level root elements belonging to that page, then lists them and all of their children in hierarchical order.

  • return: of the specified page of elements
  • since: 2.7
XHTML paged_walk ( $elements, int $max_depth, int $page_num,  $per_page)
  • int $max_depth: = 0 means display all levels; $max_depth > 0 specifies the number of display levels.
  • int $page_num: the specific page number, beginning with 1.
  • $elements
  • $per_page
start_el (line 83)

Start the element output.

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.

  • abstract:
  • since: 2.1.0
void start_el ( &$output,  $object,  $depth,  $args, [ $current_object_id = 0], string $output)
  • string $output: Passed by reference. Used to append additional content.
  • &$output
  • $object
  • $depth
  • $args
  • $current_object_id

Redefined in descendants as:
start_lvl (line 55)

Starts the list before the elements are added.

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.

  • abstract:
  • since: 2.1.0
void start_lvl ( &$output, [ $depth = 0], [ $args = array()], string $output)
  • string $output: Passed by reference. Used to append additional content.
  • &$output
  • $depth
  • $args

Redefined in descendants as:
unset_children (line 381)
void unset_children ( $e,  &$children_elements)
  • $e
  • &$children_elements
walk (line 174)

Display array of elements hierarchically.

It is a generic function which does not assume any existing order of elements. max_depth = -1 means flatly display every element. max_depth =

  1. means display all levels. max_depth > 0 specifies the number of
display levels.

  • since: 2.1.0
string walk (array $elements, int $max_depth)
  • array $elements
  • int $max_depth

Documentation generated on Fri, 24 May 2013 23:18:28 +0000 by phpDocumentor 1.4.1