Index: wp-admin/options-reading.php
===================================================================
--- wp-admin/options-reading.php	(revision 32725)
+++ wp-admin/options-reading.php	(working copy)
@@ -111,7 +111,7 @@
 	</label>
 	</p>
 <ul>
-	<li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li>
+	<li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( array( 'include_templates'=>true,  'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li>
 	<li><label for="page_for_posts"><?php printf( __( 'Posts page: %s' ), wp_dropdown_pages( array( 'name' => 'page_for_posts', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) ) ) ); ?></label></li>
 </ul>
 <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
Index: wp-includes/canonical.php
===================================================================
--- wp-includes/canonical.php	(revision 32725)
+++ wp-includes/canonical.php	(working copy)
@@ -162,7 +162,7 @@
 		} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
 			if ( $redirect_url = get_permalink(get_query_var('page_id')) )
 				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
-		} elseif ( is_page() && !is_feed() && isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front')  && ! $redirect_url ) {
+		} elseif ( is_page() && !is_feed() && isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') && is_numeric(get_option('page_on_front')) && ! $redirect_url ) {
 			$redirect_url = home_url('/');
 		} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts')  && ! $redirect_url ) {
 			if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
Index: wp-includes/class-wp-customize-control.php
===================================================================
--- wp-includes/class-wp-customize-control.php	(revision 32725)
+++ wp-includes/class-wp-customize-control.php	(working copy)
@@ -483,6 +483,7 @@
 						'show_option_none'  => __( '&mdash; Select &mdash;' ),
 						'option_none_value' => '0',
 						'selected'          => $this->value(),
+						'include_templates' => ( $this->id == 'page_on_front' )
 					)
 				);
 
Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 32725)
+++ wp-includes/formatting.php	(working copy)
@@ -3379,7 +3379,6 @@
 		case 'large_size_h':
 		case 'mailserver_port':
 		case 'comment_max_links':
-		case 'page_on_front':
 		case 'page_for_posts':
 		case 'rss_excerpt_length':
 		case 'default_category':
@@ -3393,6 +3392,17 @@
 			$value = absint( $value );
 			break;
 
+		case 'page_on_front':
+		case 'old_page_on_front':
+			if( is_numeric( $value ) ) {
+				$value = absint( $value );
+			} else {
+				if( locate_template( $value ) == '' ) {
+					$value = 0;
+				}
+			}
+			break;
+
 		case 'posts_per_page':
 		case 'posts_per_rss':
 			$value = (int) $value;
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 32725)
+++ wp-includes/link-template.php	(working copy)
@@ -319,7 +319,7 @@
 function get_page_link( $post = false, $leavename = false, $sample = false ) {
 	$post = get_post( $post );
 
-	if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) )
+	if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) && is_numeric(get_option('page_on_front')) )
 		$link = home_url('/');
 	else
 		$link = _get_page_link( $post, $leavename, $sample );
@@ -639,7 +639,7 @@
 		$feed = get_default_feed();
 
 	if ( '' != get_option('permalink_structure') ) {
-		if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') )
+		if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') && is_numeric(get_option('page_on_front')) )
 			$url = _get_page_link( $post_id );
 		else
 			$url = get_permalink($post_id);
@@ -3334,7 +3334,7 @@
 	if ( ! empty( $post_id ) ) {
 		$post_type = get_post_type_object( $post->post_type );
 
-		if ( 'page' === $post->post_type && $post->ID == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) ) {
+		if ( 'page' === $post->post_type && $post->ID == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) && is_numeric(get_option('page_on_front')) ) {
 			$shortlink = home_url( '/' );
 		} elseif ( $post_type->public ) {
 			$shortlink = home_url( '?p=' . $post_id );
Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php	(revision 32725)
+++ wp-includes/post-template.php	(working copy)
@@ -905,7 +905,7 @@
 	} else {
 		if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
 			$url = add_query_arg( 'page', $i, get_permalink() );
-		elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
+		elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID && is_numeric(get_option('page_on_front')) )
 			$url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
 		else
 			$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
@@ -1019,11 +1019,19 @@
 		'show_option_none' => '', 'show_option_no_change' => '',
 		'option_none_value' => '',
 		'value_field' => 'ID',
+		'include_templates'=>false
 	);
 
 	$r = wp_parse_args( $args, $defaults );
 
 	$pages = get_pages( $r );
+
+	if ( $r['include_templates'] ) {
+		$templates = get_page_templates();
+	}else{
+		$templates = array();
+	}
+
 	$output = '';
 	// Back-compat with old system where both id and name were based on $name argument
 	if ( empty( $r['id'] ) ) {
@@ -1030,8 +1038,9 @@
 		$r['id'] = $r['name'];
 	}
 
-	if ( ! empty( $pages ) ) {
+	if ( ! empty( $pages ) || ! empty( $templates )) {
 		$output = "<select name='" . esc_attr( $r['name'] ) . "' id='" . esc_attr( $r['id'] ) . "'>\n";
+
 		if ( $r['show_option_no_change'] ) {
 			$output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
 		}
@@ -1038,7 +1047,27 @@
 		if ( $r['show_option_none'] ) {
 			$output .= "\t<option value=\"" . esc_attr( $r['option_none_value'] ) . '">' . $r['show_option_none'] . "</option>\n";
 		}
-		$output .= walk_page_dropdown_tree( $pages, $r['depth'], $r );
+		if( ! empty( $pages )) {
+			if ( $r['include_templates'] ) {
+				$output .= "<optgroup label=\"" . __('Pages') . "\" >";
+			}
+			$output .= walk_page_dropdown_tree( $pages, $r['depth'], $r );
+			if ( $r['include_templates'] ) {
+				$output .= "</optgroup>";
+			}
+		}
+		if( ! empty( $templates ) && $r['include_templates'] ) {
+			$output .= "<optgroup label=\"" . __('Templates') . "\" >";
+			foreach ( $templates as $template_name=>$template_file ){
+				$output .= "\t<option value=\"" . esc_attr( $template_file ) . "\"";
+				if ( $template_file == $args['selected'] )
+					$output .= ' selected="selected"';
+				$output .= '>';
+				$output .= esc_html( $template_name ) ;
+				$output .= "</option>\n";
+			}
+			$output .= "</optgroup>";
+		}
 		$output .= "</select>\n";
 	}
 
@@ -1228,7 +1257,9 @@
 			} else {
 				$list_args['exclude'] = '';
 			}
