Ticket #17379: export_attachments_for_cpt.diff
File export_attachments_for_cpt.diff, 1.3 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/export.php
32 32 33 33 do_action( 'export_wp' ); 34 34 35 $get_attachments = false; 36 35 37 $sitename = sanitize_key( get_bloginfo( 'name' ) ); 36 38 if ( ! empty($sitename) ) $sitename .= '.'; 37 39 $filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml'; … … 46 48 $args['content'] = 'post'; 47 49 48 50 $where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $args['content'] ); 51 $get_attachments = true; 49 52 } else { 50 53 $post_types = get_post_types( array( 'can_export' => true ) ); 51 54 $esses = array_fill( 0, count($post_types), '%s' ); … … 79 82 // grab a snapshot of post IDs, just in case it changes during the export 80 83 $post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" ); 81 84 85 if ( $get_attachments ) { 86 $attachment_ids = $wpdb->get_col( "SELECT ID 87 FROM {$wpdb->posts} 88 WHERE {$wpdb->posts}.post_type ='attachment' 89 AND {$wpdb->posts}.post_parent IN (".implode(',', $post_ids).")" ); 90 $post_ids = array_merge($post_ids, $attachment_ids); 91 } 92 82 93 // get the requested terms ready, empty unless posts filtered by category or all content 83 94 $cats = $tags = $terms = array(); 84 95 if ( isset( $term ) && $term ) {