WordPress.org

Make WordPress Core

Ticket #14058: 3.0.1-export.diff

File 3.0.1-export.diff, 2.6 KB (added by yoavf, 8 years ago)
  • wp-admin/export.php

     
    9999<select name="author" id="author">
    100100<option value="all" selected="selected"><?php _e('All Authors'); ?></option>
    101101<?php
    102 $authors = $wpdb->get_results( "SELECT DISTINCT u.id, u.display_name FROM $wpdb->users u INNER JOIN $wpdb->posts p WHERE u.id = p.post_author ORDER BY u.display_name" );
    103 foreach ( (array) $authors as $author ) {
    104         echo "<option value='{$author->id}'>{$author->display_name}</option>\n";
     102$authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
     103foreach ( $authors as $id ) {
     104        $o = get_userdata( $id );
     105        echo "<option value='" . esc_attr($o->ID) . "'>$o->display_name</option>";
    105106}
    106107?>
    107108</select>
     
    146147
    147148
    148149include ('admin-footer.php');
    149 ?>
     150?>
     151 No newline at end of file
  • wp-admin/includes/export.php

     
    6262                $where .= $wpdb->prepare( "AND post_date < %s ", $end_date );
    6363
    6464        if ( $taxonomy && is_array( $taxonomy ) ) {
    65                 foreach ( $taxonomy as $term_id ) {
    66                         if ( $term_id != 'all' )
    67                                 $where .= $wpdb->prepare( "AND ID IN (SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d) ", $term_id );
     65                $post_ids_from_taxonomies  = array();
     66                foreach ( $taxonomy as $tax => $term_id ) {
     67                        if ( $term_id != 'all' )
     68                                $post_ids_from_taxonomies = array_merge( $post_ids_from_taxonomies, get_objects_in_term( $term_id, $tax ) );
    6869                }
    6970        }
    70 
    7171        if ( $post_status && $post_status != 'all' )
    7272                $where .= $wpdb->prepare( "AND post_status = %s", $status );
    7373
    7474        // grab a snapshot of post IDs, just in case it changes during the export
    7575        $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC" );
    76 
     76        if ( !empty( $post_ids_from_taxonomies ) )
     77                $post_ids = array_intersect( $post_ids_from_taxonomies, $post_ids );
     78               
    7779        $categories = (array) get_categories( array( 'get' => 'all' ) );
    7880        $tags = (array) get_tags( array( 'get' => 'all' ) );
    7981
     
    330332        while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) {
    331333        $where = "WHERE ID IN (" . join( ',', $next_posts ) . ")";
    332334        $posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC" );
    333 
     335       
    334336        // Begin Loop
    335337        foreach ($posts as $post) {
    336338        setup_postdata( $post );
     
    406408<?php
    407409}
    408410
    409 ?>
     411?>
     412 No newline at end of file