Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-includes/post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ function wp_dropdown_pages( $args = '' ) {
* the given n depth). Default 0.
* @type bool $echo Whether or not to echo the list of pages. Default true.
* @type string $exclude Comma-separated list of page IDs to exclude. Default empty.
* @type array $include Comma-separated list of page IDs to include. Default empty.
* @type int[]|string $include Array or comma-separated list of page IDs to include. Default empty array.
Comment on lines 1290 to +1291

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in my ticket comment, I think both $include and $exclude should be changed to be documented to be int[], and for the function to leverage wp_parse_id_list().

* @type string $link_after Text or HTML to follow the page link label. Default null.
* @type string $link_before Text or HTML to precede the page link label. Default null.
* @type string $post_type Post type to query for. Default 'page'.
Expand Down
16 changes: 16 additions & 0 deletions tests/phpunit/tests/post/wpListPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,22 @@ public function test_wp_list_pages_include() {
$this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) );
}

/**
* @ticket 66052
*/
public function test_wp_list_pages_include_accepts_array_of_ids() {
$args = array(
'echo' => false,
'include' => array( self::$parent_1, self::$parent_3 ),
);

$expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . '"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a></li>
<li class="page_item page-item-' . self::$parent_3 . '"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li>
</ul></li>';

$this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) );
}

public function test_wp_list_pages_exclude_tree() {
$args = array(
'echo' => false,
Expand Down
Loading