diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 8738231b98..9b84e9fe76 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -383,18 +383,20 @@ function wp_dashboard_right_now() { do_action( 'activity_box_end' ); } -function wp_dashboard_quick_press() { +function wp_dashboard_quick_press_output() { + global $post_ID; + $drafts = false; if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) { $view = get_permalink( $_POST['post_ID'] ); $edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) ); if ( 'post-quickpress-publish' == $_POST['action'] ) { if ( current_user_can('publish_posts') ) - printf( '
', esc_url( $view ), $edit ); + printf( '', esc_url( $view ), $edit ); else - printf( ' ', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit ); + printf( '' . __( 'Post submitted. Preview post | Edit post' ) . '
' . __( 'Draft saved. Preview post | Edit post' ) . '
' . __('You can also try %s, easy blogging from anywhere on the Web.') . '
', '' . __('Press This') . '' ); + printf('' . __('You can also try %s, easy blogging from anywhere on the Web.') . '
', '' . __('Press This') . '' ); $_REQUEST = array(); // hack for get_default_post_to_edit() } - $post = get_default_post_to_edit(); + /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ + $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID + if ( $last_post_id ) { + $post = get_post( $last_post_id ); + if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore + $post = get_default_post_to_edit('post', true); + update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + } else { + $post->post_title = ''; // Remove the auto draft title + } + } else { + $post = get_default_post_to_edit('post', true); + update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + } + + $post_ID = (int) $post->ID; ?>