Add missing access modifiers to methods/members in `Walker` and subclasses. Add a magic `__get()` method.

See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28514


git-svn-id: http://core.svn.wordpress.org/trunk@28340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-05-19 06:00:15 +00:00
parent df8a090193
commit dfa4de15fa
5 changed files with 47 additions and 36 deletions

View File

@ -21,8 +21,8 @@
* @since 2.5.1
*/
class Walker_Category_Checklist extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
public $tree_type = 'category';
public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
/**
* Starts the list before the elements are added.

View File

@ -19,7 +19,7 @@ class Walker {
* @var string
* @access public
*/
var $tree_type;
public $tree_type;
/**
* DB fields to use.
@ -28,7 +28,7 @@ class Walker {
* @var array
* @access protected
*/
var $db_fields;
protected $db_fields;
/**
* Max number of pages walked by the paged walker
@ -37,7 +37,18 @@ class Walker {
* @var int
* @access protected
*/
var $max_pages = 1;
protected $max_pages = 1;
/**
* Make private properties readable for backwards compatibility
*
* @since 4.0.0
* @param string $name
* @return mixed
*/
public function __get( $name ) {
return $this->$name;
}
/**
* Starts the list before the elements are added.
@ -52,7 +63,7 @@ class Walker {
* @param int $depth Depth of the item.
* @param array $args An array of additional arguments.
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {}
public function start_lvl( &$output, $depth = 0, $args = array() ) {}
/**
* Ends the list of after the elements are added.
@ -67,7 +78,7 @@ class Walker {
* @param int $depth Depth of the item.
* @param array $args An array of additional arguments.
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {}
public function end_lvl( &$output, $depth = 0, $args = array() ) {}
/**
* Start the element output.
@ -84,7 +95,7 @@ class Walker {
* @param array $args An array of additional arguments.
* @param int $current_object_id ID of the current item.
*/
function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
/**
* Ends the element output, if needed.
@ -99,7 +110,7 @@ class Walker {
* @param int $depth Depth of the item.
* @param array $args An array of additional arguments.
*/
function end_el( &$output, $object, $depth = 0, $args = array() ) {}
public function end_el( &$output, $object, $depth = 0, $args = array() ) {}
/**
* Traverse elements to create list from elements.
@ -121,7 +132,7 @@ class Walker {
* @param string $output Passed by reference. Used to append additional content.
* @return null Null on failure with no changes to parameters.
*/
function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if ( !$element )
return;
@ -178,7 +189,7 @@ class Walker {
* @param int $max_depth The maximum hierarchical depth.
* @return string The hierarchical item output.
*/
function walk( $elements, $max_depth) {
public function walk( $elements, $max_depth) {
$args = array_slice(func_get_args(), 2);
$output = '';
@ -266,7 +277,7 @@ class Walker {
* @param int $page_num The specific page number, beginning with 1.
* @return string XHTML of the specified page of elements
*/
function paged_walk( $elements, $max_depth, $page_num, $per_page ) {
public function paged_walk( $elements, $max_depth, $page_num, $per_page ) {
/* sanity check */
if ( empty($elements) || $max_depth < -1 )
@ -373,7 +384,7 @@ class Walker {
return $output;
}
function get_number_of_root_elements( $elements ){
public function get_number_of_root_elements( $elements ){
$num = 0;
$parent_field = $this->db_fields['parent'];
@ -386,7 +397,7 @@ class Walker {
}
// Unset all the children for a given top level element.
function unset_children( $e, &$children_elements ){
public function unset_children( $e, &$children_elements ){
if ( !$e || !$children_elements )
return;

View File

@ -1558,7 +1558,7 @@ class Walker_Comment extends Walker {
* @since 2.7.0
* @var string
*/
var $tree_type = 'comment';
public $tree_type = 'comment';
/**
* DB fields to use.
@ -1568,7 +1568,7 @@ class Walker_Comment extends Walker {
* @since 2.7.0
* @var array
*/
var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
public $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
/**
* Start the list before the elements are added.
@ -1581,7 +1581,7 @@ class Walker_Comment extends Walker {
* @param int $depth Depth of comment.
* @param array $args Uses 'style' argument for type of HTML list.
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 1;
switch ( $args['style'] ) {
@ -1608,7 +1608,7 @@ class Walker_Comment extends Walker {
* @param int $depth Depth of comment.
* @param array $args Will only append content if style argument value is 'ol' or 'ul'.
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {
public function end_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 1;
switch ( $args['style'] ) {
@ -1656,7 +1656,7 @@ class Walker_Comment extends Walker {
* @param string $output Passed by reference. Used to append additional content.
* @return null Null on failure with no changes to parameters.
*/
function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if ( !$element )
return;
@ -1690,7 +1690,7 @@ class Walker_Comment extends Walker {
* @param int $depth Depth of comment in reference to parents.
* @param array $args An array of arguments.
*/
function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
$depth++;
$GLOBALS['comment_depth'] = $depth;
$GLOBALS['comment'] = $comment;
@ -1730,7 +1730,7 @@ class Walker_Comment extends Walker {
* @param int $depth Depth of comment.
* @param array $args An array of arguments.
*/
function end_el( &$output, $comment, $depth = 0, $args = array() ) {
public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
if ( !empty( $args['end-callback'] ) ) {
ob_start();
call_user_func( $args['end-callback'], $comment, $args, $depth );

View File

@ -21,7 +21,7 @@ class Walker_Nav_Menu extends Walker {
* @since 3.0.0
* @var string
*/
var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
public $tree_type = array( 'post_type', 'taxonomy', 'custom' );
/**
* Database fields to use.
@ -31,7 +31,7 @@ class Walker_Nav_Menu extends Walker {
* @todo Decouple this.
* @var array
*/
var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
public $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
/**
* Starts the list before the elements are added.
@ -44,7 +44,7 @@ class Walker_Nav_Menu extends Walker {
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of arguments. @see wp_nav_menu()
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"sub-menu\">\n";
}
@ -60,7 +60,7 @@ class Walker_Nav_Menu extends Walker {
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of arguments. @see wp_nav_menu()
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {
public function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
@ -78,7 +78,7 @@ class Walker_Nav_Menu extends Walker {
* @param array $args An array of arguments. @see wp_nav_menu()
* @param int $id Current item ID.
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
@ -186,7 +186,7 @@ class Walker_Nav_Menu extends Walker {
* @param int $depth Depth of page. Not Used.
* @param array $args An array of arguments. @see wp_nav_menu()
*/
function end_el( &$output, $item, $depth = 0, $args = array() ) {
public function end_el( &$output, $item, $depth = 0, $args = array() ) {
$output .= "</li>\n";
}

View File

@ -1226,7 +1226,7 @@ class Walker_Page extends Walker {
* @since 2.1.0
* @var string
*/
var $tree_type = 'page';
public $tree_type = 'page';
/**
* @see Walker::$db_fields
@ -1234,7 +1234,7 @@ class Walker_Page extends Walker {
* @todo Decouple this.
* @var array
*/
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
public $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
/**
* @see Walker::start_lvl()
@ -1244,7 +1244,7 @@ class Walker_Page extends Walker {
* @param int $depth Depth of page. Used for padding.
* @param array $args
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class='children'>\n";
}
@ -1257,7 +1257,7 @@ class Walker_Page extends Walker {
* @param int $depth Depth of page. Used for padding.
* @param array $args
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {
public function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
@ -1272,7 +1272,7 @@ class Walker_Page extends Walker {
* @param int $current_page Page ID.
* @param array $args
*/
function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
if ( $depth ) {
$indent = str_repeat( "\t", $depth );
} else {
@ -1353,7 +1353,7 @@ class Walker_Page extends Walker {
* @param int $depth Depth of page. Not Used.
* @param array $args
*/
function end_el( &$output, $page, $depth = 0, $args = array() ) {
public function end_el( &$output, $page, $depth = 0, $args = array() ) {
$output .= "</li>\n";
}
@ -1371,7 +1371,7 @@ class Walker_PageDropdown extends Walker {
* @since 2.1.0
* @var string
*/
var $tree_type = 'page';
public $tree_type = 'page';
/**
* @see Walker::$db_fields
@ -1379,7 +1379,7 @@ class Walker_PageDropdown extends Walker {
* @todo Decouple this
* @var array
*/
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
public $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
/**
* @see Walker::start_el()
@ -1391,7 +1391,7 @@ class Walker_PageDropdown extends Walker {
* @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
* @param int $id
*/
function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
$pad = str_repeat('&nbsp;', $depth * 3);
$output .= "\t<option class=\"level-$depth\" value=\"$page->ID\"";