wppaste
WordPress

Walker_Page

Since
2.1.0
Source
wp-includes/class-walker-page.php:17
Core walker class used to create an HTML list of pages.

Compatibility

WordPress
since 2.1.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 3

Every hook that fires from inside Walker_Page, in the order it appears in the class, grouped by the method that fires it.

Properties · 2

$tree_typestringpublic
What the class handles.
$db_fieldsstring[]public
Database fields to use.

Methods · 4

  • start_lvl()Outputs the beginning of the current level in the tree before elements are output.
  • end_lvl()Outputs the end of the current level in the tree after elements are output.
  • start_el()Outputs the beginning of the current element in the tree.
  • end_el()Outputs the end of the current element in the tree.

Source code

class Walker_Page extends Walker { 	/**	 * What the class handles.	 *	 * @since 2.1.0	 * @var string	 *	 * @see Walker::$tree_type	 */	public $tree_type = 'page'; 	/**	 * Database fields to use.	 *	 * @since 2.1.0	 * @var string[]	 *	 * @see Walker::$db_fields	 * @todo Decouple this.	 */	public $db_fields = array(		'parent' => 'post_parent',		'id'     => 'ID',	); 	/**	 * Outputs the beginning of the current level in the tree before elements are output.	 *	 * @since 2.1.0	 *	 * @see Walker::start_lvl()	 *	 * @param string $output Used to append additional content (passed by reference).	 * @param int    $depth  Optional. Depth of page. Used for padding. Default 0.	 * @param array  $args   Optional. Arguments for outputting the next level.	 *                       Default empty array.	 */	public function start_lvl( &$output, $depth = 0, $args = array() ) {		if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) {			$t = "\t";			$n = "\n";		} else {			$t = '';			$n = '';		}		$indent  = str_repeat( $t, $depth );		$output .= "{$n}{$indent}<ul class='children'>{$n}";	} 	/**	 * Outputs the end of the current level in the tree after elements are output.	 *	 * @since 2.1.0	 *	 * @see Walker::end_lvl()	 *	 * @param string $output Used to append additional content (passed by reference).	 * @param int    $depth  Optional. Depth of page. Used for padding. Default 0.	 * @param array  $args   Optional. Arguments for outputting the end of the current level.	 *                       Default empty array.	 */	public function end_lvl( &$output, $depth = 0, $args = array() ) {		if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) {			$t = "\t";			$n = "\n";		} else {			$t = '';			$n = '';		}		$indent  = str_repeat( $t, $depth );		$output .= "{$indent}</ul>{$n}";	} 	/**	 * Outputs the beginning of the current element in the tree.	 *	 * @see Walker::start_el()	 * @since 2.1.0	 * @since 5.9.0 Renamed `$page` to `$data_object` and `$current_page` to `$current_object_id`

Changelog

Introduced in 2.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/class-walker-page.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.