Make WordPress Core

Changeset 28731


Ignore:
Timestamp:
06/10/2014 07:14:26 PM (10 years ago)
Author:
johnbillion
Message:

Only include relevant post authors in WXR exports. Fixes #20206. Props jeremyfelt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/export.php

    r28500 r28731  
    241241     *
    242242     * @since 3.1.0
    243      */
    244     function wxr_authors_list() {
     243     *
     244     * @param array $post_ids Array of post IDs to filter the query by. Optional.
     245     */
     246    function wxr_authors_list( array $post_ids = null ) {
    245247        global $wpdb;
    246248
     249        if ( !empty( $post_ids ) ) {
     250            $post_ids = array_map( 'absint', $post_ids );
     251            $and = 'AND ID IN ( ' . implode( ', ', $post_ids ) . ')';
     252        } else {
     253            $and = '';
     254        }
     255
    247256        $authors = array();
    248         $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft'" );
     257        $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" );
    249258        foreach ( (array) $results as $result )
    250259            $authors[] = get_userdata( $result->post_author );
     
    345354    <wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
    346355
    347 <?php wxr_authors_list(); ?>
     356<?php wxr_authors_list( $post_ids ); ?>
    348357
    349358<?php foreach ( $cats as $c ) : ?>
Note: See TracChangeset for help on using the changeset viewer.