Make WordPress Core

Changeset 30153


Ignore:
Timestamp:
11/01/2014 07:44:07 PM (10 years ago)
Author:
wonderboymusic
Message:

In wp_xmlrpc_server methods, for comprehensibility:

  • initialize arrays in loops, instead of overriding an uninitialized array each time
  • in ->blogger_getRecentPosts() and ->mw_getRecentPosts(), remove the extra loops by only setting one array

See #30224.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r30139 r30153  
    27642764        if ( $all_tags = get_tags() ) {
    27652765            foreach( (array) $all_tags as $tag ) {
     2766                $struct = array();
    27662767                $struct['tag_id']           = $tag->term_id;
    27672768                $struct['name']             = $tag->name;
     
    32213222            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    32223223
     3224        $comment = array();
    32233225        $comment['comment_post_ID'] = $post_id;
    32243226
     
    34843486            return new IXR_Error( 403, __( 'You are not allowed to update options.' ) );
    34853487
     3488        $option_names = array();
    34863489        foreach ( $options as $o_name => $o_value ) {
    34873490            $option_names[] = $o_name;
     
    36293632                    $supported = get_theme_support( 'post-formats' );
    36303633
     3634                    $data = array();
    36313635                    $data['all'] = $formats;
    36323636                    $data['supported'] = $supported[0];
     
    40754079        }
    40764080
     4081        $recent_posts = array();
    40774082        foreach ($posts_list as $entry) {
    40784083            if ( !current_user_can( 'edit_post', $entry['ID'] ) )
     
    40864091            $content .= wp_unslash($entry['post_content']);
    40874092
    4088             $struct[] = array(
     4093            $recent_posts[] = array(
    40894094                'userid' => $entry['post_author'],
    40904095                'dateCreated' => $post_date,
     
    40924097                'postid' => (string) $entry['ID'],
    40934098            );
    4094 
    4095         }
    4096 
    4097         $recent_posts = array();
    4098         for ( $j=0; $j<count($struct); $j++ ) {
    4099             array_push($recent_posts, $struct[$j]);
    41004099        }
    41014100
     
    51035102            return array();
    51045103
    5105         $struct = array();
     5104        $recent_posts = array();
    51065105        foreach ($posts_list as $entry) {
    51075106            if ( !current_user_can( 'edit_post', $entry['ID'] ) )
     
    51475146                $post_format = 'standard';
    51485147
    5149             $struct[] = array(
     5148            $recent_posts[] = array(
    51505149                'dateCreated' => $post_date,
    51515150                'userid' => $entry['post_author'],
     
    51755174                'date_modified_gmt' => $post_modified_gmt,
    51765175                'sticky' => ( $entry['post_type'] === 'post' && is_sticky( $entry['ID'] ) ),
     5176                'wp_post_thumbnail' => get_post_thumbnail_id( $entry['ID'] )
    51775177            );
    5178 
    5179             $entry_index = count( $struct ) - 1;
    5180             $struct[ $entry_index ][ 'wp_post_thumbnail' ] = get_post_thumbnail_id( $entry['ID'] );
    5181         }
    5182 
    5183         $recent_posts = array();
    5184         for ( $j=0; $j<count($struct); $j++ ) {
    5185             array_push($recent_posts, $struct[$j]);
    51865178        }
    51875179
     
    52175209        if ( $cats = get_categories(array('get' => 'all')) ) {
    52185210            foreach ( $cats as $cat ) {
     5211                $struct = array();
    52195212                $struct['categoryId'] = $cat->term_id;
    52205213                $struct['parentId'] = $cat->parent;
     
    54375430        if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) {
    54385431            foreach ( $cats as $cat ) {
     5432                $struct = array();
    54395433                $struct['categoryId'] = $cat->term_id;
    54405434                $struct['categoryName'] = $cat->name;
Note: See TracChangeset for help on using the changeset viewer.