Make WordPress Core

Ticket #16379: 16379.12-refresh.diff

File 16379.12-refresh.diff, 24.2 KB (added by DrewAPicture, 12 years ago)
  • wp-includes/default-filters.php

     
    258258add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment'                           );
    259259add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment'                           );
    260260add_action( 'welcome_panel',              'wp_welcome_panel'                               );
     261add_action( 'page_for_posts_message',     'display_page_for_posts_message'                 );
    261262
    262263// Navigation menu actions
    263264add_action( 'delete_post',                '_wp_delete_post_menu_item'         );
  • wp-admin/includes/post.php

     
    13301330}
    13311331
    13321332/**
     1333 * Checks if page on front is set, else shows latests posts
     1334 *
     1335 * @since 3.5.0
     1336 * @access private
     1337 */
     1338
     1339function _show_on_front_cant_create_pages () {
     1340       
     1341        // If an existing page is set, keep things as is, rather than reverting to showing posts.
     1342        if ( get_option( 'page_on_front' ) ) {
     1343                $show_on_front_value = 'page';
     1344        } else {
     1345                $show_on_front_value = 'posts';
     1346                update_option( 'page_on_front', 0 );
     1347                update_option( 'page_for_posts', 0 );
     1348        }
     1349        add_settings_error( 'page_on_front', 'create_pages', __( 'You are not allowed to create pages on this site.' ) );
     1350        return $show_on_front_value;
     1351}
     1352
     1353/**
    13331354 * Creates new pages to be set as a front page or a page for posts in Reading Settings.
    13341355 *
    13351356 * @todo Make sure we are doing adequate sanitization on success, and cleanup/reset on failure.
     
    13381359 * @access private
    13391360 */
    13401361function _show_on_front_reading_settings( $show_on_front_value ) {
     1362       
    13411363        // If we're not saving the Reading Settings screen, don't intercept.
    13421364        if ( ! $_POST || ! strpos( wp_get_referer(), 'options-reading.php' ) )
    13431365                return $show_on_front_value;
    1344 
     1366               
     1367        // If 'latest posts' is set, stop here
    13451368        if ( 'posts' == $show_on_front_value ) {
    13461369                update_option( 'page_on_front', 0 );
    13471370                update_option( 'page_for_posts', 0 );
     1371
    13481372                return $show_on_front_value;
    13491373        }
     1374       
     1375        // They didn't select a page at all. Sad face.
     1376        if ( ! $_POST['page_on_front_title'] ) {
     1377                $show_on_front_value = 'posts';
     1378                update_option( 'page_on_front', 0 );
     1379                update_option( 'page_for_posts', 0 );
     1380                add_settings_error( 'page_on_front', 'no_page_selected', __( 'You must select a page to set a static front page.' ) );
     1381                return $show_on_front_value;
     1382        }
     1383       
     1384        // PAGE_ON_FRONT
     1385        $existing_page_on_front = get_page_by_title( stripslashes( $_POST['page_on_front_title'] ) );
    13501386
    1351         // If a new front page was meant to be created, go forth and create it.
    1352         if ( 'new' == $_POST['page_on_front'] ) {
    1353 
     1387        if ( $existing_page_on_front && $existing_page_on_front->ID && 'publish' == $existing_page_on_front->post_status && 'page' == $existing_page_on_front->post_type ) {
     1388               
     1389                // If a page exists with this same title, use it
     1390                update_option( 'page_on_front', (int) $existing_page_on_front->ID );
     1391        } else {
     1392               
    13541393                // If the user can't create pages, revert.
    13551394                if ( ! current_user_can( 'create_posts', 'page' ) ) {
    1356                         // If an existing page is set, keep things as is, rather than reverting to showing posts.
    1357                         if ( get_option( 'page_on_front' ) ) {
    1358                                 $show_on_front_value = 'page';
    1359                         } else {
    1360                                 $show_on_front_value = 'posts';
    1361                                 update_option( 'page_on_front', 0 );
    1362                                 update_option( 'page_for_posts', 0 );
    1363                         }
    1364                         add_settings_error( 'page_on_front', 'create_pages', __( 'You are not allowed to create pages on this site.' ) );
    1365                         return $show_on_front_value;
     1395                        return _show_on_front_cant_create_pages();
    13661396                }
    1367 
    1368                 $existing_page = get_page_by_title( stripslashes( $_POST['page_on_front_title'] ) );
    1369 
    1370                 // If page already exists and it's public, there's no need to create a new page.
    1371                 if ( $existing_page && 'publish' == $existing_page->post_status ) {
    1372                         $page_id = $existing_page->ID;
    1373                 } else {
    1374                         $page_id = wp_insert_post( array(
    1375                                 'post_title' => $_POST['page_on_front_title'],
    1376                                 'post_type' => 'page',
    1377                                 'post_status' => 'publish',
    1378                                 'comment_status' => 'closed',
    1379                                 'ping_status' => 'closed',
    1380                                 // @todo Create some sort of a 'context' in postmeta so we know we created a page through these means.
    1381                                 //       Consider then showing that context in the list table as a good-first-step.
    1382                         ) );
    1383                 }
    1384 
     1397               
     1398                // Create new page
     1399                $page_id = wp_insert_post( array(
     1400                        'post_title' => wp_strip_all_tags( $_POST['page_on_front_title'] ),
     1401                        'post_type' => 'page',
     1402                        'post_status' => 'publish',
     1403                        'comment_status' => 'closed',
     1404                        'ping_status' => 'closed'
     1405                        // @todo Create some sort of a 'context' in postmeta so we know we created a page through these means.
     1406                        //       Consider then showing that context in the list table as a good-first-step.
     1407                ) );
     1408               
    13851409                if ( $page_id ) {
    13861410                        update_option( 'page_on_front', $page_id );
    1387                 // If we can't save it, revert.
    1388                 } elseif ( get_option( 'page_on_front' ) ) {
    1389                         // If an existing page is set, keep things as is, rather than reverting to showing posts.
    1390                         $show_on_front_value = 'page';
    13911411                } else {
    1392                         $show_on_front_value = 'posts';
    1393                         update_option( 'page_on_front', 0 );
    1394                         update_option( 'page_for_posts', 0 );
    1395                         return $show_on_front_value;
     1412               
     1413                        // If we can't save it, revert.
     1414                        return _show_on_front_cant_create_pages();
    13961415                }
    1397         } elseif ( $_POST['page_on_front'] ) {
    1398                 update_option( 'page_on_front', $_POST['page_on_front'] );
    1399         } else {
    1400                 // They didn't select a page at all. Sad face.
    1401                 $show_on_front_value = 'posts';
    1402                 update_option( 'page_on_front', 0 );
    1403                 update_option( 'page_for_posts', 0 );
    1404                 add_settings_error( 'page_on_front', 'no_page_selected', __( 'You must select a page to set a static front page.' ) );
    1405                 return $show_on_front_value;
    14061416        }
    1407 
    1408         // If a page for posts was meant to be specified, update/create it.
    1409         if ( ! isset( $_POST['page_for_posts'] ) ) {
    1410                 update_option( 'page_for_posts', 0 );
     1417       
     1418        // PAGE_FOR_POSTS
     1419        if ( ! isset( $_POST['page_for_posts_name'] ) ) {
    14111420                return $show_on_front_value;
    14121421        }
    1413 
    1414         $page_for_posts = (int) $_POST['page_for_posts'];
    1415 
    1416         if ( ! $page_for_posts || ! $page = get_post( $page_for_posts, ARRAY_A ) ) {
    1417                 update_option( 'page_for_posts', 0 );
    1418                 return $show_on_front_value;
     1422       
     1423        $existing_page_for_posts = get_page_by_path( stripslashes( $_POST['page_for_posts_name'] ) );
     1424       
     1425        if ( $existing_page_for_posts && $existing_page_for_posts->ID && 'publish' == $existing_page_for_posts->post_status && 'page' == $existing_page_for_posts->post_type ) {
     1426               
     1427                // If a page exists with this same name, use it
     1428                update_option( 'page_for_posts', (int) $existing_page_for_posts->ID );
     1429        } else {
     1430               
     1431                // If the user can't create pages, revert.
     1432                if ( ! current_user_can( 'create_posts', 'page' ) ) {
     1433                        return _show_on_front_cant_create_pages();
     1434                }
     1435               
     1436                // Create new page
     1437                $page_id = wp_insert_post( array(
     1438                        'post_title' => 'Latest posts',
     1439                        'post_name' => wp_strip_all_tags( $_POST['page_for_posts_name'] ),
     1440                        'post_type' => 'page',
     1441                        'post_status' => 'publish',
     1442                        'comment_status' => 'closed',
     1443                        'ping_status' => 'closed'
     1444                ) );
     1445               
     1446                if ( $page_id ) {
     1447                        update_option( 'page_for_posts', $page_id );
     1448                } else {
     1449               
     1450                        // If we can't save it, revert.
     1451                        return _show_on_front_cant_create_pages();
     1452                }
    14191453        }
    14201454
    1421         if ( 'page' != $page['post_type'] || ! current_user_can( 'edit_post', $page_for_posts ) ) {
    1422                 update_option( 'page_for_posts', 0 );
    1423                 return $show_on_front_value;
    1424         }
    1425 
    1426         if ( 'publish' != $page['post_status'] && ! current_user_can( 'publish_post', $page_for_posts ) ) {
    1427                 update_option( 'page_for_posts', 0 );
    1428                 return $show_on_front_value;
    1429         }
    1430 
    1431         $args = add_magic_quotes( $page );
    1432         $args['post_title']  = $_POST['page_for_posts_title'];
    1433         $args['post_name']   = $_POST['post_name'];
    1434         $args['post_status'] = 'publish';
    1435         if ( 'auto-draft' == $page['post_status'] ) {
    1436                 $args['comment_status'] = 'closed';
    1437                 $args['ping_status'] = 'closed';
    1438         }
    1439 
    1440         $page_id = wp_insert_post( $args );
    1441         update_option( 'page_for_posts', $page_id );
    1442 
    14431455        return $show_on_front_value;
    14441456}
    1445 add_filter( 'sanitize_option_show_on_front', '_show_on_front_reading_settings' );
     1457add_filter( 'sanitize_option_show_on_front', '_show_on_front_reading_settings' );
     1458 No newline at end of file
  • wp-admin/edit-form-advanced.php

     
    306306wp_nonce_field( 'autosave', 'autosavenonce', false );
    307307wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
    308308wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
    309 ?>
    310309
     310do_action( 'page_for_posts_message' );
     311
     312function display_page_for_posts_message () {
     313        global $post;
     314       
     315        if ( $post->ID == get_option( 'page_for_posts' ) ) { ?>
     316                <div class="updated message">
     317                        <p><?php echo sprintf( __( 'This page is set to display your <a href="%s">latest posts</a>. As a result, the main content for this page (as seen in the editor below) will not be displayed. Visit your <a href="%s">reading settings</a> to change the \'front page displays\' option.' ), 'options-reading.php', 'options-reading.php' ); ?></p>
     318                </div>
     319<?php
     320        }
     321} ?>
     322
    311323<div id="poststuff">
    312324
    313325<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
  • wp-admin/css/ie.css

     
    601601
    602602* html #adminmenu div.wp-menu-image {
    603603        height: 29px;
    604 }
     604}
     605 No newline at end of file
  • wp-admin/css/wp-admin.css

     
    44314431        margin-top: 12px;
    44324432}
    44334433
    4434 .form-table input.tog {
    4435         margin-top: 2px;
    4436         margin-right: 2px;
    4437         float: left;
    4438 }
    4439 
    44404434.form-table td p {
    44414435        margin-top: 4px;
    44424436}
     
    51345128        margin: -3px 3px;
    51355129}
    51365130
    5137 .js.options-reading-php .if-page-on-front,
    5138 .js.options-reading-php .if-page-for-posts,
    5139 .options-reading-php .if-new-front-page {
     5131#front-static-pages .pfp-wrapper {
     5132        display: inline-block;
     5133        position: relative;
     5134}
     5135
     5136#front-static-pages .pfp-wrapper .description {
     5137        white-space: nowrap;
     5138}
     5139
     5140#front-static-pages .pfp-slash {
     5141        left: 6px;
     5142        position: absolute;
     5143        top: 1px;
     5144}
     5145
     5146#page_for_posts_name {
     5147        margin: 0;
     5148        padding-left: 8px;
     5149        width: 170px;
     5150}
     5151
     5152#page_on_front_title {
     5153        margin: 0;
     5154        width: 170px;
     5155}
     5156
     5157#front-static-pages .page-options {
    51405158        display: none;
     5159        margin-top: 8px;
    51415160}
    5142 .options-reading-php .page-on-front .if-page-on-front,
    5143 .options-reading-php .page-for-posts .if-page-for-posts {
     5161
     5162.page-options .sample-url {
     5163        color: #888;
     5164        font-size: 11px;
     5165}
     5166
     5167.static-front-page #front-static-pages .page-options {
    51445168        display: block;
    51455169}
    5146 .options-reading-php .new-front-page .if-new-front-page {
    5147         display: inline;
    5148 }
    51495170
    51505171/*------------------------------------------------------------------------------
    51515172  21.0 - Admin Footer
  • wp-admin/options-reading.php

     
    1616$parent_file = 'options-general.php';
    1717
    1818wp_enqueue_script( 'sample-permalink' );
     19wp_enqueue_script( 'jquery-ui-core' );
     20wp_enqueue_script( 'jquery-ui-autocomplete' );
    1921
    2022/**
    2123 * Display JavaScript on the page.
     
    2325 * @since 3.5.0
    2426 */
    2527function options_reading_add_js() {
     28
     29$all_pages = get_pages();
     30
     31// Populate autocomplete options
     32$page_titles_json = $page_names_json = array();
     33
     34foreach ( $all_pages as $page ) {
     35        array_push( $page_titles_json, array(
     36                'id' => $page->ID,
     37                'label' => $page->post_title,
     38                'post_name' => $page->post_name
     39        ) );
     40       
     41        array_push( $page_names_json, array(
     42                'id' => $page->ID,
     43                'label' => $page->post_name,
     44                'post_title' => $page->post_title
     45        ) );
     46}
    2647?>
    2748<script>
    28 jQuery(document).ready( function($) {
    29         var section = $('#front-static-pages');
    30         $('#show_on_front').change( function() {
    31                 var checked = $(this).prop('checked');
    32                 section.toggleClass('page-on-front', checked);
    33                 if ( checked )
    34                         $('#page_for_posts').prop('checked', true).change();
    35                 else
    36                         section.removeClass('page-for-posts');
    37         });
    38         $('#page_for_posts').change( function() {
    39                 section.toggleClass('page-for-posts', $(this).prop('checked'));
    40         });
    41         $('#page_on_front').change( function() {
    42                 section.toggleClass('new-front-page', 'new' === $(this).val());
    43         });
    44 });
     49    jQuery( function( $ ) {
     50                var pageTitles = <?php echo json_encode( $page_titles_json ); ?>,
     51                        pageNames = <?php echo json_encode( $page_names_json ); ?>;
     52                       
     53                $( document ).ready( function () {
     54                        $( '.tog' ).change( function () {
     55                                if ( 'page' === $( this ).val() ) {
     56                                        $( '.form-table' ).addClass( 'static-front-page' );
     57                                } else {
     58                                        $( '.form-table' ).removeClass( 'static-front-page' );
     59                                }
     60                        });
     61                        $( '#page_on_front_title' ).keyup( function () {
     62                               
     63                                // Hide edit link
     64                                $( this ).parent().find( '.description' ).hide();
     65                        });
     66                        $( '#page_for_posts_name' ).keyup( function () {
     67                                thisVal = $( this ).val();
     68                               
     69                                // Update example URL
     70                                $( '.page_for_posts_url' ).html( thisVal );
     71                               
     72                                // Hide edit link
     73                                $( this ).parent().find( '.description' ).hide();
     74                        });
     75                });
     76                       
     77                addAutocomplete( 'page_on_front_title', pageTitles, 'page_on_front' );
     78                addAutocomplete( 'page_for_posts_name', pageNames, 'page_for_posts' );
     79               
     80                function addAutocomplete ( textbox, source, hidden ) {
     81                $( '#' + textbox ).autocomplete( {
     82                                source: source,
     83                                minLength: 1,
     84                                delay: 0,
     85                                autoFocus: true,
     86                                response: function( event, ui ) {
     87                                       
     88                                        // If this value doesn't exist in dropdown, show 'add new page' option at top
     89                                        if ( ! isNewPage( source, $( this ).val() ) ) {
     90                                                ui.content.unshift( {
     91                                                        'id': 0,
     92                                                        'label': '-- Add new page --',
     93                                                        'post_name': null
     94                                                } );
     95                                        }
     96                                },
     97                                select: function( event, ui ) {
     98                                        var thisVal = $( this ).val();
     99                                       
     100                                        // Update example URL on click
     101                                        if ( 'page_for_posts_name' === textbox )
     102                                                $( '.page_for_posts_url' ).html( ui.item.label );
     103                                       
     104                                        if ( 0 === ui.item.id ){
     105                                                setTimeout( function () {
     106                                                        $( '#' + textbox ).val( thisVal ).focus();
     107                                                }, 30);
     108                                        }
     109                                       
     110                                        if ( ui.item.id ) {
     111                                                var thisId = ui.item.id;
     112                                        } else {
     113                                                var thisId = 'new';
     114                                        }
     115                                        $( '#' + hidden ).val( thisId );
     116                                }
     117                        } );
     118            }
     119            function isNewPage ( source, label ) {
     120
     121                        for ( i=0; i<source.length; i++ ) {
     122                                if ( label === source[i].label )
     123                                        return true;
     124                        }
     125
     126                        return false;
     127                }
     128    } );
    45129</script>
    46130<?php
    47131}
     
    90174<?php
    91175settings_fields( 'reading' );
    92176wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
    93 ?>
    94 <table class="form-table">
    95 <?php
    96 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) )
    97         add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
    98177
    99178$classes = '';
    100179if ( 'page' == get_option( 'show_on_front' ) ) {
    101         if ( ! get_pages() || ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {
     180        $classes = 'static-front-page';
     181        /*if ( ! get_pages() || ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {
    102182                update_option( 'show_on_front', 'posts' );
    103183        } else {
    104                 $classes = 'page-on-front';
    105                 if ( get_option( 'page_for_posts' ) )
    106                         $classes .= ' page-for-posts';
    107         }
     184                $classes = 'static-front-page';
     185        }*/
    108186}
     187?>
     188<table class="form-table <?php echo $classes; ?>">
     189<?php
     190if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) )
     191        add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
    109192
    110 $all_pages = get_pages();
    111 $new_front_page_only = ! get_option( 'page_on_front' ) && ( ! $all_pages || ( 1 == count( $all_pages ) && __( 'sample-page' ) == $all_pages[0]->post_name ) );
     193$page_on_front = get_post( get_option( 'page_on_front' ) );
     194$page_for_posts = get_post( get_option( 'page_for_posts' ) );
    112195
    113 if ( current_user_can( 'create_posts', 'page' ) && ! ( get_option( 'page_for_posts' ) && $page_for_posts = get_post( get_option( 'page_for_posts' ) ) ) ) {
    114         $title = _x( 'Blog', 'default page for posts title' );
    115         // @todo What if the found page is post_type = attachment or post_status != publish?
    116         //       We could go ahead and create a new one, but we would not be able to take over
    117         //       the slug from another page. (We could for an attachment.)
    118         //       We must also check that the user can edit this page and publish a page.
    119         //       Otherwise, we must assume they cannot create pages (throughout), and thus
    120         //       should fall back to the dropdown.
    121         $page_for_posts = get_page_by_path( sanitize_title( $title ) );
    122         if ( ! $page_for_posts || $page_for_posts->ID == get_option( 'page_on_front' ) ) {
    123                 $page_for_posts = get_default_post_to_edit( 'page', true );
    124                 $page_for_posts->post_title = $title;
    125                 $page_for_posts->post_name = sanitize_title( $title );
    126         }
     196// Setup empty vars
     197$page_on_front_helper_text = $page_for_posts_helper_text = '';
     198
     199if ( ! isset( $page_on_front ) ) {
     200        // Default for page_on_front
     201        $page_on_front->post_title = 'Home';
     202} else {
     203        // Show link to edit page if it exists
     204        $page_on_front_helper_text = sprintf( __( '<span class="description"> (<a href="%s">Edit</a>)</span>' ), 'post.php?post=' . $page_on_front->ID . '&action=edit' );
    127205}
    128206
    129 if ( ! $new_front_page_only || current_user_can( 'create_posts', 'page' ) ) : ?>
    130 <tr valign="top">
    131 <th scope="row"><?php _e( 'Enable a static front page' ); ?></th>
    132 <td id="front-static-pages" class="<?php echo $classes; ?>">
    133         <fieldset><legend class="screen-reader-text"><span><?php _e( 'Enable a static front page' ); ?></span></legend>
    134         <p><label for="show_on_front">
    135                 <input id="show_on_front" name="show_on_front" type="checkbox" value="page" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
    136                 <?php printf( __( 'Show a <a href="%s">page</a> instead of your latest posts' ), 'edit.php?post_type=page' ); ?>
    137         </label></p>
    138         <p class="if-page-on-front sub-option">
    139         <?php if ( $new_front_page_only ) : // If no pages, or only sample page, only allow a new page to be added ?>
    140                 <label for="page_on_front_title"><?php _e( 'Add new page titled:' ); ?>
    141         <?php else : ?>
    142                 <label for="page_on_front">
    143                         <select name="page_on_front" id="page_on_front">
    144                                 <option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
    145                                 <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
    146                                 <option value="new" id="new-page"><?php _e( '&mdash; Add new page &mdash;' ); ?></option>
    147                                 <?php endif; ?>
    148                                 <?php echo walk_page_dropdown_tree( $all_pages, 0, array( 'selected' => get_option( 'page_on_front' ) ) ); ?>
    149                         </select>
    150                 </label>
    151                 <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
    152                 <label for="page_on_front_title" class="if-new-front-page"><?php _e( 'titled:' ); ?>
    153                 <?php endif; ?>
    154         <?php endif; ?>
    155         <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
    156                         <input name="page_on_front_title" type="text" id="page_on_front_title" value="<?php echo esc_attr_x( 'Home', 'default page on front title' ); ?>" />
    157                 </label>
    158         <?php endif; ?>
    159         </p>
    160         <p class="if-page-on-front"><label for="page_for_posts">
    161                 <input id="page_for_posts" name="page_for_posts" type="checkbox" value="<?php echo $page_for_posts->ID; ?>" <?php checked( (bool) get_option( 'page_for_posts' ) ); ?> />
    162                 <?php _e( 'Show latest posts on a separate page' ); ?>
    163         </label></p>
    164         <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
    165         <p class="if-page-for-posts sub-option"><label for="page_for_posts_title"><?php _e( 'Page title:' ); ?>
    166                 <input name="page_for_posts_title" type="text" id="page_for_posts_title" value="<?php echo esc_attr( htmlspecialchars( $page_for_posts->post_title ) ); ?>" />
    167         </label></p>
    168         <p class="if-page-for-posts sub-option" id="edit-slug-box">
    169                 <?php echo get_sample_permalink_html( $page_for_posts->ID, $page_for_posts->post_title, $page_for_posts->post_name ); ?>
    170         </p>
    171         <input name="post_name" type="hidden" id="post_name" value="<?php echo esc_attr( apply_filters( 'editable_slug', $page_for_posts->post_name ) ); ?>" />
    172         <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
    173         <div class="error inline"><p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'These pages should not be the same!' ); ?></p></div>
    174         <?php endif; ?>
    175         </fieldset>
    176         <?php else : // cannot create pages, so fall back to a selector of existing pages ?>
    177         <p class="if-page-for-posts sub-option"><label for="page_for_posts">
    178                 <?php wp_dropdown_pages( array(
    179                         'name' => 'page_for_posts', 'show_option_none' => __( '&mdash; Select &mdash;' ),
    180                         'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' )
    181                 ) ); ?>
    182         <?php endif; // create pages ?>
    183 </td>
     207if ( ! isset( $page_for_posts ) ) {
     208        // Default for page_for_posts
     209        $page_for_posts->post_name = 'blog';
     210} else {
     211        // Show link to edit page if it exists
     212        $page_for_posts_helper_text = sprintf( __( '<span class="description"> (<a href="%s">Edit</a>)</span>' ), 'post.php?post=' . $page_for_posts->ID . '&action=edit' );
     213}
     214?>
     215
     216<tr>
     217        <th scope="row"><?php _e( 'Front page displays' ); ?></th>
     218        <td id="front-static-pages" class="<?php echo $classes; ?>">
     219                <fieldset>
     220                        <legend class="screen-reader-text">
     221                                <span><?php _e( 'Front page displays' ); ?></span>
     222                        </legend>
     223                        <label>
     224                                <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
     225                                <span class="radio-label"><?php _e( 'Your latest posts' ); ?></span>
     226                        </label>
     227                        <br />
     228                        <label>
     229                                <input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
     230                                <span class="radio-label"><?php _e( 'A static page' ); ?></span>
     231                        </label>
     232                        <div class="page-options">
     233                                <label>
     234                                        <?php _e( 'Enter a title for your static front page.' ); ?><br />
     235                                        <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
     236                                        <input name="page_on_front_title" type="text" id="page_on_front_title" value="<?php echo esc_attr_x( $page_on_front->post_title, 'default page on front title' ); ?>" />
     237                                        <?php echo $page_on_front_helper_text; ?>
     238                                        <?php else : // cannot create pages, so fall back to a selector of existing pages ?>
     239                                        <?php wp_dropdown_pages( array(
     240                                                'name' => 'page_on_front', 'show_option_none' => __( '&mdash; Select &mdash;' ),
     241                                                'option_none_value' => '0', 'selected' => get_option( 'page_on_front' )
     242                                        ) ); ?>
     243                                        <?php endif; // cannot create pages ?>
     244                                </label>
     245                        </div>
     246                        <div class="page-options">
     247                                <label>
     248                                        <?php _e( 'Choose a URL for your latests posts.' ); ?><br />
     249                                        <div class="pfp-wrapper">
     250                                                <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
     251                                                <div class="pfp-slash">/</div>
     252                                                <input name="page_for_posts_name" type="text" id="page_for_posts_name" value="<?php echo esc_attr_x( $page_for_posts->post_name, 'default page for posts name' ); ?>" />
     253                                                <?php echo $page_for_posts_helper_text; ?>
     254                                                <br />
     255                                                <span class="sample-url"><?php echo get_site_url(); ?>/<strong class="page_for_posts_url"><?php echo $page_for_posts->post_name; ?></strong></span>
     256                                                <?php else : // cannot create pages, so fall back to a selector of existing pages ?>
     257                                                <?php wp_dropdown_pages( array(
     258                                                        'name' => 'page_for_posts', 'show_option_none' => __( '&mdash; Select &mdash;' ),
     259                                                        'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' )
     260                                                ) ); ?>
     261                                                <?php endif; // cannot create pages ?>
     262                                        </div>
     263                                </label>
     264                        </div>
     265                </fieldset>
     266        </td>
    184267</tr>
    185 <?php endif; // if no pages to choose from and can't create pages ?>
    186268
    187269<tr valign="top">
    188270<th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>