Make WordPress Core

Changeset 18023


Ignore:
Timestamp:
05/24/2011 03:57:28 PM (14 years ago)
Author:
ryan
Message:

Mark import attachments as private. Schedule job to delete old import attachments. Introduce attachment context.

Location:
branches/3.1
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1

  • branches/3.1/wp-admin/custom-background.php

    r16660 r18023  
    338338            'post_content' => $url,
    339339            'post_mime_type' => $type,
    340             'guid' => $url
     340            'guid' => $url,
     341            'context' => 'custom-background'
    341342        );
    342343
  • branches/3.1/wp-admin/custom-header.php

    r16061 r18023  
    596596        'post_content' => $url,
    597597        'post_mime_type' => $type,
    598         'guid' => $url);
     598        'guid' => $url,
     599        'context' => 'custom-header');
    599600
    600601        // Save the data
     
    688689            'post_content' => $url,
    689690            'post_mime_type' => 'image/jpeg',
    690             'guid' => $url
     691            'guid' => $url,
     692            'context' => 'custom-header'
    691693        );
    692694
  • branches/3.1/wp-admin/includes/import.php

    r16608 r18023  
    8181        'post_content' => $url,
    8282        'post_mime_type' => $type,
    83         'guid' => $url
     83        'guid' => $url,
     84        'context' => 'import',
     85        'post_status' => 'private'
    8486    );
    8587
     
    8789    $id = wp_insert_attachment( $object, $file );
    8890
     91    // schedule a cleanup for one day from now in case of failed import or missing wp_import_cleanup() call
     92    wp_schedule_single_event( time() + 86400, 'importer_scheduled_cleanup', array( $id ) );
     93
    8994    return array( 'file' => $file, 'id' => $id );
    9095}
  • branches/3.1/wp-admin/includes/post.php

    r18020 r18023  
    997997    $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
    998998    $q['post_type'] = 'attachment';
    999     $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit';
     999    $post_type = get_post_type_object( 'attachment' );
     1000    $states = array( 'inherit' );
     1001    if ( current_user_can( $post_type->cap->read_private_posts ) )
     1002        $states[] = 'private';
     1003
     1004    $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;
    10001005    $media_per_page = (int) get_user_option( 'upload_per_page' );
    10011006    if ( empty( $media_per_page ) || $media_per_page < 1 )
  • branches/3.1/wp-includes/default-filters.php

    r18018 r18023  
    256256add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'            );
    257257add_action( 'admin_init',                 'send_frame_options_header', 10, 0 );
     258add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment'           );
    258259
    259260// Navigation menu actions
  • branches/3.1/wp-includes/post.php

    r17519 r18023  
    558558        return false;
    559559
    560     // Unattached attachments are assumed to be published.
    561     if ( ('attachment' == $post->post_type) && ('inherit' == $post->post_status) && ( 0 == $post->post_parent) )
    562         return 'publish';
    563 
    564     if ( ('attachment' == $post->post_type) && $post->post_parent && ($post->ID != $post->post_parent) )
    565         return get_post_status($post->post_parent);
     560    if ( 'attachment' == $post->post_type ) {
     561        if ( 'private' == $post->post_status )
     562            return 'private';
     563
     564        // Unattached attachments are assumed to be published
     565        if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) )
     566            return 'publish';
     567
     568        // Inherit status from the parent
     569        if ( $post->post_parent && ( $post->ID != $post->post_parent ) )
     570            return get_post_status($post->post_parent);
     571    }
    566572
    567573    return $post->post_status;
     
    35333539    global $wpdb, $user_ID;
    35343540
    3535     $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
     3541    $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID,
    35363542        'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    35373543        'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
    3538         'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0);
     3544        'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');
    35393545
    35403546    $object = wp_parse_args($object, $defaults);
     
    35513557
    35523558    $post_type = 'attachment';
    3553     $post_status = 'inherit';
     3559
     3560    if ( ! in_array( $post_status, array( 'inherit', 'private' ) ) )
     3561        $post_status = 'inherit';
    35543562
    35553563    // Make sure we set a valid category.
     
    36533661    if ( isset($post_parent) && $post_parent < 0 )
    36543662        add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true);
     3663
     3664    if ( ! empty( $context ) )
     3665        add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    36553666
    36563667    if ( $update) {
Note: See TracChangeset for help on using the changeset viewer.