diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
index 94e898ea7c..1abf9f4c10 100644
--- a/src/wp-includes/post-template.php
+++ b/src/wp-includes/post-template.php
@@ -918,7 +918,7 @@ function the_meta() {
* @param array|string $args Optional. Override default arguments.
* @return string HTML content, if not displaying.
*/
-function wp_dropdown_pages($args = '') {
+function wp_dropdown_pages( $args = '' ) {
$defaults = array(
'depth' => 0, 'child_of' => 0,
'selected' => 0, 'echo' => 1,
@@ -928,21 +928,23 @@ function wp_dropdown_pages($args = '') {
);
$r = wp_parse_args( $args, $defaults );
- extract( $r, EXTR_SKIP );
- $pages = get_pages($r);
+ $pages = get_pages( $r );
$output = '';
// Back-compat with old system where both id and name were based on $name argument
- if ( empty($id) )
- $id = $name;
+ if ( empty( $r['id'] ) ) {
+ $r['id'] = $r['name'];
+ }
- if ( ! empty($pages) ) {
- $output = "
+
+LINEAGE;
+
+ $output = wp_dropdown_pages( array( 'echo' => 0 ) );
+ $this->assertEquals( $lineage, $output );
+
+ $depth =<<
+ Post title 1
+
+
+DEPTH;
+
+ $output = wp_dropdown_pages( array( 'echo' => 0, 'depth' => 1 ) );
+ $this->assertEquals( $depth, $output );
+
+ $option_none =<<
+ Hoo
+ Post title 1
+
+
+NONE;
+
+ $output = wp_dropdown_pages( array( 'echo' => 0, 'depth' => 1,
+ 'show_option_none' => 'Hoo', 'option_none_value' => 'Woo'
+ ) );
+ $this->assertEquals( $option_none, $output );
+
+ $option_no_change =<<
+ Burrito
+ Hoo
+ Post title 1
+
+
+NO;
+ $output = wp_dropdown_pages( array( 'echo' => 0, 'depth' => 1,
+ 'show_option_none' => 'Hoo', 'option_none_value' => 'Woo',
+ 'show_option_no_change' => 'Burrito'
+ ) );
+ $this->assertEquals( $option_no_change, $output );
+ }
}
\ No newline at end of file