Changeset 57681
- Timestamp:
- 02/21/2024 06:13:27 PM (9 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/export.php
r55942 r57681 144 144 // Grab a snapshot of post IDs, just in case it changes during the export. 145 145 $post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" ); 146 147 // Get IDs for the attachments of each post, unless all content is already being exported. 148 if ( ! in_array( $args['content'], array( 'all', 'attachment' ), true ) ) { 149 // Array to hold all additional IDs (attachments and thumbnails). 150 $additional_ids = array(); 151 152 // Create a copy of the post IDs array to avoid modifying the original array. 153 $processing_ids = $post_ids; 154 155 while ( $next_posts = array_splice( $processing_ids, 0, 20 ) ) { 156 $posts_in = array_map( 'absint', $next_posts ); 157 $placeholders = array_fill( 0, count( $posts_in ), '%d' ); 158 159 // Create a string for the placeholders. 160 $in_placeholder = implode( ',', $placeholders ); 161 162 // Prepare the SQL statement for attachment ids. 163 $attachment_ids = $wpdb->get_col( 164 $wpdb->prepare( 165 " 166 SELECT ID 167 FROM $wpdb->posts 168 WHERE post_parent IN ($in_placeholder) AND post_type = 'attachment' 169 ", 170 $posts_in 171 ) 172 ); 173 174 $thumbnails_ids = $wpdb->get_col( 175 $wpdb->prepare( 176 " 177 SELECT meta_value 178 FROM $wpdb->postmeta 179 WHERE $wpdb->postmeta.post_id IN ($in_placeholder) 180 AND $wpdb->postmeta.meta_key = '_thumbnail_id' 181 ", 182 $posts_in 183 ) 184 ); 185 186 $additional_ids = array_merge( $additional_ids, $attachment_ids, $thumbnails_ids ); 187 } 188 189 // Merge the additional IDs back with the original post IDs after processing all posts 190 $post_ids = array_unique( array_merge( $post_ids, $additional_ids ) ); 191 } 146 192 147 193 /*
Note: See TracChangeset
for help on using the changeset viewer.