Ticket #19627: frontpage.patch
File frontpage.patch, 13.4 KB (added by , 8 years ago) |
---|
-
wp-admin/options-reading.php
111 111 </label> 112 112 </p> 113 113 <ul> 114 <li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( array( ' name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li>114 <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' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li> 115 115 <li><label for="page_for_posts"><?php printf( __( 'Posts page: %s' ), wp_dropdown_pages( array( 'name' => 'page_for_posts', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) ) ) ); ?></label></li> 116 116 </ul> 117 117 <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?> -
wp-includes/canonical.php
162 162 } elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) { 163 163 if ( $redirect_url = get_permalink(get_query_var('page_id')) ) 164 164 $redirect['query'] = remove_query_arg('page_id', $redirect['query']); 165 } 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 ) {165 } 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 ) { 166 166 $redirect_url = home_url('/'); 167 167 } 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 ) { 168 168 if ( $redirect_url = get_permalink(get_option('page_for_posts')) ) -
wp-includes/class-wp-customize-control.php
483 483 'show_option_none' => __( '— Select —' ), 484 484 'option_none_value' => '0', 485 485 'selected' => $this->value(), 486 'include_templates' => ( $this->id == 'page_on_front' ) 486 487 ) 487 488 ); 488 489 -
wp-includes/formatting.php
3379 3379 case 'large_size_h': 3380 3380 case 'mailserver_port': 3381 3381 case 'comment_max_links': 3382 case 'page_on_front':3383 3382 case 'page_for_posts': 3384 3383 case 'rss_excerpt_length': 3385 3384 case 'default_category': … … 3393 3392 $value = absint( $value ); 3394 3393 break; 3395 3394 3395 case 'page_on_front': 3396 case 'old_page_on_front': 3397 if( is_numeric( $value ) ) { 3398 $value = absint( $value ); 3399 } else { 3400 if( locate_template( $value ) == '' ) { 3401 $value = 0; 3402 } 3403 } 3404 break; 3405 3396 3406 case 'posts_per_page': 3397 3407 case 'posts_per_rss': 3398 3408 $value = (int) $value; -
wp-includes/link-template.php
319 319 function get_page_link( $post = false, $leavename = false, $sample = false ) { 320 320 $post = get_post( $post ); 321 321 322 if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) )322 if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) && is_numeric(get_option('page_on_front')) ) 323 323 $link = home_url('/'); 324 324 else 325 325 $link = _get_page_link( $post, $leavename, $sample ); … … 639 639 $feed = get_default_feed(); 640 640 641 641 if ( '' != get_option('permalink_structure') ) { 642 if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') )642 if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') && is_numeric(get_option('page_on_front')) ) 643 643 $url = _get_page_link( $post_id ); 644 644 else 645 645 $url = get_permalink($post_id); … … 3334 3334 if ( ! empty( $post_id ) ) { 3335 3335 $post_type = get_post_type_object( $post->post_type ); 3336 3336 3337 if ( 'page' === $post->post_type && $post->ID == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) ) {3337 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')) ) { 3338 3338 $shortlink = home_url( '/' ); 3339 3339 } elseif ( $post_type->public ) { 3340 3340 $shortlink = home_url( '?p=' . $post_id ); -
wp-includes/post-template.php
905 905 } else { 906 906 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 907 907 $url = add_query_arg( 'page', $i, get_permalink() ); 908 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )908 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID && is_numeric(get_option('page_on_front')) ) 909 909 $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged'); 910 910 else 911 911 $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged'); … … 1019 1019 'show_option_none' => '', 'show_option_no_change' => '', 1020 1020 'option_none_value' => '', 1021 1021 'value_field' => 'ID', 1022 'include_templates'=>false 1022 1023 ); 1023 1024 1024 1025 $r = wp_parse_args( $args, $defaults ); 1025 1026 1026 1027 $pages = get_pages( $r ); 1028 1029 if ( $r['include_templates'] ) { 1030 $templates = get_page_templates(); 1031 }else{ 1032 $templates = array(); 1033 } 1034 1027 1035 $output = ''; 1028 1036 // Back-compat with old system where both id and name were based on $name argument 1029 1037 if ( empty( $r['id'] ) ) { … … 1030 1038 $r['id'] = $r['name']; 1031 1039 } 1032 1040 1033 if ( ! empty( $pages ) ) {1041 if ( ! empty( $pages ) || ! empty( $templates )) { 1034 1042 $output = "<select name='" . esc_attr( $r['name'] ) . "' id='" . esc_attr( $r['id'] ) . "'>\n"; 1043 1035 1044 if ( $r['show_option_no_change'] ) { 1036 1045 $output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n"; 1037 1046 } … … 1038 1047 if ( $r['show_option_none'] ) { 1039 1048 $output .= "\t<option value=\"" . esc_attr( $r['option_none_value'] ) . '">' . $r['show_option_none'] . "</option>\n"; 1040 1049 } 1041 $output .= walk_page_dropdown_tree( $pages, $r['depth'], $r ); 1050 if( ! empty( $pages )) { 1051 if ( $r['include_templates'] ) { 1052 $output .= "<optgroup label=\"" . __('Pages') . "\" >"; 1053 } 1054 $output .= walk_page_dropdown_tree( $pages, $r['depth'], $r ); 1055 if ( $r['include_templates'] ) { 1056 $output .= "</optgroup>"; 1057 } 1058 } 1059 if( ! empty( $templates ) && $r['include_templates'] ) { 1060 $output .= "<optgroup label=\"" . __('Templates') . "\" >"; 1061 foreach ( $templates as $template_name=>$template_file ){ 1062 $output .= "\t<option value=\"" . esc_attr( $template_file ) . "\""; 1063 if ( $template_file == $args['selected'] ) 1064 $output .= ' selected="selected"'; 1065 $output .= '>'; 1066 $output .= esc_html( $template_name ) ; 1067 $output .= "</option>\n"; 1068 } 1069 $output .= "</optgroup>"; 1070 } 1042 1071 $output .= "</select>\n"; 1043 1072 } 1044 1073 … … 1228 1257 } else { 1229 1258 $list_args['exclude'] = ''; 1230 1259 } 1231 $list_args['exclude'] .= get_option('page_on_front'); 1260 if( is_numeric(get_option('page_on_front')) ){ 1261 $list_args['exclude'] .= get_option('page_on_front'); 1262 } 1232 1263 } 1233 1264 } 1234 1265 -
wp-includes/query.php
1751 1751 $this->is_home = true; 1752 1752 1753 1753 // Correct is_* for page_on_front and page_for_posts 1754 if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) {1754 if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') && is_numeric(get_option('page_on_front')) ) { 1755 1755 $_query = wp_parse_args($this->query); 1756 1756 // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. 1757 1757 if ( isset($_query['pagename']) && '' == $_query['pagename'] ) … … 1759 1759 if ( empty($_query) || !array_diff( array_keys($_query), array('preview', 'page', 'paged', 'cpage') ) ) { 1760 1760 $this->is_page = true; 1761 1761 $this->is_home = false; 1762 $qv['page_id'] = get_option('page_on_front'); 1762 if(is_numeric(get_option('page_on_front'))) { 1763 $qv['page_id'] = get_option('page_on_front'); 1764 } 1763 1765 // Correct <!--nextpage--> for page_on_front 1764 1766 if ( !empty($qv['paged']) ) { 1765 1767 $qv['page'] = $qv['paged']; … … 2494 2496 if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 ) 2495 2497 $q['comments_per_page'] = get_option('comments_per_page'); 2496 2498 2497 if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) {2499 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'))) { 2498 2500 $this->is_page = true; 2499 2501 $this->is_home = false; 2500 2502 $q['page_id'] = get_option('page_on_front'); … … 4316 4318 // most likely case 4317 4319 if ( 'posts' == get_option( 'show_on_front') && $this->is_home() ) 4318 4320 return true; 4319 elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' )) )4321 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' ) ) != '' ) ) 4320 4322 return true; 4321 4323 else 4322 4324 return false; -
wp-includes/rewrite.php
1476 1476 $commentmatch = $match . $commentregex; 1477 1477 $commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1); 1478 1478 1479 if ( get_option('page_on_front') ) {1479 if ( get_option('page_on_front') && is_numeric(get_option('page_on_front')) ) { 1480 1480 //create query for Root /comment-page-xx 1481 1481 $rootcommentmatch = $match . $commentregex; 1482 1482 $rootcommentquery = $index . '?' . $query . '&page_id=' . get_option('page_on_front') . '&cpage=' . $this->preg_index($num_toks + 1); … … 1506 1506 //only on pages with comments add ../comment-page-xx/ 1507 1507 if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) { 1508 1508 $rewrite = array_merge($rewrite, array($commentmatch => $commentquery)); 1509 } elseif ( EP_ROOT & $ep_mask && get_option('page_on_front') ) {1509 } elseif ( EP_ROOT & $ep_mask && get_option('page_on_front') && is_numeric(get_option('page_on_front')) ) { 1510 1510 $rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery)); 1511 1511 } 1512 1512 //do endpoints -
wp-includes/template.php
286 286 */ 287 287 function get_front_page_template() { 288 288 $templates = array('front-page.php'); 289 289 if( get_option( "show_on_front" ) == "page" && ! is_numeric( get_option( "page_on_front" ) ) ){ 290 if( locate_template( get_option( "page_on_front" ) ) != '' ) { 291 $templates = array( get_option("page_on_front") ); 292 } 293 } 290 294 return get_query_template( 'front_page', $templates ); 291 295 } 292 296 -
wp-includes/theme.php
1952 1952 remove_action( 'after_switch_theme', '_wp_sidebars_changed' ); 1953 1953 update_option( 'theme_switched_via_customizer', false ); 1954 1954 } 1955 $value_frontpage = get_theme_support( 'custom-frontpage' ) ; 1956 $template_frontpage = isset( $value_frontpage[0] ) ? $value_frontpage[0] : ''; 1955 1957 1958 if( ! empty ( $template_frontpage ) ){ 1959 update_option( 'old_page_on_front' , get_option( 'page_on_front' ) ); 1960 update_option( 'old_show_on_front' , get_option( 'show_on_front' ) ); 1961 update_option( 'page_on_front' , $template_frontpage . '.php' ); 1962 update_option( 'show_on_front' , 'page' ); 1963 }else{ 1964 $old_frontpage = get_option( 'old_page_on_front' ); 1965 $old_show_on_front = get_option( 'old_show_on_front' ); 1966 if( $old_frontpage !== false && $old_show_on_front !== false ){ 1967 update_option( 'page_on_front',$old_frontpage ); 1968 update_option( 'show_on_front',$old_show_on_front ); 1969 } 1970 } 1956 1971 if ( $old_theme->exists() ) { 1957 1972 /** 1958 1973 * Fires on the first WP load after a theme switch if the old theme still exists.