Fix permalink editor for pages, hide "View Post" button while editing permalink, fixes #9040
git-svn-id: http://svn.automattic.com/wordpress/trunk@10525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -943,16 +943,13 @@ function get_sample_permalink($id, $title=null, $name = null) {
|
||||
* @param unknown_type $new_slug
|
||||
* @return unknown
|
||||
*/
|
||||
function get_sample_permalink_html($id, $new_title=null, $new_slug=null) {
|
||||
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||
$post = &get_post($id);
|
||||
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
|
||||
if ( 'publish' == $post->post_status )
|
||||
$view_post = 'post' == $post->post_type ? __('View Post') : __('View Page');
|
||||
|
||||
if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
|
||||
if ( 'page' == $post->post_type )
|
||||
return '';
|
||||
|
||||
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n";
|
||||
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
|
||||
if ( isset($view_post) )
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
function edit_permalink(post_id) {
|
||||
var i, c = 0, e = jQuery('#editable-post-name'), revert_e = e.html(), real_slug = jQuery('#post_name'), revert_slug = real_slug.html(), b = jQuery('#edit-slug-buttons'), revert_b = b.html(), full = jQuery('#editable-post-name-full').html();
|
||||
|
||||
b.html('<a href="" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+'</a>');
|
||||
jQuery('#view-post-btn').hide();
|
||||
b.html('<a href="#" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="#">'+slugL10n.cancel+'</a>');
|
||||
b.children('.save').click(function() {
|
||||
var new_slug = e.children('input').val();
|
||||
jQuery.post(slugL10n.requestFile, {
|
||||
@@ -14,10 +15,12 @@ function edit_permalink(post_id) {
|
||||
b.html(revert_b);
|
||||
real_slug.attr('value', new_slug);
|
||||
make_slugedit_clickable();
|
||||
jQuery('#view-post-btn').show();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
jQuery('#edit-slug-buttons .cancel').click(function() {
|
||||
jQuery('#view-post-btn').show();
|
||||
e.html(revert_e);
|
||||
b.html(revert_b);
|
||||
real_slug.attr('value', revert_slug);
|
||||
|
||||
@@ -1 +1 @@
|
||||
function edit_permalink(a){var d,h=0,g=jQuery("#editable-post-name"),j=g.html(),m=jQuery("#post_name"),n=m.html(),k=jQuery("#edit-slug-buttons"),l=k.html(),f=jQuery("#editable-post-name-full").html();k.html('<a href="" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+"</a>");k.children(".save").click(function(){var b=g.children("input").val();jQuery.post(slugL10n.requestFile,{action:"sample-permalink",post_id:a,new_slug:b,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(c){jQuery("#edit-slug-box").html(c);k.html(l);m.attr("value",b);make_slugedit_clickable()});return false});jQuery("#edit-slug-buttons .cancel").click(function(){g.html(j);k.html(l);m.attr("value",n);return false});for(d=0;d<f.length;++d){if("%"==f.charAt(d)){h++}}slug_value=(h>f.length/4)?"":f;g.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(c){var b=c.charCode?c.charCode:c.keyCode?c.keyCode:0;if(13==b){k.children(".save").click();return false}if(27==b){k.children(".cancel").click();return false}m.attr("value",this.value)}).focus()}function make_slugedit_clickable(){jQuery("#editable-post-name").click(function(){jQuery("#edit-slug-buttons").children(".edit-slug").click()})};
|
||||
function edit_permalink(a){var d,h=0,g=jQuery("#editable-post-name"),j=g.html(),m=jQuery("#post_name"),n=m.html(),k=jQuery("#edit-slug-buttons"),l=k.html(),f=jQuery("#editable-post-name-full").html();jQuery("#view-post-btn").hide();k.html('<a href="#" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="#">'+slugL10n.cancel+"</a>");k.children(".save").click(function(){var b=g.children("input").val();jQuery.post(slugL10n.requestFile,{action:"sample-permalink",post_id:a,new_slug:b,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(c){jQuery("#edit-slug-box").html(c);k.html(l);m.attr("value",b);make_slugedit_clickable();jQuery("#view-post-btn").show()});return false});jQuery("#edit-slug-buttons .cancel").click(function(){jQuery("#view-post-btn").show();g.html(j);k.html(l);m.attr("value",n);return false});for(d=0;d<f.length;++d){if("%"==f.charAt(d)){h++}}slug_value=(h>f.length/4)?"":f;g.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(c){var b=c.charCode?c.charCode:c.keyCode?c.keyCode:0;if(13==b){k.children(".save").click();return false}if(27==b){k.children(".cancel").click();return false}m.attr("value",this.value)}).focus()}function make_slugedit_clickable(){jQuery("#editable-post-name").click(function(){jQuery("#edit-slug-buttons").children(".edit-slug").click()})};
|
||||
Reference in New Issue
Block a user