mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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
This commit is contained in:
parent
d1764d86e4
commit
14767d6c69
@ -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 );
|
||||
@ -1427,13 +1428,18 @@ class Walker_PageDropdown extends Walker {
|
||||
* @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 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<option class=\"level-$depth\" value=\"$page->ID\"";
|
||||
if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) {
|
||||
$args['value_field'] = 'ID';
|
||||
}
|
||||
|
||||
$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $page->{$args['value_field']} ) . "\"";
|
||||
if ( $page->ID == $args['selected'] )
|
||||
$output .= ' selected="selected"';
|
||||
$output .= '>';
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31337';
|
||||
$wp_version = '4.2-alpha-31338';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user