-			$list_args['exclude'] .= get_option('page_on_front');
+			if( is_numeric(get_option('page_on_front')) ){
+				$list_args['exclude'] .= get_option('page_on_front');
+			}
 		}
 	}
 
Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 32725)
+++ wp-includes/query.php	(working copy)
@@ -1751,7 +1751,7 @@
 			$this->is_home = true;
 
 		// Correct is_* for page_on_front and page_for_posts
-		if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) {
+		if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') && is_numeric(get_option('page_on_front')) ) {
 			$_query = wp_parse_args($this->query);
 			// pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.
 			if ( isset($_query['pagename']) && '' == $_query['pagename'] )
@@ -1759,7 +1759,9 @@
 			if ( empty($_query) || !array_diff( array_keys($_query), array('preview', 'page', 'paged', 'cpage') ) ) {
 				$this->is_page = true;
 				$this->is_home = false;
-				$qv['page_id'] = get_option('page_on_front');
+				if(is_numeric(get_option('page_on_front'))) {
+					$qv['page_id'] = get_option('page_on_front');
+				}
 				// Correct <!--nextpage--> for page_on_front
 				if ( !empty($qv['paged']) ) {
 					$qv['page'] = $qv['paged'];
@@ -2494,7 +2496,7 @@
 		if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 )
 			$q['comments_per_page'] = get_option('comments_per_page');
 
-		if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) {
+		if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') && is_numeric(get_option('page_on_front'))) {
 			$this->is_page = true;
 			$this->is_home = false;
 			$q['page_id'] = get_option('page_on_front');
@@ -4316,7 +4318,7 @@
 		// most likely case
 		if ( 'posts' == get_option( 'show_on_front') && $this->is_home() )
 			return true;
-		elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) )
+		elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && ( $this->is_page( get_option( 'page_on_front' ) ) || locate_template( get_option( 'page_on_front' ) ) != '' ) )
 			return true;
 		else
 			return false;
Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 32725)
+++ wp-includes/rewrite.php	(working copy)
@@ -1476,7 +1476,7 @@
 			$commentmatch = $match . $commentregex;
 			$commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1);
 
-			if ( get_option('page_on_front') ) {
+			if ( get_option('page_on_front')  && is_numeric(get_option('page_on_front')) ) {
 				//create query for Root /comment-page-xx
 				$rootcommentmatch = $match . $commentregex;
 				$rootcommentquery = $index . '?' . $query . '&page_id=' . get_option('page_on_front') . '&cpage=' . $this->preg_index($num_toks + 1);
@@ -1506,7 +1506,7 @@
 			//only on pages with comments add ../comment-page-xx/
 			if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) {
 				$rewrite = array_merge($rewrite, array($commentmatch => $commentquery));
-			} elseif ( EP_ROOT & $ep_mask && get_option('page_on_front') ) {
+			} elseif ( EP_ROOT & $ep_mask && get_option('page_on_front') && is_numeric(get_option('page_on_front')) ) {
 				$rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery));
 			}
 			//do endpoints
Index: wp-includes/template.php
===================================================================
--- wp-includes/template.php	(revision 32725)
+++ wp-includes/template.php	(working copy)
@@ -286,7 +286,11 @@
  */
 function get_front_page_template() {
 	$templates = array('front-page.php');
-
+	if( get_option( "show_on_front" ) == "page" && ! is_numeric( get_option( "page_on_front" ) ) ){
+		if( locate_template( get_option( "page_on_front" ) ) != '' ) {
+			$templates = array( get_option("page_on_front") );
+		}
+	}
 	return get_query_template( 'front_page', $templates );
 }
 
Index: wp-includes/theme.php
===================================================================
--- wp-includes/theme.php	(revision 32725)
+++ wp-includes/theme.php	(working copy)
@@ -1952,7 +1952,22 @@
 			remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
 			update_option( 'theme_switched_via_customizer', false );
 		}
+		$value_frontpage = get_theme_support( 'custom-frontpage' ) ;
+		$template_frontpage = isset( $value_frontpage[0] ) ? $value_frontpage[0] : '';
 
+		if( ! empty ( $template_frontpage ) ){
+			update_option( 'old_page_on_front' , get_option( 'page_on_front' ) );
+			update_option( 'old_show_on_front' , get_option( 'show_on_front' ) );
+			update_option( 'page_on_front' , $template_frontpage . '.php' );
+			update_option( 'show_on_front' , 'page' );
+		}else{
+			$old_frontpage = get_option( 'old_page_on_front' );
+			$old_show_on_front = get_option( 'old_show_on_front' );
+			if( $old_frontpage !== false  &&   $old_show_on_front !== false  ){
+				update_option( 'page_on_front',$old_frontpage );
+				update_option( 'show_on_front',$old_show_on_front );
+			}
+		}
 		if ( $old_theme->exists() ) {
 			/**
 			 * Fires on the first WP load after a theme switch if the old theme still exists.
