Make WordPress Core

Ticket #11243: xmlrpc.php.diff

File xmlrpc.php.diff, 1.2 KB (added by josephscott, 14 years ago)
  • xmlrpc.php

     
    612612
    613613                do_action('xmlrpc_call', 'wp.getPages');
    614614
    615                 $pages = get_posts( array('post_type' => 'page', 'post_status' => 'all', 'numberposts' => $num_pages) );
     615                $many_pages = get_posts( array('post_type' => 'page', 'post_status' => 'all', 'numberposts' => ( $num_pages * 3 ) ) );
    616616                $num_pages = count($pages);
    617617
     618                // Remove pages that are in the trash
     619                $pages = array( );
     620                foreach ( (array) $many_pages as $a_page ) {
     621                        if ( $a_page->post_status == 'trash' )
     622                                continue;
     623
     624                        $pages[] = $a_page;
     625                }
     626
     627                // Limit page count to the number requested
     628                $total_pages = count($pages);
     629                if ( $total_pages > $num_pages ) {
     630                        $pages = array_slice( $pages, 0, $num_pages - 1 );
     631                        $total_pages = $num_pages;
     632                }
     633
    618634                // If we have pages, put together their info.
    619                 if($num_pages >= 1) {
     635                if($total_pages >= 1) {
    620636                        $pages_struct = array();
    621637
    622                         for($i = 0; $i < $num_pages; $i++) {
     638                        for($i = 0; $i < $total_pages; $i++) {
    623639                                $page = wp_xmlrpc_server::wp_getPage(array(
    624640                                        $blog_id, $pages[$i]->ID, $username, $password
    625641                                ));