[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-wp-walker.php (summary)

(no description)

File Size: 449 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Walker:: (9 methods):
  start_lvl()
  end_lvl()
  start_el()
  end_el()
  display_element()
  walk()
  paged_walk()
  get_number_of_root_elements()
  unset_children()


Class: Walker  - X-Ref

A class for displaying various tree-like structures.

Extend the Walker class to use it, see examples 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.

start_lvl( &$output, $depth = 0, $args = array()   X-Ref
Starts the list before the elements are added.

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.

param: string $output Used to append additional content (passed by reference).
param: int    $depth  Depth of the item.
param: array  $args   An array of additional arguments.
since: 2.1.0

end_lvl( &$output, $depth = 0, $args = array()   X-Ref
Ends the list of after the elements are added.

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.

param: string $output Used to append additional content (passed by reference).
param: int    $depth  Depth of the item.
param: array  $args   An array of additional arguments.
since: 2.1.0

start_el( &$output, $data_object, $depth = 0, $args = array()   X-Ref
Starts the element output.

The $args parameter holds additional values that may be used with the child
class methods. Also includes the element output.

param: string $output            Used to append additional content (passed by reference).
param: object $data_object       The data object.
param: int    $depth             Depth of the item.
param: array  $args              An array of additional arguments.
param: int    $current_object_id Optional. ID of the current item. Default 0.
since: 2.1.0
since: 5.9.0 Renamed `$object` (a PHP reserved keyword) to `$data_object` for PHP 8 named parameter support.

end_el( &$output, $data_object, $depth = 0, $args = array()   X-Ref
Ends the element output, if needed.

The $args parameter holds additional values that may be used with the child class methods.

param: string $output      Used to append additional content (passed by reference).
param: object $data_object The data object.
param: int    $depth       Depth of the item.
param: array  $args        An array of additional arguments.
since: 2.1.0
since: 5.9.0 Renamed `$object` (a PHP reserved keyword) to `$data_object` for PHP 8 named parameter support.

display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output )   X-Ref
Traverses 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 should not be called directly, use the walk() method instead.

param: object $element           Data object.
param: array  $children_elements List of elements to continue traversing (passed by reference).
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            Used to append additional content (passed by reference).
since: 2.5.0

walk( $elements, $max_depth, ...$args )   X-Ref
Displays array of elements hierarchically.

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.

return: string The hierarchical item output.
param: array $elements  An array of elements.
param: int   $max_depth The maximum hierarchical depth.
param: mixed ...$args   Optional additional arguments.
since: 2.1.0
since: 5.3.0 Formalized the existing `...$args` parameter by adding it

paged_walk( $elements, $max_depth, $page_num, $per_page, ...$args )   X-Ref
Produces 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.

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

return: string XHTML of the specified page of elements.
param: array $elements  An array of elements.
param: int   $max_depth The maximum hierarchical depth.
param: int   $page_num  The specific page number, beginning with 1.
param: int   $per_page  Number of elements per page.
param: mixed ...$args   Optional additional arguments.
since: 2.7.0
since: 5.3.0 Formalized the existing `...$args` parameter by adding it

get_number_of_root_elements( $elements )   X-Ref
Calculates the total number of root elements.

return: int Number of root elements.
param: array $elements Elements to list.
since: 2.7.0

unset_children( $element, &$children_elements )   X-Ref
Unsets all the children for a given top level element.

param: object $element           The top level element.
param: array  $children_elements The children elements.
since: 2.7.0



Generated: Sat Nov 23 01:00:02 2024 Cross-referenced by PHPXref 0.7.1