From 14767d6c691048f5daaacdf35f97232edb68630b Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 5 Feb 2015 19:04:23 +0000 Subject: [PATCH] Introduce `'value_field'` parameter to `wp_dropdown_pages()`. This parameter allows developers to choose the post field that will be used to fill in the 'option' attribute of the generated dropdown markup. See [31006] #30306 for a parallel enhancement in `wp_dropdown_categories()`. Props jfarthing84. Fixes #12494. Built from https://develop.svn.wordpress.org/trunk@31338 git-svn-id: http://core.svn.wordpress.org/trunk@31319 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-template.php | 16 +++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 927c6592cd..e91358ec6a 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -971,7 +971,8 @@ function wp_dropdown_pages( $args = '' ) { 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'show_option_none' => '', 'show_option_no_change' => '', - 'option_none_value' => '' + 'option_none_value' => '', + 'value_field' => 'ID', ); $r = wp_parse_args( $args, $defaults ); @@ -1425,15 +1426,20 @@ class Walker_PageDropdown extends Walker { * @since 2.1.0 * * @param string $output Passed by reference. Used to append additional content. - * @param object $page Page data object. - * @param int $depth Depth of page in reference to parent pages. Used for padding. - * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element. + * @param object $page Page data object. + * @param int $depth Depth of page in reference to parent pages. Used for padding. + * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option + * element. Uses 'value_field' argument to fill "value" attribute. See {@see wp_dropdown_pages()}. * @param int $id */ public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) { $pad = str_repeat(' ', $depth * 3); - $output .= "\t