Make WordPress Core

Changeset 14815


Ignore:
Timestamp:
05/23/2010 07:58:06 AM (16 years ago)
Author:
westi
Message:

Ensure that QuickPress media uploads get attached to the auto-draft we create for new posts correctly. Fixes #10917 props ocean90.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/dashboard.php

    r14582 r14815  
    384384}
    385385
    386 function wp_dashboard_quick_press() {
     386function wp_dashboard_quick_press_output() {
     387        global $post_ID;
     388
    387389        $drafts = false;
    388390        if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
     
    391393                if ( 'post-quickpress-publish' == $_POST['action'] ) {
    392394                        if ( current_user_can('publish_posts') )
    393                                 printf( '<div class="message"><p>' . __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit );
     395                                printf( '<div class="updated"><p>' . __( 'Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit );
    394396                        else
    395                                 printf( '<div class="message"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
     397                                printf( '<div class="updated"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
    396398                } else {
    397                         printf( '<div class="message"><p>' . __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
     399                        printf( '<div class="updated"><p>' . __( 'Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
    398400                        $drafts_query = new WP_Query( array(
    399401                                'post_type' => 'post',
     
    408410                                $drafts =& $drafts_query->posts;
    409411                }
    410                 printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="tools.php">' . __('Press This') . '</a>' );
     412                printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' );
    411413                $_REQUEST = array(); // hack for get_default_post_to_edit()
    412414        }
    413415
    414         $post = get_default_post_to_edit();
     416        /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
     417        $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
     418        if ( $last_post_id ) {
     419                $post = get_post( $last_post_id );
     420                if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
     421                        $post = get_default_post_to_edit('post', true);
     422                        update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
     423                } else {
     424                        $post->post_title = ''; // Remove the auto draft title
     425                }
     426        } else {
     427                $post = get_default_post_to_edit('post', true);
     428                update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
     429        }
     430
     431        $post_ID = (int) $post->ID;
    415432?>
    416433
     
    441458                <p class="submit">
    442459                        <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
    443                         <input type="hidden" name="quickpress_post_ID" value="<?php echo (int) $post->ID; ?>" />
     460                        <input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?>" />
    444461                        <input type="hidden" name="post_type" value="post" />
    445462                        <?php wp_nonce_field('add-post'); ?>
     
    458475        if ( $drafts )
    459476                wp_dashboard_recent_drafts( $drafts );
     477}
     478
     479function wp_dashboard_quick_press() {
     480        echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
    460481}
    461482
  • trunk/wp-admin/index-extra.php

    r14139 r14815  
    3333        wp_dashboard_plugins_output();
    3434        break;
     35       
     36case 'dashboard_quick_press' :
     37        wp_dashboard_quick_press_output();
     38        break;
    3539
    3640}
  • trunk/wp-admin/js/dashboard.dev.js

    r13085 r14815  
    77                'dashboard_primary',
    88                'dashboard_secondary',
    9                 'dashboard_plugins'
     9                'dashboard_plugins',
     10                'dashboard_quick_press'
    1011        ];
    1112
     
    2122                                                        if ( 'dashboard_plugins' == id && $.isFunction(tb_init) )
    2223                                                                tb_init('#dashboard_plugins a.thickbox');
     24                                                        if ( 'dashboard_quick_press' == id && $.isFunction(tb_init) ) {
     25                                                                tb_init('#dashboard_quick_press a.thickbox');
     26                                                                quickPressLoad();
     27                                                        }
    2328                                                });
    2429                                        });
     
    5459                                $('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'hidden');
    5560                                $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','');
     61                                $('#dashboard_quick_press ul').next('p').remove();
    5662                                $('#dashboard_quick_press ul').find('li').each( function() {
    5763                                        $('#dashboard_recent_drafts ul').prepend( this );
     
    6672
    6773        };
    68         quickPressLoad();
    6974
    7075} );
  • trunk/wp-admin/js/dashboard.js

    r13085 r14815  
    1 var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(a){ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins"];ajaxPopulateWidgets=function(b){show=function(g,c){var f,d=a("#"+g+" div.inside:visible").find(".widget-loading");if(d.length){f=d.parent();setTimeout(function(){f.load("index-extra.php?jax="+g,"",function(){f.hide().slideDown("normal",function(){a(this).css("display","");if("dashboard_plugins"==g&&a.isFunction(tb_init)){tb_init("#dashboard_plugins a.thickbox")}})})},c*500)}};if(b){b=b.toString();if(a.inArray(b,ajaxWidgets)!=-1){show(b,0)}}else{a.each(ajaxWidgets,function(c){show(this,c)})}};ajaxPopulateWidgets();postboxes.add_postbox_toggles("dashboard",{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var b=a("#quickpost-action"),c;c=a("#quick-press").submit(function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","visible");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","disabled");if("post"==b.val()){b.val("post-quickpress-publish")}a("#dashboard_quick_press div.inside").load(c.attr("action"),c.serializeArray(),function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","hidden");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","");a("#dashboard_quick_press ul").find("li").each(function(){a("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");quickPressLoad()});return false});a("#publish").click(function(){b.val("post-quickpress-publish")})};quickPressLoad()});
     1var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(a){ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins","dashboard_quick_press"];ajaxPopulateWidgets=function(b){show=function(g,c){var f,d=a("#"+g+" div.inside:visible").find(".widget-loading");if(d.length){f=d.parent();setTimeout(function(){f.load("index-extra.php?jax="+g,"",function(){f.hide().slideDown("normal",function(){a(this).css("display","");if("dashboard_plugins"==g&&a.isFunction(tb_init)){tb_init("#dashboard_plugins a.thickbox")}if("dashboard_quick_press"==g&&a.isFunction(tb_init)){tb_init("#dashboard_quick_press a.thickbox");quickPressLoad()}})})},c*500)}};if(b){b=b.toString();if(a.inArray(b,ajaxWidgets)!=-1){show(b,0)}}else{a.each(ajaxWidgets,function(c){show(this,c)})}};ajaxPopulateWidgets();postboxes.add_postbox_toggles("dashboard",{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var b=a("#quickpost-action"),c;c=a("#quick-press").submit(function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","visible");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","disabled");if("post"==b.val()){b.val("post-quickpress-publish")}a("#dashboard_quick_press div.inside").load(c.attr("action"),c.serializeArray(),function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","hidden");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","");a("#dashboard_quick_press ul").next("p").remove();a("#dashboard_quick_press ul").find("li").each(function(){a("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");quickPressLoad()});return false});a("#publish").click(function(){b.val("post-quickpress-publish")})}});
  • trunk/wp-admin/post.php

    r14585 r14815  
    132132                // output the quickpress dashboard widget
    133133                require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
    134                 wp_dashboard_quick_press();
     134                wp_dashboard_quick_press_output();
    135135                exit;
    136136        }
  • trunk/wp-includes/script-loader.php

    r14799 r14815  
    361361                $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
    362362
    363                 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20100213' );
     363                $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20100523' );
    364364                $scripts->add_data( 'dashboard', 'group', 1 );
    365365
Note: See TracChangeset for help on using the changeset viewer.