| 1 | Index: wp-includes/script-loader.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/script-loader.php (revision 22121) |
|---|
| 4 | +++ wp-includes/script-loader.php (working copy) |
|---|
| 5 | @@ -369,7 +369,9 @@ |
|---|
| 6 | |
|---|
| 7 | $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 ); |
|---|
| 8 | |
|---|
| 9 | - $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), false, 1 ); |
|---|
| 10 | + $scripts->add( 'sample-permalink', "wp-admin/js/sample-permalink.js", array(), false, 1 ); |
|---|
| 11 | + |
|---|
| 12 | + $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox', 'sample-permalink' ), false, 1 ); |
|---|
| 13 | did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array( |
|---|
| 14 | 'ok' => __('OK'), |
|---|
| 15 | 'cancel' => __('Cancel'), |
|---|
| 16 | Index: wp-admin/includes/post.php |
|---|
| 17 | =================================================================== |
|---|
| 18 | --- wp-admin/includes/post.php (revision 22121) |
|---|
| 19 | +++ wp-admin/includes/post.php (working copy) |
|---|
| 20 | @@ -1059,9 +1059,15 @@ |
|---|
| 21 | * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor. |
|---|
| 22 | */ |
|---|
| 23 | function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
|---|
| 24 | - global $wpdb; |
|---|
| 25 | + global $wpdb, $current_screen; |
|---|
| 26 | + |
|---|
| 27 | $post = get_post($id); |
|---|
| 28 | |
|---|
| 29 | + if ( isset( $current_screen ) ) |
|---|
| 30 | + $context = $current_screen->id; |
|---|
| 31 | + else |
|---|
| 32 | + $context = isset( $_POST['context'] ) ? $_POST['context'] : ''; |
|---|
| 33 | + |
|---|
| 34 | list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
|---|
| 35 | |
|---|
| 36 | if ( 'publish' == get_post_status( $post ) ) { |
|---|
| 37 | @@ -1072,11 +1078,12 @@ |
|---|
| 38 | $title = __('Temporary permalink. Click to edit this part.'); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | - if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { |
|---|
| 42 | - $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n"; |
|---|
| 43 | + if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { |
|---|
| 44 | + $return = ( 'options-reading' == $context ) ? __( 'Located at' ) . "\n" : '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|---|
| 45 | + $return .= '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n"; |
|---|
| 46 | if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) |
|---|
| 47 | $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; |
|---|
| 48 | - if ( isset($view_post) ) |
|---|
| 49 | + if ( isset( $view_post ) && 'options-reading' == $context ) |
|---|
| 50 | $return .= "<span id='view-post-btn'><a href='$permalink' class='button button-small'>$view_post</a></span>\n"; |
|---|
| 51 | |
|---|
| 52 | $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); |
|---|
| 53 | @@ -1099,14 +1106,14 @@ |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>'; |
|---|
| 57 | - $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); |
|---|
| 58 | - $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink); |
|---|
| 59 | - $return = '<strong>' . __('Permalink:') . "</strong>\n"; |
|---|
| 60 | + $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, $permalink ); |
|---|
| 61 | + $view_link = str_replace( array( '%pagename%', '%postname%' ), $post_name, $permalink ); |
|---|
| 62 | + $return = ( 'options-reading' == $context ) ? __( 'Located at' ) . "\n" : '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|---|
| 63 | $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n"; |
|---|
| 64 | $return .= '‎'; // Fix bi-directional text display defect in RTL languages. |
|---|
| 65 | $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n"; |
|---|
| 66 | $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; |
|---|
| 67 | - if ( isset($view_post) ) |
|---|
| 68 | + if ( isset( $view_post ) && 'options-reading' != $context ) |
|---|
| 69 | $return .= "<span id='view-post-btn'><a href='$view_link' class='button button-small'>$view_post</a></span>\n"; |
|---|
| 70 | |
|---|
| 71 | $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); |
|---|
| 72 | @@ -1322,3 +1329,50 @@ |
|---|
| 73 | |
|---|
| 74 | return $url; |
|---|
| 75 | } |
|---|
| 76 | + |
|---|
| 77 | +/** |
|---|
| 78 | + * Creates new pages to be set as a front page or a page for posts in Reading Settings. |
|---|
| 79 | + * |
|---|
| 80 | + * @since 3.5.0 |
|---|
| 81 | + * @access private |
|---|
| 82 | + */ |
|---|
| 83 | +function _create_pages_for_reading_settings() { |
|---|
| 84 | + if ( ! isset( $_POST['show_on_front'] ) ) |
|---|
| 85 | + return; |
|---|
| 86 | + |
|---|
| 87 | + $post_type = get_post_type_object( 'page' ); |
|---|
| 88 | + if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
|---|
| 89 | + wp_die( __( 'You are not allowed to create pages on this site.' ) ); |
|---|
| 90 | + |
|---|
| 91 | + if ( isset( $_POST['page_on_front'] ) && 'new' == $_POST['page_on_front'] ) { |
|---|
| 92 | + |
|---|
| 93 | + $title = esc_html( stripslashes( $_POST['page_on_front_title'] ) ); |
|---|
| 94 | + $existing_page = get_page_by_title( $title ); |
|---|
| 95 | + |
|---|
| 96 | + // If page already exists and it's public, there's no need to create a new page |
|---|
| 97 | + if ( $existing_page && 'publish' == $existing_page->post_status ) { |
|---|
| 98 | + $page_id = $existing_page->ID; |
|---|
| 99 | + } else { |
|---|
| 100 | + $page_id = wp_insert_post( array( |
|---|
| 101 | + 'post_title' => $title, |
|---|
| 102 | + 'post_type' => 'page', |
|---|
| 103 | + 'post_status' => 'publish' |
|---|
| 104 | + ) ); |
|---|
| 105 | + } |
|---|
| 106 | + |
|---|
| 107 | + if ( $page_id && ! is_wp_error( $page_id ) ) |
|---|
| 108 | + $_POST['page_on_front'] = $page_id; |
|---|
| 109 | + } |
|---|
| 110 | + |
|---|
| 111 | + if ( isset( $_POST['page_for_posts'] ) ) { |
|---|
| 112 | + if ( ! $page = get_post( (int) $_POST['page_for_posts'] ) ) |
|---|
| 113 | + return; |
|---|
| 114 | + |
|---|
| 115 | + $page->post_title = esc_html( stripslashes( $_POST['page_for_posts_title'] ) ); |
|---|
| 116 | + $page->post_name = esc_html( stripslashes( $_POST['post_name'] ) ); |
|---|
| 117 | + $page->post_status = 'publish'; |
|---|
| 118 | + |
|---|
| 119 | + wp_update_post( $page ); |
|---|
| 120 | + } |
|---|
| 121 | +} |
|---|
| 122 | +add_action( 'admin_init', '_create_pages_for_reading_settings' ); |
|---|
| 123 | Index: wp-admin/js/sample-permalink.js |
|---|
| 124 | =================================================================== |
|---|
| 125 | --- wp-admin/js/sample-permalink.js (revision 0) |
|---|
| 126 | +++ wp-admin/js/sample-permalink.js (revision 0) |
|---|
| 127 | @@ -0,0 +1,75 @@ |
|---|
| 128 | +var editPermalink, makeSlugeditClickable; |
|---|
| 129 | + |
|---|
| 130 | +(function($){ |
|---|
| 131 | + if ( ! $('#edit-slug-box').length ) |
|---|
| 132 | + return; |
|---|
| 133 | + editPermalink = function(post_id) { |
|---|
| 134 | + var i, c = 0, |
|---|
| 135 | + e = $('#editable-post-name'), |
|---|
| 136 | + revert_e = e.html(), |
|---|
| 137 | + real_slug = $('#post_name'), |
|---|
| 138 | + evert_slug = real_slug.val(), |
|---|
| 139 | + b = $('#edit-slug-buttons'), |
|---|
| 140 | + revert_b = b.html(), |
|---|
| 141 | + full = $('#editable-post-name-full').html(); |
|---|
| 142 | + |
|---|
| 143 | + $('#view-post-btn').hide(); |
|---|
| 144 | + b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); |
|---|
| 145 | + b.children('.save').click(function() { |
|---|
| 146 | + var new_slug = e.children('input').val(); |
|---|
| 147 | + if ( new_slug == $('#editable-post-name-full').text() ) { |
|---|
| 148 | + return $('.cancel', '#edit-slug-buttons').click(); |
|---|
| 149 | + } |
|---|
| 150 | + $.post(ajaxurl, { |
|---|
| 151 | + action: 'sample-permalink', |
|---|
| 152 | + post_id: post_id, |
|---|
| 153 | + new_slug: new_slug, |
|---|
| 154 | + new_title: $('#title').val(), |
|---|
| 155 | + context: pagenow, |
|---|
| 156 | + samplepermalinknonce: $('#samplepermalinknonce').val() |
|---|
| 157 | + }, function(data) { |
|---|
| 158 | + $('#edit-slug-box').html(data); |
|---|
| 159 | + b.html(revert_b); |
|---|
| 160 | + real_slug.val(new_slug); |
|---|
| 161 | + makeSlugeditClickable(); |
|---|
| 162 | + $('#view-post-btn').show(); |
|---|
| 163 | + }); |
|---|
| 164 | + return false; |
|---|
| 165 | + }); |
|---|
| 166 | + |
|---|
| 167 | + $('.cancel', '#edit-slug-buttons').click(function() { |
|---|
| 168 | + $('#view-post-btn').show(); |
|---|
| 169 | + e.html(revert_e); |
|---|
| 170 | + b.html(revert_b); |
|---|
| 171 | + real_slug.val(revert_slug); |
|---|
| 172 | + return false; |
|---|
| 173 | + }); |
|---|
| 174 | + |
|---|
| 175 | + for ( i = 0; i < full.length; ++i ) { |
|---|
| 176 | + if ( '%' == full.charAt(i) ) |
|---|
| 177 | + c++; |
|---|
| 178 | + } |
|---|
| 179 | + |
|---|
| 180 | + slug_value = ( c > full.length / 4 ) ? '' : full; |
|---|
| 181 | + e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){ |
|---|
| 182 | + var key = e.keyCode || 0; |
|---|
| 183 | + // on enter, just save the new slug, don't save the post |
|---|
| 184 | + if ( 13 == key ) { |
|---|
| 185 | + b.children('.save').click(); |
|---|
| 186 | + return false; |
|---|
| 187 | + } |
|---|
| 188 | + if ( 27 == key ) { |
|---|
| 189 | + b.children('.cancel').click(); |
|---|
| 190 | + return false; |
|---|
| 191 | + } |
|---|
| 192 | + real_slug.val(this.value); |
|---|
| 193 | + }).focus(); |
|---|
| 194 | + } |
|---|
| 195 | + |
|---|
| 196 | + makeSlugeditClickable = function() { |
|---|
| 197 | + $('#editable-post-name').click(function() { |
|---|
| 198 | + $('#edit-slug-buttons').children('.edit-slug').click(); |
|---|
| 199 | + }); |
|---|
| 200 | + } |
|---|
| 201 | + makeSlugeditClickable(); |
|---|
| 202 | +})(jQuery); |
|---|
| 203 | \ No newline at end of file |
|---|
| 204 | Index: wp-admin/js/post.js |
|---|
| 205 | =================================================================== |
|---|
| 206 | --- wp-admin/js/post.js (revision 22121) |
|---|
| 207 | +++ wp-admin/js/post.js (working copy) |
|---|
| 208 | @@ -559,71 +559,6 @@ |
|---|
| 209 | }); |
|---|
| 210 | } // end submitdiv |
|---|
| 211 | |
|---|
| 212 | - // permalink |
|---|
| 213 | - if ( $('#edit-slug-box').length ) { |
|---|
| 214 | - editPermalink = function(post_id) { |
|---|
| 215 | - var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'), revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(), full = $('#editable-post-name-full').html(); |
|---|
| 216 | - |
|---|
| 217 | - $('#view-post-btn').hide(); |
|---|
| 218 | - b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); |
|---|
| 219 | - b.children('.save').click(function() { |
|---|
| 220 | - var new_slug = e.children('input').val(); |
|---|
| 221 | - if ( new_slug == $('#editable-post-name-full').text() ) { |
|---|
| 222 | - return $('.cancel', '#edit-slug-buttons').click(); |
|---|
| 223 | - } |
|---|
| 224 | - $.post(ajaxurl, { |
|---|
| 225 | - action: 'sample-permalink', |
|---|
| 226 | - post_id: post_id, |
|---|
| 227 | - new_slug: new_slug, |
|---|
| 228 | - new_title: $('#title').val(), |
|---|
| 229 | - samplepermalinknonce: $('#samplepermalinknonce').val() |
|---|
| 230 | - }, function(data) { |
|---|
| 231 | - $('#edit-slug-box').html(data); |
|---|
| 232 | - b.html(revert_b); |
|---|
| 233 | - real_slug.val(new_slug); |
|---|
| 234 | - makeSlugeditClickable(); |
|---|
| 235 | - $('#view-post-btn').show(); |
|---|
| 236 | - }); |
|---|
| 237 | - return false; |
|---|
| 238 | - }); |
|---|
| 239 | - |
|---|
| 240 | - $('.cancel', '#edit-slug-buttons').click(function() { |
|---|
| 241 | - $('#view-post-btn').show(); |
|---|
| 242 | - e.html(revert_e); |
|---|
| 243 | - b.html(revert_b); |
|---|
| 244 | - real_slug.val(revert_slug); |
|---|
| 245 | - return false; |
|---|
| 246 | - }); |
|---|
| 247 | - |
|---|
| 248 | - for ( i = 0; i < full.length; ++i ) { |
|---|
| 249 | - if ( '%' == full.charAt(i) ) |
|---|
| 250 | - c++; |
|---|
| 251 | - } |
|---|
| 252 | - |
|---|
| 253 | - slug_value = ( c > full.length / 4 ) ? '' : full; |
|---|
| 254 | - e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){ |
|---|
| 255 | - var key = e.keyCode || 0; |
|---|
| 256 | - // on enter, just save the new slug, don't save the post |
|---|
| 257 | - if ( 13 == key ) { |
|---|
| 258 | - b.children('.save').click(); |
|---|
| 259 | - return false; |
|---|
| 260 | - } |
|---|
| 261 | - if ( 27 == key ) { |
|---|
| 262 | - b.children('.cancel').click(); |
|---|
| 263 | - return false; |
|---|
| 264 | - } |
|---|
| 265 | - real_slug.val(this.value); |
|---|
| 266 | - }).focus(); |
|---|
| 267 | - } |
|---|
| 268 | - |
|---|
| 269 | - makeSlugeditClickable = function() { |
|---|
| 270 | - $('#editable-post-name').click(function() { |
|---|
| 271 | - $('#edit-slug-buttons').children('.edit-slug').click(); |
|---|
| 272 | - }); |
|---|
| 273 | - } |
|---|
| 274 | - makeSlugeditClickable(); |
|---|
| 275 | - } |
|---|
| 276 | - |
|---|
| 277 | // word count |
|---|
| 278 | if ( typeof(wpWordCount) != 'undefined' ) { |
|---|
| 279 | $(document).triggerHandler('wpcountwords', [ co.val() ]); |
|---|
| 280 | Index: wp-admin/css/wp-admin-rtl.css |
|---|
| 281 | =================================================================== |
|---|
| 282 | --- wp-admin/css/wp-admin-rtl.css (revision 22121) |
|---|
| 283 | +++ wp-admin/css/wp-admin-rtl.css (working copy) |
|---|
| 284 | @@ -915,8 +915,7 @@ |
|---|
| 285 | border-bottom-right-radius: 3px; |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | -#front-page-warning, |
|---|
| 289 | -#front-static-pages ul, |
|---|
| 290 | +#front-static-pages .sub-option, |
|---|
| 291 | ul.export-filters, |
|---|
| 292 | .inline-editor ul.cat-checklist ul, |
|---|
| 293 | .categorydiv ul.categorychecklist ul, |
|---|
| 294 | Index: wp-admin/css/wp-admin.css |
|---|
| 295 | =================================================================== |
|---|
| 296 | --- wp-admin/css/wp-admin.css (revision 22121) |
|---|
| 297 | +++ wp-admin/css/wp-admin.css (working copy) |
|---|
| 298 | @@ -2929,6 +2929,10 @@ |
|---|
| 299 | font-size: 11px; |
|---|
| 300 | } |
|---|
| 301 | |
|---|
| 302 | +#front-static-pages #edit-slug-box { |
|---|
| 303 | + padding: 0; |
|---|
| 304 | +} |
|---|
| 305 | + |
|---|
| 306 | #editable-post-name-full { |
|---|
| 307 | display: none; |
|---|
| 308 | } |
|---|
| 309 | @@ -3414,8 +3418,7 @@ |
|---|
| 310 | margin: 0; |
|---|
| 311 | } |
|---|
| 312 | |
|---|
| 313 | -#front-page-warning, |
|---|
| 314 | -#front-static-pages ul, |
|---|
| 315 | +#front-static-pages .sub-option, |
|---|
| 316 | ul.export-filters, |
|---|
| 317 | .inline-editor ul.cat-checklist ul, |
|---|
| 318 | .categorydiv ul.categorychecklist ul, |
|---|
| 319 | @@ -4988,6 +4991,19 @@ |
|---|
| 320 | margin: -3px 3px; |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | +.js.options-reading-php .if-page-on-front, |
|---|
| 324 | +.js.options-reading-php .if-page-for-posts, |
|---|
| 325 | +.options-reading-php .if-new-front-page { |
|---|
| 326 | + display: none; |
|---|
| 327 | +} |
|---|
| 328 | +.options-reading-php .page-on-front .if-page-on-front, |
|---|
| 329 | +.options-reading-php .page-for-posts .if-page-for-posts { |
|---|
| 330 | + display: block; |
|---|
| 331 | +} |
|---|
| 332 | +.options-reading-php .new-front-page .if-new-front-page { |
|---|
| 333 | + display: inline; |
|---|
| 334 | +} |
|---|
| 335 | + |
|---|
| 336 | /*------------------------------------------------------------------------------ |
|---|
| 337 | 21.0 - Admin Footer |
|---|
| 338 | ------------------------------------------------------------------------------*/ |
|---|
| 339 | Index: wp-admin/options-reading.php |
|---|
| 340 | =================================================================== |
|---|
| 341 | --- wp-admin/options-reading.php (revision 22121) |
|---|
| 342 | +++ wp-admin/options-reading.php (working copy) |
|---|
| 343 | @@ -15,6 +15,8 @@ |
|---|
| 344 | $title = __( 'Reading Settings' ); |
|---|
| 345 | $parent_file = 'options-general.php'; |
|---|
| 346 | |
|---|
| 347 | +wp_enqueue_script( 'sample-permalink' ); |
|---|
| 348 | + |
|---|
| 349 | /** |
|---|
| 350 | * Display JavaScript on the page. |
|---|
| 351 | * |
|---|
| 352 | @@ -22,23 +24,23 @@ |
|---|
| 353 | */ |
|---|
| 354 | function options_reading_add_js() { |
|---|
| 355 | ?> |
|---|
| 356 | -<script type="text/javascript"> |
|---|
| 357 | -//<![CDATA[ |
|---|
| 358 | - jQuery(document).ready(function($){ |
|---|
| 359 | - var section = $('#front-static-pages'), |
|---|
| 360 | - staticPage = section.find('input:radio[value="page"]'), |
|---|
| 361 | - selects = section.find('select'), |
|---|
| 362 | - check_disabled = function(){ |
|---|
| 363 | - selects.prop( 'disabled', ! staticPage.prop('checked') ); |
|---|
| 364 | - }; |
|---|
| 365 | - check_disabled(); |
|---|
| 366 | - section.find('input:radio').change(check_disabled); |
|---|
| 367 | +<script> |
|---|
| 368 | +jQuery(document).ready( function($) { |
|---|
| 369 | + var section = $('#front-static-pages'); |
|---|
| 370 | + $('#show_on_front').change( function() { |
|---|
| 371 | + section.toggleClass('page-on-front', $(this).prop('checked')); |
|---|
| 372 | }); |
|---|
| 373 | -//]]> |
|---|
| 374 | + $('#page_for_posts').change( function() { |
|---|
| 375 | + section.toggleClass('page-for-posts', $(this).prop('checked')); |
|---|
| 376 | + }); |
|---|
| 377 | + $('#page_on_front').change( function() { |
|---|
| 378 | + section.toggleClass('new-front-page', 'new' === $(this).val()); |
|---|
| 379 | + }); |
|---|
| 380 | +}); |
|---|
| 381 | </script> |
|---|
| 382 | <?php |
|---|
| 383 | } |
|---|
| 384 | -add_action('admin_head', 'options_reading_add_js'); |
|---|
| 385 | +add_action( 'admin_head', 'options_reading_add_js' ); |
|---|
| 386 | |
|---|
| 387 | /** |
|---|
| 388 | * Render the blog charset setting. |
|---|
| 389 | @@ -82,47 +84,94 @@ |
|---|
| 390 | <form method="post" action="options.php"> |
|---|
| 391 | <?php |
|---|
| 392 | settings_fields( 'reading' ); |
|---|
| 393 | - |
|---|
| 394 | +wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); |
|---|
| 395 | +?> |
|---|
| 396 | +<table class="form-table"> |
|---|
| 397 | +<?php |
|---|
| 398 | if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) |
|---|
| 399 | add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) ); |
|---|
| 400 | -?> |
|---|
| 401 | |
|---|
| 402 | -<?php if ( ! get_pages() ) : ?> |
|---|
| 403 | -<input name="show_on_front" type="hidden" value="posts" /> |
|---|
| 404 | -<table class="form-table"> |
|---|
| 405 | -<?php |
|---|
| 406 | - if ( 'posts' != get_option( 'show_on_front' ) ) : |
|---|
| 407 | +$classes = ''; |
|---|
| 408 | +if ( 'page' == get_option( 'show_on_front' ) ) { |
|---|
| 409 | + if ( ! get_pages() || ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) { |
|---|
| 410 | update_option( 'show_on_front', 'posts' ); |
|---|
| 411 | - endif; |
|---|
| 412 | + } else { |
|---|
| 413 | + $classes = 'page-on-front'; |
|---|
| 414 | + if ( get_option( 'page_for_posts' ) ) |
|---|
| 415 | + $classes .= ' page-for-posts'; |
|---|
| 416 | + } |
|---|
| 417 | +} |
|---|
| 418 | |
|---|
| 419 | -else : |
|---|
| 420 | - if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) |
|---|
| 421 | - update_option( 'show_on_front', 'posts' ); |
|---|
| 422 | -?> |
|---|
| 423 | -<table class="form-table"> |
|---|
| 424 | +$all_pages = get_pages(); |
|---|
| 425 | +$new_front_page_only = ! get_option( 'page_on_front' ) && ( ! $all_pages || ( 1 == count( $all_pages ) && __( 'sample-page' ) == $all_pages[0]->post_name ) ); |
|---|
| 426 | + |
|---|
| 427 | +if ( current_user_can( 'create_posts', 'page' ) && ! ( get_option( 'page_for_posts' ) && $page_for_posts = get_post( get_option( 'page_for_posts' ) ) ) ) { |
|---|
| 428 | + $title = _x( 'Blog', 'default page for posts title' ); |
|---|
| 429 | + if ( ! $page_for_posts = get_page_by_path( sanitize_title( $title ) ) ) { |
|---|
| 430 | + $page_for_posts = get_default_post_to_edit( 'page', true ); |
|---|
| 431 | + $page_for_posts->post_title = $title; |
|---|
| 432 | + $page_for_posts->post_name = sanitize_title( $title ); |
|---|
| 433 | + } |
|---|
| 434 | +} |
|---|
| 435 | + |
|---|
| 436 | +if ( ! $new_front_page_only || current_user_can( 'create_posts', 'page' ) ) : ?> |
|---|
| 437 | <tr valign="top"> |
|---|
| 438 | -<th scope="row"><?php _e( 'Front page displays' ); ?></th> |
|---|
| 439 | -<td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Front page displays' ); ?></span></legend> |
|---|
| 440 | - <p><label> |
|---|
| 441 | - <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> /> |
|---|
| 442 | - <?php _e( 'Your latest posts' ); ?> |
|---|
| 443 | - </label> |
|---|
| 444 | +<th scope="row"><?php _e( 'Enable a static front page' ); ?></th> |
|---|
| 445 | +<td id="front-static-pages" class="<?php echo $classes; ?>"> |
|---|
| 446 | + <fieldset><legend class="screen-reader-text"><span><?php _e( 'Enable a static front page' ); ?></span></legend> |
|---|
| 447 | + <p><label for="show_on_front"> |
|---|
| 448 | + <input id="show_on_front" name="show_on_front" type="checkbox" value="page" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> /> |
|---|
| 449 | + <?php printf( __( 'Show a <a href="%s">page</a> instead of your latest posts' ), 'edit.php?post_type=page' ); ?> |
|---|
| 450 | + </label></p> |
|---|
| 451 | + <p class="if-page-on-front sub-option"> |
|---|
| 452 | + <?php if ( $new_front_page_only ) : // If no pages, or only sample page, only allow a new page to be added ?> |
|---|
| 453 | + <label for="page_on_front_title"><?php _e( 'Add new page titled:' ); ?> |
|---|
| 454 | + <?php else : ?> |
|---|
| 455 | + <label for="page_on_front"> |
|---|
| 456 | + <select name="page_on_front" id="page_on_front"> |
|---|
| 457 | + <option value="0"><?php _e( '— Select —' ); ?></option> |
|---|
| 458 | + <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?> |
|---|
| 459 | + <option value="new" id="new-page"><?php _e( '— Add new page —' ); ?></option> |
|---|
| 460 | + <?php endif; ?> |
|---|
| 461 | + <?php echo walk_page_dropdown_tree( $all_pages, 0, array( 'selected' => get_option( 'page_on_front' ) ) ); ?> |
|---|
| 462 | + </select> |
|---|
| 463 | + </label> |
|---|
| 464 | + <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?> |
|---|
| 465 | + <label for="page_on_front_title" class="if-new-front-page"><?php _e( 'titled:' ); ?> |
|---|
| 466 | + <?php endif; ?> |
|---|
| 467 | + <?php endif; ?> |
|---|
| 468 | + <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?> |
|---|
| 469 | + <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' ); ?>" /> |
|---|
| 470 | + </label> |
|---|
| 471 | + <?php endif; ?> |
|---|
| 472 | </p> |
|---|
| 473 | - <p><label> |
|---|
| 474 | - <input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> /> |
|---|
| 475 | - <?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?> |
|---|
| 476 | - </label> |
|---|
| 477 | + <p class="if-page-on-front"><label for="page_for_posts"> |
|---|
| 478 | + <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' ) ); ?> /> |
|---|
| 479 | + <?php _e( 'Show latest posts on a separate page' ); ?> |
|---|
| 480 | + </label></p> |
|---|
| 481 | + <?php if ( current_user_can( 'create_posts', 'page' ) ) : ?> |
|---|
| 482 | + <p class="if-page-for-posts sub-option"><label for="page_for_posts_title"><?php _e( 'Page title:' ); ?> |
|---|
| 483 | + <input name="page_for_posts_title" type="text" id="page_for_posts_title" value="<?php echo esc_attr( htmlspecialchars( $page_for_posts->post_title ) ); ?>" /> |
|---|
| 484 | + </label></p> |
|---|
| 485 | + <p class="if-page-for-posts sub-option" id="edit-slug-box"> |
|---|
| 486 | + <?php echo get_sample_permalink_html( $page_for_posts->ID, $page_for_posts->post_title, $page_for_posts->post_name ); ?> |
|---|
| 487 | + <input name="post_name" type="hidden" id="post_name" value="<?php echo esc_attr( apply_filters( 'editable_slug', $page_for_posts->post_name ) ); ?>" /> |
|---|
| 488 | </p> |
|---|
| 489 | -<ul> |
|---|
| 490 | - <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> |
|---|
| 491 | - <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> |
|---|
| 492 | -</ul> |
|---|
| 493 | -<?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?> |
|---|
| 494 | -<div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div> |
|---|
| 495 | -<?php endif; ?> |
|---|
| 496 | -</fieldset></td> |
|---|
| 497 | + <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?> |
|---|
| 498 | + <div class="error inline sub-option"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div> |
|---|
| 499 | + <?php endif; ?> |
|---|
| 500 | + </fieldset> |
|---|
| 501 | + <?php else : // cannot create pages, so fall back to a selector of existing pages ?> |
|---|
| 502 | + <p class="if-page-for-posts sub-option"><label for="page_for_posts"> |
|---|
| 503 | + <?php wp_dropdown_pages( array( |
|---|
| 504 | + 'name' => 'page_for_posts', 'show_option_none' => __( '— Select —' ), |
|---|
| 505 | + 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) |
|---|
| 506 | + ) ); ?> |
|---|
| 507 | + <?php endif; // create pages ?> |
|---|
| 508 | +</td> |
|---|
| 509 | </tr> |
|---|
| 510 | -<?php endif; ?> |
|---|
| 511 | +<?php endif; // if no pages to choose from and can't create pages ?> |
|---|
| 512 | + |
|---|
| 513 | <tr valign="top"> |
|---|
| 514 | <th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th> |
|---|
| 515 | <td> |
|---|