WordPress.org

Make WordPress Core

Ticket #18235: 18235.diff

File 18235.diff, 4.4 KB (added by markjaquith, 7 years ago)

Refreshed patch

  • wp-admin/edit-form-advanced.php

    if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 
    2323 * @var int
    2424 */
    2525$post_ID = isset($post_ID) ? (int) $post_ID : 0;
    26 $temp_ID = isset($temp_ID) ? (int) $temp_ID : 0;
    2726$user_ID = isset($user_ID) ? (int) $user_ID : 0;
    2827$action = isset($action) ? $action : '';
    2928
  • wp-admin/includes/post.php

    function edit_post( $post_data = null ) { 
    229229
    230230        wp_update_post( $post_data );
    231231
    232         // Reunite any orphaned attachments with their parent
    233         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
    234                 $draft_ids = array();
    235         if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
    236                 _relocate_children( $draft_temp_id, $post_ID );
    237 
    238232        // Now that we have an ID we can fix any attachment anchor hrefs
    239233        _fix_attachment_links( $post_ID );
    240234
    function post_exists($title, $content = '', $date = '') { 
    538532function wp_write_post() {
    539533        global $user_ID;
    540534
    541 
    542535        if ( isset($_POST['post_type']) )
    543536                $ptype = get_post_type_object($_POST['post_type']);
    544537        else
    function wp_write_post() { 
    556549        // Clear out any data in internal vars.
    557550        unset( $_POST['filter'] );
    558551
    559         // Check for autosave collisions
    560         // Does this need to be updated? ~ Mark
    561         $temp_id = false;
    562         if ( isset($_POST['temp_ID']) ) {
    563                 $temp_id = (int) $_POST['temp_ID'];
    564                 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
    565                         $draft_ids = array();
    566                 foreach ( $draft_ids as $temp => $real )
    567                         if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then )
    568                                 unset($draft_ids[$temp]);
    569 
    570                 if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
    571                         $_POST['post_ID'] = $draft_ids[$temp_id];
    572                         unset($_POST['temp_ID']);
    573                         update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
    574                         return edit_post();
    575                 }
    576         }
    577 
    578552        // Edit don't write if we have a post id.
    579         if ( isset( $_POST['ID'] ) ) {
    580                 $_POST['post_ID'] = $_POST['ID'];
    581                 unset ( $_POST['ID'] );
    582         }
    583         if ( isset( $_POST['post_ID'] ) ) {
     553        if ( isset( $_POST['post_ID'] ) )
    584554                return edit_post();
    585         }
    586555
    587556        $translated = _wp_translate_postdata( false );
    588557        if ( is_wp_error($translated) )
    function wp_write_post() { 
    616585
    617586        add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
    618587
    619         // Reunite any orphaned attachments with their parent
    620         // Does this need to be updated? ~ Mark
    621         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
    622                 $draft_ids = array();
    623         if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
    624                 _relocate_children( $draft_temp_id, $post_ID );
    625         if ( $temp_id && $temp_id != $draft_temp_id )
    626                 _relocate_children( $temp_id, $post_ID );
    627 
    628         // Update autosave collision detection
    629         if ( $temp_id ) {
    630                 $draft_ids[$temp_id] = $post_ID;
    631                 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
    632         }
    633 
    634588        // Now that we have an ID we can fix any attachment anchor hrefs
    635589        _fix_attachment_links( $post_ID );
    636590
    function wp_write_post() { 
    643597 * Calls wp_write_post() and handles the errors.
    644598 *
    645599 * @since 2.0.0
    646  *
     600 
     601 * @uses wp_write_post()
     602 * @uses is_wp_error()
     603 * @uses wp_die()
    647604 * @return unknown
    648605 */
    649606function write_post() {
    function wp_create_post_autosave( $post_id ) { 
    13221279 * @package WordPress
    13231280 * @since 2.7.0
    13241281 *
    1325  * @uses wp_write_post()
     1282 * @uses get_post_status()
    13261283 * @uses edit_post()
    13271284 * @uses get_post()
    13281285 * @uses current_user_can()
     1286 * @uses wp_die()
    13291287 * @uses wp_create_post_autosave()
     1288 * @uses add_query_arg()
     1289 * @uses wp_create_nonce()
    13301290 *
    13311291 * @return str URL to redirect to show the preview
    13321292 */
  • wp-includes/post.php

    function wp_insert_attachment($object, $file = false, $parent = 0) { 
    37283728
    37293729        clean_post_cache($post_ID);
    37303730
    3731         if ( isset($post_parent) && $post_parent < 0 )
    3732                 add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true);
    3733 
    37343731        if ( ! empty( $context ) )
    37353732                add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    37363733