Show permalink editor on new posts after autosave. Props filosofo. see #5749

git-svn-id: http://svn.automattic.com/wordpress/trunk@6954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-21 17:08:06 +00:00
parent eb3cb51113
commit f5afc1fd4f
6 changed files with 26 additions and 16 deletions

View File

@ -527,7 +527,7 @@ break;
case 'get-permalink':
check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
die(get_permalink($post_id));
die(add_query_arg(array('preview' => 'true'), get_permalink($post_id)));
break;
case 'sample-permalink':
check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );

View File

@ -71,18 +71,12 @@ addLoadEvent(focusit);
<h3><?php _e('Title') ?></h3>
<div class="inside">
<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" />
<?php
$sample_permalink_html = get_sample_permalink_html($post->ID);
if ($post->ID && $sample_permalink_html):
?>
<div id="edit-slug-box" style="display: <?php echo $post->ID? 'block' : 'none';?>">
<strong><?php _e('Permalink:'); ?></strong>
<span id="sample-permalink"><?php echo $sample_permalink_html; ?></span>
<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug" onclick="edit_permalink(<?php echo $post->ID; ?>);return false;"><?php _e('Edit');?></a></span>
<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
<div id="edit-slug-box">
<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
echo $sample_permalink_html;
endif; ?>
</div>
<?php
endif;
?>
</div>
</div>

View File

@ -604,7 +604,9 @@ function get_sample_permalink_html($id, $new_slug=null) {
}
$post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name_abridged.'</span><span id="editable-post-name-full">'.$post_name.'</span>';
$display_link = str_replace('%postname%', $post_name_html, $permalink);
return $display_link;
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $display_link . "</span>\n";
$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug" onclick="edit_permalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
return $return;
}
?>

View File

@ -16,7 +16,7 @@ function edit_permalink(post_id) {
post_id: post_id,
new_slug: new_slug,
samplepermalinknonce: jQuery('#samplepermalinknonce').val()}, function(data) {
jQuery('#sample-permalink').html(data);
jQuery('#edit-slug-box').html(data);
b.html(revert_b);
real_slug.attr('value', new_slug);
make_slugedit_clickable();

View File

@ -47,6 +47,7 @@ function autosave_update_post_ID(response) {
}
jQuery('#autosave').html(message);
autosave_update_preview_link(res);
autosave_update_slug(res);
autosave_enable_buttons();
}
@ -62,7 +63,19 @@ function autosave_update_preview_link(post_id) {
}, function(permalink) {
jQuery('#previewview').html('<a target="_blank" href="'+permalink+'">'+previewText+'</a>');
});
}
}
function autosave_update_slug(post_id) {
// create slug area only if not already there
if ( 'undefined' != typeof make_slugedit_clickable && ! jQuery('#edit-slug-box > *').get()[0] ) {
jQuery.post(slugL10n.requestFile, {
action: 'sample-permalink',
post_id: post_id,
samplepermalinknonce: jQuery('#samplepermalinknonce').val()}, function(data) {
jQuery('#edit-slug-box').html(data);
make_slugedit_clickable();
});
}
}
@ -81,6 +94,7 @@ function autosave_saved(response) {
}
jQuery('#autosave').html(message);
autosave_update_preview_link(res);
autosave_update_slug(res);
autosave_enable_buttons();
}

View File

@ -42,7 +42,7 @@ class WP_Scripts {
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080220');
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080221');
$this->localize( 'autosave', 'autosaveL10n', array(
'autosaveInterval' => apply_filters('autosave_interval', '120'),
'errorText' => __('Error: %response%'),