wp/wp-includes/class-walker-page-dropdown.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    33 	 * @var array
    33 	 * @var array
    34 	 *
    34 	 *
    35 	 * @see Walker::$db_fields
    35 	 * @see Walker::$db_fields
    36 	 * @todo Decouple this
    36 	 * @todo Decouple this
    37 	 */
    37 	 */
    38 	public $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
    38 	public $db_fields = array(
       
    39 		'parent' => 'post_parent',
       
    40 		'id'     => 'ID',
       
    41 	);
    39 
    42 
    40 	/**
    43 	/**
    41 	 * Starts the element output.
    44 	 * Starts the element output.
    42 	 *
    45 	 *
    43 	 * @since 2.1.0
    46 	 * @since 2.1.0
    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";