Ticket #18306: 18306.11.diff
File 18306.11.diff, 6.1 KB (added by , 9 years ago) |
---|
-
src/wp-admin/css/edit.css
113 113 } 114 114 115 115 #editable-post-name { 116 background-color: #fffbcc;116 font-weight: bold; 117 117 } 118 118 119 119 #editable-post-name input { 120 120 font-size: 13px; 121 font-weight: normal; 121 122 height: 22px; 122 123 margin: 0; 123 124 width: 16em; -
src/wp-admin/includes/post.php
1275 1275 1276 1276 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1277 1277 1278 $view_link = false; 1279 $preview_target = ''; 1280 1278 1281 if ( current_user_can( 'read_post', $post->ID ) ) { 1279 $ptype = get_post_type_object( $post->post_type ); 1280 $view_post = $ptype->labels->view_item; 1282 if ( 'draft' == $post->post_status ) { 1283 $draft_link = set_url_scheme( get_permalink( $post->ID ) ); 1284 $view_link = get_preview_post_link( $post, array(), $draft_link ); 1285 $preview_target = " target='wp-preview-{$post->ID}'"; 1286 } else { 1287 if ( 'publish' === $post->post_status ) { 1288 $view_link = get_permalink( $post ); 1289 } else { 1290 // Allow non-published (private, future) to be viewed at a pretty permalink. 1291 $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, urldecode( $permalink ) ); 1292 } 1293 } 1281 1294 } 1282 1295 1283 if ( 'publish' == get_post_status( $post ) ) { 1284 $title = __('Click to edit this part of the permalink'); 1285 } else { 1286 $title = __('Temporary permalink. Click to edit this part.'); 1287 } 1296 $return = '<strong>' . __('Permalink:') . "</strong>\n"; 1288 1297 1298 // Permalinks without a post/page name placeholder don't have anything to edit 1289 1299 if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { 1290 $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n"; 1300 if ( false !== $view_link ) { 1301 $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $permalink . "</a>\n"; 1302 } else { 1303 $return .= '<span id="sample-permalink">' . $permalink . "</span>\n"; 1304 } 1305 1306 // Encourage a pretty permalink setting 1291 1307 if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) { 1292 1308 $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; 1293 1309 } … … 1306 1322 } 1307 1323 } 1308 1324 1309 $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';1325 $post_name_html = '<span id="editable-post-name">' . $post_name_abridged . '</span>'; 1310 1326 $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) ); 1311 1327 1312 $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; 1313 $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n"; 1328 $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a>\n"; 1314 1329 $return .= '‎'; // Fix bi-directional text display defect in RTL languages. 1315 $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";1330 $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js">' . __( 'Edit' ) . "</button></span>\n"; 1316 1331 $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; 1317 1332 } 1318 1333 1319 if ( isset( $view_post ) ) {1320 if ( 'draft' == $post->post_status ) {1321 $draft_link = set_url_scheme( get_permalink( $post->ID ) );1322 $preview_link = get_preview_post_link( $post, array(), $draft_link );1323 $return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n";1324 } else {1325 if ( 'publish' === $post->post_status ) {1326 // View Post button should always go to the saved permalink.1327 $pretty_permalink = get_permalink( $post );1328 } else {1329 // Allow non-published (private, future) to be viewed at a pretty permalink.1330 $pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, urldecode( $permalink ) );1331 }1332 1333 $return .= "<span id='view-post-btn'><a href='" . $pretty_permalink . "' class='button button-small'>$view_post</a></span>\n";1334 }1335 }1336 1337 1334 /** 1338 1335 * Filter the sample permalink HTML markup. 1339 1336 * -
src/wp-admin/js/post.js
210 210 sticky = '', 211 211 $textarea = $('#content'), 212 212 $document = $(document), 213 $editSlugWrap = $('#edit-slug-box'),214 213 postId = $('#post_ID').val() || 0, 215 214 $submitpost = $('#submitpost'), 216 215 releaseLock = true, … … 737 736 full = full.html(); 738 737 739 738 $('#view-post-btn').hide(); 740 b.html('< a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');739 b.html('<button type="button" class="save button button-small">'+postL10n.ok+'</button> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); 741 740 b.children('.save').click(function() { 742 741 var new_slug = e.children('input').val(); 743 742 if ( new_slug == $('#editable-post-name-full').text() ) { … … 796 795 }).focus(); 797 796 } 798 797 799 if ( $editSlugWrap.length) {800 $editSlugWrap.on( 'click', function( event ) {801 var $target = $( event.target);798 $('#edit-slug-box').on( 'click', '.edit-slug', function() { 799 editPermalink(); 800 }); 802 801 803 if ( $target.is('#editable-post-name') || $target.hasClass('edit-slug') ) {804 editPermalink();805 }806 });807 }808 809 802 wptitlehint = function(id) { 810 803 id = id || 'title'; 811 804