X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/138998bbd8f7a1ac38b2f1eacbdf7cd522be4b13..ef91a7f4f3c6468973e192335a27ec0e0faca0b5:/wp-includes/class-walker-page.php diff --git a/wp-includes/class-walker-page.php b/wp-includes/class-walker-page.php index 3b3ca318..3fcaa67a 100644 --- a/wp-includes/class-walker-page.php +++ b/wp-includes/class-walker-page.php @@ -15,60 +15,103 @@ * @see Walker */ class Walker_Page extends Walker { + /** - * @see Walker::$tree_type + * What the class handles. + * * @since 2.1.0 + * @access public * @var string + * + * @see Walker::$tree_type */ public $tree_type = 'page'; /** - * @see Walker::$db_fields + * Database fields to use. + * * @since 2.1.0 - * @todo Decouple this. + * @access private * @var array + * + * @see Walker::$db_fields + * @todo Decouple this. */ - public $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); + public $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); /** - * @see Walker::start_lvl() + * Outputs the beginning of the current level in the tree before elements are output. + * * @since 2.1.0 + * @access public + * + * @see Walker::start_lvl() * * @param string $output Passed by reference. Used to append additional content. - * @param int $depth Depth of page. Used for padding. - * @param array $args + * @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() ) { - $indent = str_repeat("\t", $depth); - $output .= "\n$indent{$n}"; } /** + * Outputs the beginning of the current element in the tree. + * * @see Walker::start_el() * @since 2.1.0 + * @access public * - * @param string $output Passed by reference. Used to append additional content. - * @param object $page Page data object. - * @param int $depth Depth of page. Used for padding. - * @param int $current_page Page ID. - * @param array $args + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Post $page Page data object. + * @param int $depth Optional. Depth of page. Used for padding. Default 0. + * @param array $args Optional. Array of arguments. Default empty array. + * @param int $current_page Optional. Page ID. Default 0. */ public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) { + if ( 'preserve' === $args['item_spacing'] ) { + $t = "\t"; + $n = "\n"; + } else { + $t = ''; + $n = ''; + } if ( $depth ) { - $indent = str_repeat( "\t", $depth ); + $indent = str_repeat( $t, $depth ); } else { $indent = ''; } @@ -94,14 +137,14 @@ class Walker_Page extends Walker { } /** - * Filter the list of CSS classes to include with each page item in the list. + * Filters the list of CSS classes to include with each page item in the list. * * @since 2.8.0 * * @see wp_list_pages() * * @param array $css_class An array of CSS classes to be applied - * to each list item. + * to each list item. * @param WP_Post $page Page data object. * @param int $depth Depth of page, used for padding. * @param array $args An array of arguments. @@ -117,12 +160,12 @@ class Walker_Page extends Walker { $args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before']; $args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after']; - /** This filter is documented in wp-includes/post-template.php */ $output .= $indent . sprintf( '
  • %s%s%s', $css_classes, get_permalink( $page->ID ), $args['link_before'], + /** This filter is documented in wp-includes/post-template.php */ apply_filters( 'the_title', $page->post_title, $page->ID ), $args['link_after'] ); @@ -140,16 +183,27 @@ class Walker_Page extends Walker { } /** - * @see Walker::end_el() + * Outputs the end of the current element in the tree. + * * @since 2.1.0 + * @access public * - * @param string $output Passed by reference. Used to append additional content. - * @param object $page Page data object. Not used. - * @param int $depth Depth of page. Not Used. - * @param array $args + * @see Walker::end_el() + * + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Post $page Page data object. Not used. + * @param int $depth Optional. Depth of page. Default 0 (unused). + * @param array $args Optional. Array of arguments. Default empty array. */ public function end_el( &$output, $page, $depth = 0, $args = array() ) { - $output .= "
  • \n"; + if ( 'preserve' === $args['item_spacing'] ) { + $t = "\t"; + $n = "\n"; + } else { + $t = ''; + $n = ''; + } + $output .= "{$n}"; } }