if ( !
current_user_can( 'edit_posts'
) ) { return;
} // 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 ) || 'auto-draft' !==
$post->post_status
) { // auto-draft doesn't exist anymore.
$post =
get_default_post_to_edit( 'post', true
);
update_user_option( get_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
);
$user_id =
get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
if ( in_array( get_current_blog_id(),
array_keys( get_blogs_of_user( $user_id ) ), true
) ) { update_user_option( $user_id, 'dashboard_quick_press_last_post_id',
(int) $post->ID
); // Save post_ID.