WordPress.org

Make WordPress Core

Ticket #14757: 14757.3.diff

File 14757.3.diff, 1.9 KB (added by logiclord, 7 years ago)

specific capability test. Still needs testing.

  • .php

    diff --git a/export_old.php b/export_new.php
    index 2efd040..52c7422 100644
    old new function export_wp( $args = array() ) { 
    237237                global $wpdb;
    238238
    239239                $authors = array();
    240                 $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" );
     240            $results = get_users('blog_id='.$GLOBALS['blog_id']);
    241241                foreach ( (array) $results as $result )
    242                         $authors[] = get_userdata( $result->post_author );
     242                        $authors[] = get_userdata( $result->ID );
    243243
    244244                $authors = array_filter( $authors );
    245 
     245               
    246246                foreach( $authors as $author ) {
    247                         echo "\t<wp:author>";
    248                         echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
    249                         echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
    250                         echo '<wp:author_email>' . $author->user_email . '</wp:author_email>';
    251                         echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
    252                         echo '<wp:author_first_name>' . wxr_cdata( $author->user_firstname ) . '</wp:author_first_name>';
    253                         echo '<wp:author_last_name>' . wxr_cdata( $author->user_lastname ) . '</wp:author_last_name>';
    254                         echo "</wp:author>\n"; 
     247       
     248                        if( isset( $author->wp_capabilities['editor'] )|| isset( $author->wp_capabilities['author'] ) || isset( $author->wp_capabilities['administrator'] ) || isset( $author->wp_capabilities['contributor'] ) )       {
     249                                echo "\t<wp:author>";
     250                                echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
     251                                echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
     252                                echo '<wp:author_email>' . $author->user_email . '</wp:author_email>';
     253                                echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
     254                                echo '<wp:author_first_name>' . wxr_cdata( $author->user_firstname ) . '</wp:author_first_name>';
     255                                echo '<wp:author_last_name>' . wxr_cdata( $author->user_lastname ) . '</wp:author_last_name>';
     256                                echo "</wp:author>\n";
     257                        }
    255258                }
    256259        }
    257260