Make WordPress Core

Ticket #9471: 9471.diff

File 9471.diff, 5.4 KB (added by Denis-de-Bernardy, 16 years ago)
  • wp-includes/post.php

     
    14011401        if ( ('' == $post_content) && ('' == $post_title) && ('' == $post_excerpt) ) {
    14021402                if ( $wp_error )
    14031403                        return new WP_Error('empty_content', __('Content, title, and excerpt are empty.'));
    1404                 else
     1404                elseif ( empty($force_autosave) )
    14051405                        return 0;
    14061406        }
    14071407
  • wp-includes/js/autosave.dev.js

     
    172172autosave = function() {
    173173        // (bool) is rich editor enabled and active
    174174        var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(), post_data, doAutoSave, ed, origStatus, successCallback;
    175 
     175       
     176        var force = jQuery("#force_autosave").size() && jQuery("#force_autosave").val();
     177       
    176178        post_data = {
    177179                action: "autosave",
    178180                post_ID:  jQuery("#post_ID").val() || 0,
     
    208210                post_data["post_name"] = jQuery('#post_name').val();
    209211
    210212        // Nothing to save or no change.
    211         if( ( post_data["post_title"].length == 0 && post_data["content"].length == 0 ) || post_data["post_title"] + post_data["content"] == autosaveLast) {
     213        if ( !force && (( post_data["post_title"].length == 0 && post_data["content"].length == 0 ) || post_data["post_title"] + post_data["content"] == autosaveLast ) ) {
    212214                doAutoSave = false;
    213215        }
    214216
     
    232234        if ( jQuery("#post_author").size() )
    233235                post_data["post_author"] = jQuery("#post_author").val();
    234236        post_data["user_ID"] = jQuery("#user-id").val();
     237       
     238        if ( force )
     239                post_data["force_autosave"] = 1;
    235240
    236241        // Don't run while the TinyMCE spellcheck is on. It resets all found words.
    237242        if ( rich && tinyMCE.activeEditor.plugins.spellchecker && tinyMCE.activeEditor.plugins.spellchecker.active ) {
  • wp-admin/includes/media.php

     
    358358        $video_title = __('Add Video');
    359359        $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio");
    360360        $audio_title = __('Add Audio');
     361       
     362        $tb_class = $uploading_iframe_ID >= 0 ? ' class="thickbox"' : '';
     363       
    361364        $out = <<<EOF
    362365
    363         <a href="{$image_upload_iframe_src}&amp;TB_iframe=true" id="add_image" class="thickbox" title='$image_title' onclick="return false;"><img src='images/media-button-image.gif' alt='$image_title' /></a>
    364         <a href="{$video_upload_iframe_src}&amp;TB_iframe=true" id="add_video" class="thickbox" title='$video_title' onclick="return false;"><img src='images/media-button-video.gif' alt='$video_title' /></a>
    365         <a href="{$audio_upload_iframe_src}&amp;TB_iframe=true" id="add_audio" class="thickbox" title='$audio_title' onclick="return false;"><img src='images/media-button-music.gif' alt='$audio_title' /></a>
    366         <a href="{$media_upload_iframe_src}&amp;TB_iframe=true" id="add_media" class="thickbox" title='$media_title' onclick="return false;"><img src='images/media-button-other.gif' alt='$media_title' /></a>
     366        <a href="{$image_upload_iframe_src}&amp;TB_iframe=true" id="add_image" title='$image_title' $tb_class onclick="return false;"><img src='images/media-button-image.gif' alt='$image_title' /></a>
     367        <a href="{$video_upload_iframe_src}&amp;TB_iframe=true" id="add_video" title='$video_title' $tb_class onclick="return false;"><img src='images/media-button-video.gif' alt='$video_title' /></a>
     368        <a href="{$audio_upload_iframe_src}&amp;TB_iframe=true" id="add_audio" title='$audio_title' $tb_class onclick="return false;"><img src='images/media-button-music.gif' alt='$audio_title' /></a>
     369        <a href="{$media_upload_iframe_src}&amp;TB_iframe=true" id="add_media" title='$media_title' $tb_class onclick="return false;"><img src='images/media-button-other.gif' alt='$media_title' /></a>
    367370
    368371EOF;
    369372        printf($context, $out);
  • wp-admin/edit-form-advanced.php

     
    573573<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post->post_type) ?>" />
    574574<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" />
    575575<input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
     576<input type="hidden" id="force_autosave" value="" />
    576577<?php
    577578if ( 'draft' != $post->post_status )
    578579        wp_original_referer_field(true, 'previous');
     
    661662<?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?>
    662663<script type="text/javascript">
    663664try{document.post.title.focus();}catch(e){}
     665jQuery(function($) {
     666        $("#add_image, #add_video, #add_audio, #add_media").click(function() {
     667                var post_id = parseInt($("#post_ID").val(), 10);
     668
     669                if ( post_id > 0 )
     670                        return false;
     671
     672                $("#force_autosave").val(1);
     673                autosave();
     674                $("#force_autosave").val('');
     675
     676                if ( !$(this).hasClass('thickbox') ) {
     677                        $(this).addClass('thickbox').hasClass('thickbox');
     678                        tb_init(this);
     679                        return false;
     680                } else {
     681                        return false;
     682                }
     683        });
     684});
    664685</script>
    665686<?php endif; ?>