diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php
index 397e9e7..f3b7a48 100644
a
|
b
|
function export_wp( $args = array() ) { |
29 | 29 | 'start_date' => false, 'end_date' => false, 'status' => false, |
30 | 30 | ); |
31 | 31 | $args = wp_parse_args( $args, $defaults ); |
| 32 | $get_attachments = false; |
32 | 33 | |
33 | 34 | /** |
34 | 35 | * Fires at the beginning of an export, before any headers are sent. |
… |
… |
function export_wp( $args = array() ) { |
53 | 54 | $args['content'] = 'post'; |
54 | 55 | |
55 | 56 | $where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $args['content'] ); |
| 57 | $get_attachments = true; |
56 | 58 | } else { |
57 | 59 | $post_types = get_post_types( array( 'can_export' => true ) ); |
58 | 60 | $esses = array_fill( 0, count($post_types), '%s' ); |
… |
… |
function export_wp( $args = array() ) { |
86 | 88 | // Grab a snapshot of post IDs, just in case it changes during the export. |
87 | 89 | $post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" ); |
88 | 90 | |
| 91 | if ( $get_attachments ) { |
| 92 | $attachments_parents = $post_ids; |
| 93 | |
| 94 | // fetch attachments, 20 posts at a time |
| 95 | while ( $next_posts = array_splice( $attachments_parents, 0, 20 ) ) { |
| 96 | $attachment_ids = $wpdb->get_col( "SELECT ID |
| 97 | FROM {$wpdb->posts} |
| 98 | WHERE {$wpdb->posts}.post_type ='attachment' |
| 99 | AND {$wpdb->posts}.post_parent IN (".implode(',', $post_ids).")" ); |
| 100 | |
| 101 | $thumbnails_ids = $wpdb->get_col( "SELECT meta_value |
| 102 | FROM {$wpdb->postmeta} |
| 103 | WHERE {$wpdb->postmeta}.post_id IN (".implode(',', $post_ids).") |
| 104 | AND {$wpdb->postmeta}.meta_key = '_thumbnail_id'" ); |
| 105 | |
| 106 | $post_ids = array_merge($post_ids, $attachment_ids, $thumbnails_ids); |
| 107 | } |
| 108 | |
| 109 | // remove posible duplicated ids |
| 110 | $post_ids = array_unique($post_ids); |
| 111 | } |
| 112 | |
89 | 113 | /* |
90 | 114 | * Get the requested terms ready, empty unless posts filtered by category |
91 | 115 | * or all content. |