From eb62aecbc3da169065324846fb3fa50548300898 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 10 Jun 2014 19:15:13 +0000 Subject: [PATCH] Only include relevant post authors in WXR exports. Fixes #20206. Props jeremyfelt. Built from https://develop.svn.wordpress.org/trunk@28731 git-svn-id: http://core.svn.wordpress.org/trunk@28545 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/export.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php index 5ca5e12526..91ecf793cf 100644 --- a/wp-admin/includes/export.php +++ b/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 : ''; ?>