Changeset 22127 for trunk/wp-admin/includes/post.php
- Timestamp:
- 10/06/2012 03:19:29 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r21949 r22127 1063 1063 $post = get_post($id); 1064 1064 1065 $context = isset( $_POST['context'] ) ? $_POST['context'] : get_current_screen()->id; 1065 1066 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1066 1067 … … 1074 1075 1075 1076 if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { 1077 if ( 'options-reading' == $context ) 1078 return ''; 1076 1079 $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n"; 1077 1080 if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) … … 1102 1105 $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); 1103 1106 $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink); 1104 $return = '<strong>' . __('Permalink:') . "</strong>\n";1107 $return = ( 'options-reading' == $context ) ? __( 'Located at' ) . "\n" : '<strong>' . __( 'Permalink:' ) . "</strong>\n"; 1105 1108 $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n"; 1106 1109 $return .= '‎'; // Fix bi-directional text display defect in RTL languages. 1107 1110 $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"; 1108 1111 $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; 1109 if ( isset( $view_post))1112 if ( isset( $view_post ) && 'options-reading' != $context ) 1110 1113 $return .= "<span id='view-post-btn'><a href='$view_link' class='button button-small'>$view_post</a></span>\n"; 1111 1114 … … 1323 1326 return $url; 1324 1327 } 1328 1329 /** 1330 * Creates new pages to be set as a front page or a page for posts in Reading Settings. 1331 * 1332 * @todo Make sure we are doing adequate sanitization on success, and cleanup/reset on failure. 1333 * 1334 * @since 3.5.0 1335 * @access private 1336 */ 1337 function _create_pages_for_reading_settings() { 1338 // If we're saving the Reading Settings screen, intercept. 1339 if ( ! isset( $_POST['show_on_front'] ) ) 1340 return; 1341 1342 // If a new front page was meant to be created, go forth and create it. 1343 if ( isset( $_POST['page_on_front'] ) && 'new' == $_POST['page_on_front'] ) { 1344 if ( ! current_user_can( 'create_posts', 'page' ) ) { 1345 $_POST['page_on_front'] = 0; 1346 $_POST['show_on_front'] = 'posts'; 1347 add_settings_error( 'page_on_front', __( 'You are not allowed to create pages on this site.' ) ); 1348 } 1349 1350 $existing_page = get_page_by_title( stripslashes( $_POST['page_on_front_title'] ) ); 1351 1352 // If page already exists and it's public, there's no need to create a new page 1353 if ( $existing_page && 'publish' == $existing_page->post_status ) { 1354 $page_id = $existing_page->ID; 1355 } else { 1356 $page_id = wp_insert_post( array( 1357 'post_title' => $_POST['page_on_front_title'], 1358 'post_type' => 'page', 1359 'post_status' => 'publish', 1360 'comment_status' => 'closed', 1361 'ping_status' => 'closed', 1362 // @todo Create some sort of a 'context' in postmeta so we know we created a page through these means. 1363 // Consider then showing that context in the list table as a good-first-step. 1364 ), true ); 1365 } 1366 1367 // Make sure page_on_front is properly saved by options.php. 1368 if ( is_wp_error( $page_id ) ) 1369 $_POST['page_on_front'] = 0; 1370 else 1371 $_POST['page_on_front'] = $page_id; 1372 } 1373 1374 // If a page for posts was meant to be specified, update/create it. 1375 if ( ! isset( $_POST['page_for_posts'] ) ) 1376 return; 1377 1378 $page_for_posts = (int) $_POST['page_for_posts']; 1379 if ( ! $page_for_posts || ! $page = get_post( $page_for_posts, ARRAY_A ) ) { 1380 $_POST['page_for_posts'] = 0; 1381 return; 1382 } 1383 1384 // @todo The UI (see @todo's in options-reading) should cover the next 3 conditionals, 1385 // which means we shouldn't need to bother with setting a settings error here. 1386 // However, we may wish to restore settings before bailing, beyond setting 1387 // page_for_posts to 0 (which we then expect to get cleaned up by options.php). 1388 if ( 'page' != $page['post_type'] || ! current_user_can( 'edit_post', $page_for_posts ) ) { 1389 $_POST['page_for_posts'] = 0; 1390 return; 1391 } 1392 1393 if ( 'publish' != $page['post_status'] && ! current_user_can( 'publish_post', $page_for_posts ) ) { 1394 $_POST['page_for_posts'] = 0; 1395 return; 1396 } 1397 1398 $args = add_magic_quotes( $page ); 1399 $args['post_title'] = $_POST['page_for_posts_title']; 1400 $args['post_name'] = $_POST['post_name']; 1401 $args['post_status'] = 'publish'; 1402 if ( 'auto-draft' == $page['post_status'] ) { 1403 $args['comment_status'] = 'closed'; 1404 $args['ping_status'] = 'closed'; 1405 } 1406 1407 $page_id = wp_insert_post( $args, true ); 1408 if ( is_wp_error( $page_id ) ) 1409 $_POST['page_for_posts'] = 0; 1410 } 1411 add_filter( 'admin_init', '_create_pages_for_reading_settings' );
Note: See TracChangeset
for help on using the changeset viewer.