Ticket #18306: 18306.12.diff
File 18306.12.diff, 7.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
1287 1287 1288 1288 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1289 1289 1290 $view_link = false; 1291 $preview_target = ''; 1292 1290 1293 if ( current_user_can( 'read_post', $post->ID ) ) { 1291 $ptype = get_post_type_object( $post->post_type ); 1292 $view_post = $ptype->labels->view_item; 1294 if ( 'draft' == $post->post_status ) { 1295 $draft_link = set_url_scheme( get_permalink( $post->ID ) ); 1296 $view_link = get_preview_post_link( $post, array(), $draft_link ); 1297 $preview_target = " target='wp-preview-{$post->ID}'"; 1298 } else { 1299 if ( 'publish' === $post->post_status ) { 1300 $view_link = get_permalink( $post ); 1301 } else { 1302 // Allow non-published (private, future) to be viewed at a pretty permalink. 1303 $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, urldecode( $permalink ) ); 1304 } 1305 } 1293 1306 } 1294 1307 1295 if ( 'publish' == get_post_status( $post ) ) { 1296 $title = __('Click to edit this part of the permalink'); 1297 } else { 1298 $title = __('Temporary permalink. Click to edit this part.'); 1299 } 1308 // Permalinks without a post/page name placeholder don't have anything to edit 1309 if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { 1310 $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; 1300 1311 1301 if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { 1302 $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n"; 1312 if ( false !== $view_link ) { 1313 $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $permalink . "</a>\n"; 1314 } else { 1315 $return .= '<span id="sample-permalink">' . $permalink . "</span>\n"; 1316 } 1317 1318 // Encourage a pretty permalink setting 1303 1319 if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) { 1304 1320 $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; 1305 1321 } … … 1318 1334 } 1319 1335 } 1320 1336 1321 $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';1337 $post_name_html = '<span id="editable-post-name">' . $post_name_abridged . '</span>'; 1322 1338 $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) ); 1323 1339 1324 $return = 1325 $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";1340 $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; 1341 $return .= '<span id="sample-permalink"><a href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a></span>\n"; 1326 1342 $return .= '‎'; // Fix bi-directional text display defect in RTL languages. 1327 $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";1343 $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js">' . __( 'Edit' ) . "</button></span>\n"; 1328 1344 $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; 1329 1345 } 1330 1346 -
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, … … 723 722 // permalink 724 723 function editPermalink() { 725 724 var i, slug_value, 725 e, revert_e, 726 726 c = 0, 727 e = $('#editable-post-name'),728 revert_e = e.html(),729 727 real_slug = $('#post_name'), 730 728 revert_slug = real_slug.val(), 731 b = $('#edit-slug-buttons'), 732 revert_b = b.html(), 729 permalink = $( '#sample-permalink' ), 730 permalinkOrig = permalink.html(), 731 permalinkInner = $( '#sample-permalink a' ).html(), 732 buttons = $('#edit-slug-buttons'), 733 buttonsOrig = buttons.html(), 733 734 full = $('#editable-post-name-full'); 734 735 735 736 // Deal with Twemoji in the post-name 736 737 full.find( 'img' ).replaceWith( function() { return this.alt; } ); 737 738 full = full.html(); 738 739 739 $('#view-post-btn').hide(); 740 b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); 741 b.children('.save').click(function() { 740 permalink.html( permalinkInner ); 741 e = $('#editable-post-name'); 742 revert_e = e.html(); 743 744 buttons.html('<button type="button" class="save button button-small">'+postL10n.ok+'</button> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); 745 buttons.children('.save').click(function() { 742 746 var new_slug = e.children('input').val(); 743 747 if ( new_slug == $('#editable-post-name-full').text() ) { 744 b .children('.cancel').click();748 buttons.children('.cancel').click(); 745 749 return false; 746 750 } 747 751 $.post(ajaxurl, { … … 759 763 }); 760 764 } 761 765 762 b.html(revert_b); 766 buttons.html(buttonsOrig); 767 permalink.html(permalinkOrig); 763 768 real_slug.val(new_slug); 764 $( '#view-post-btn').show();769 $( '.edit-slug' ).focus(); 765 770 }); 766 771 return false; 767 772 }); 768 773 769 b .children('.cancel').click(function() {774 buttons.children('.cancel').click(function() { 770 775 $('#view-post-btn').show(); 771 776 e.html(revert_e); 772 b.html(revert_b); 777 buttons.html(buttonsOrig); 778 permalink.html(permalinkOrig); 773 779 real_slug.val(revert_slug); 780 $( '.edit-slug' ).focus(); 774 781 return false; 775 782 }); 776 783 … … 784 791 var key = e.keyCode || 0; 785 792 // on enter, just save the new slug, don't save the post 786 793 if ( 13 == key ) { 787 b .children('.save').click();794 buttons.children('.save').click(); 788 795 return false; 789 796 } 790 797 if ( 27 == key ) { 791 b .children('.cancel').click();798 buttons.children('.cancel').click(); 792 799 return false; 793 800 } 794 801 } ).keyup( function() { … … 796 803 }).focus(); 797 804 } 798 805 799 if ( $editSlugWrap.length) {800 $editSlugWrap.on( 'click', function( event ) {801 var $target = $( event.target);806 $('#edit-slug-box').on( 'click', '.edit-slug', function() { 807 editPermalink(); 808 }); 802 809 803 if ( $target.is('#editable-post-name') || $target.hasClass('edit-slug') ) {804 editPermalink();805 }806 });807 }808 809 810 wptitlehint = function(id) { 810 811 id = id || 'title'; 811 812