52 * attribute for option element. Uses 'value_field' argument to fill "value" |
55 * attribute for option element. Uses 'value_field' argument to fill "value" |
53 * attribute. See wp_dropdown_pages(). Default empty array. |
56 * attribute. See wp_dropdown_pages(). Default empty array. |
54 * @param int $id Optional. ID of the current page. Default 0 (unused). |
57 * @param int $id Optional. ID of the current page. Default 0 (unused). |
55 */ |
58 */ |
56 public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) { |
59 public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) { |
57 $pad = str_repeat(' ', $depth * 3); |
60 $pad = str_repeat( ' ', $depth * 3 ); |
58 |
61 |
59 if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) { |
62 if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) { |
60 $args['value_field'] = 'ID'; |
63 $args['value_field'] = 'ID'; |
61 } |
64 } |
62 |
65 |
63 $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $page->{$args['value_field']} ) . "\""; |
66 $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $page->{$args['value_field']} ) . '"'; |
64 if ( $page->ID == $args['selected'] ) |
67 if ( $page->ID == $args['selected'] ) { |
65 $output .= ' selected="selected"'; |
68 $output .= ' selected="selected"'; |
|
69 } |
66 $output .= '>'; |
70 $output .= '>'; |
67 |
71 |
68 $title = $page->post_title; |
72 $title = $page->post_title; |
69 if ( '' === $title ) { |
73 if ( '' === $title ) { |
70 /* translators: %d: ID of a post */ |
74 /* translators: %d: ID of a post */ |
74 /** |
78 /** |
75 * Filters the page title when creating an HTML drop-down list of pages. |
79 * Filters the page title when creating an HTML drop-down list of pages. |
76 * |
80 * |
77 * @since 3.1.0 |
81 * @since 3.1.0 |
78 * |
82 * |
79 * @param string $title Page title. |
83 * @param string $title Page title. |
80 * @param object $page Page data object. |
84 * @param WP_Post $page Page data object. |
81 */ |
85 */ |
82 $title = apply_filters( 'list_pages', $title, $page ); |
86 $title = apply_filters( 'list_pages', $title, $page ); |
83 |
87 |
84 $output .= $pad . esc_html( $title ); |
88 $output .= $pad . esc_html( $title ); |
85 $output .= "</option>\n"; |
89 $output .= "</option>\n"; |