From f02e878bb0d2634eb5d1f022ca438824bb3e5448 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 10 Jun 2014 19:14:26 +0000 Subject: [PATCH] Only include relevant post authors in WXR exports. Fixes #20206. Props jeremyfelt. git-svn-id: https://develop.svn.wordpress.org/trunk@28731 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/export.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/export.php b/src/wp-admin/includes/export.php index 5ca5e12526..91ecf793cf 100644 --- a/src/wp-admin/includes/export.php +++ b/src/wp-admin/includes/export.php @@ -240,12 +240,21 @@ function export_wp( $args = array() ) { * Output list of authors with posts * * @since 3.1.0 + * + * @param array $post_ids Array of post IDs to filter the query by. Optional. */ - function wxr_authors_list() { + function wxr_authors_list( array $post_ids = null ) { global $wpdb; + if ( !empty( $post_ids ) ) { + $post_ids = array_map( 'absint', $post_ids ); + $and = 'AND ID IN ( ' . implode( ', ', $post_ids ) . ')'; + } else { + $and = ''; + } + $authors = array(); - $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft'" ); + $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" ); foreach ( (array) $results as $result ) $authors[] = get_userdata( $result->post_author ); @@ -344,7 +353,7 @@ function export_wp( $args = array() ) { - + term_id ?>slug; ?>parent ? $cats[$c->parent]->slug : ''; ?>