Print out option HTML elements for the page templates drop-down.

Signature

page_template_dropdown( $default = '', $post_type = 'page' )
default
 (string) Optional. The template file name. Default empty.
Default: ''
post_type
 (string) Optional. Post type to get templates for. Default 'post'.
Default: 'page'

Return

(void)

Source

function page_template_dropdown( $default = '', $post_type = 'page' ) {
	$templates = get_page_templates( null, $post_type );
	ksort( $templates );
	foreach ( array_keys( $templates ) as $template ) {
		$selected = selected( $default, $templates[ $template ], false );
		echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . "</option>";
	}
}
WP Trac GitHub

Link here