Don't load autosave.js on the attachment editing screen, add simple AYS on unload if there are changes, props helenyhou, fixes #22491
git-svn-id: https://develop.svn.wordpress.org/trunk@22725 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0f21638a91
commit
5e7443ca85
@ -418,3 +418,21 @@ if ( post_type_supports( $post_type, 'comments' ) )
|
||||
try{document.post.title.focus();}catch(e){}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( 'attachment' == $post_type ) { ?>
|
||||
<script type="text/javascript">
|
||||
(function($){
|
||||
function getFieldsContent() {
|
||||
return ($('#title').val() || '') + ($('#attachment_caption').val() || '') +
|
||||
($('#attachment_alt').val() || '') + ($('#attachment_content').val() || '') + ($('#post_name').val() || '');
|
||||
}
|
||||
|
||||
var initial = getFieldsContent();
|
||||
|
||||
window.onbeforeunload = function() {
|
||||
if ( initial != getFieldsContent() )
|
||||
return '<?php _e('The changes you made will be lost if you navigate away from this page.'); ?>';
|
||||
};
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
@ -43,7 +43,8 @@ if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_
|
||||
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) )
|
||||
wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
|
||||
|
||||
wp_enqueue_script('autosave');
|
||||
if ( 'attachment' !== $post_type )
|
||||
wp_enqueue_script('autosave');
|
||||
|
||||
// Show post form.
|
||||
$post = get_default_post_to_edit( $post_type, true );
|
||||
|
@ -169,7 +169,9 @@ case 'edit':
|
||||
add_action('admin_notices', '_admin_notice_post_locked' );
|
||||
} else {
|
||||
$active_post_lock = wp_set_post_lock( $post->ID );
|
||||
wp_enqueue_script('autosave');
|
||||
|
||||
if ( 'attachment' !== $post_type )
|
||||
wp_enqueue_script('autosave');
|
||||
}
|
||||
|
||||
$title = $post_type_object->labels->edit_item;
|
||||
|
Loading…
Reference in New Issue
Block a user