Make WordPress Core


Ignore:
Timestamp:
05/06/2011 07:51:47 PM (15 years ago)
Author:
ryan
Message:

Use static strings. Props niallkennedy. fixes #17169

File:
1 edited

Legend:

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

    r17771 r17823  
    476476
    477477                // If we found the page then format the data.
    478                 if ( $page->ID && ($page->post_type == "page") ) {
     478                if ( $page->ID && ($page->post_type == 'page') ) {
    479479                        // Get all of the page content and link.
    480480                        $full_page = get_extended($page->post_content);
     
    493493
    494494                        // Format page date.
    495                         $page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false);
    496                         $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false);
     495                        $page_date = mysql2date('Ymd\TH:i:s', $page->post_date, false);
     496                        $page_date_gmt = mysql2date('Ymd\TH:i:s', $page->post_date_gmt, false);
    497497
    498498                        // For drafts use the GMT version of the date
     
    514514
    515515                        $page_struct = array(
    516                                 "dateCreated"                   => new IXR_Date($page_date),
    517                                 "userid"                                => $page->post_author,
    518                                 "page_id"                               => $page->ID,
    519                                 "page_status"                   => $page->post_status,
    520                                 "description"                   => $full_page["main"],
    521                                 "title"                                 => $page->post_title,
    522                                 "link"                                  => $link,
    523                                 "permaLink"                             => $link,
    524                                 "categories"                    => $categories,
    525                                 "excerpt"                               => $page->post_excerpt,
    526                                 "text_more"                             => $full_page["extended"],
    527                                 "mt_allow_comments"             => $allow_comments,
    528                                 "mt_allow_pings"                => $allow_pings,
    529                                 "wp_slug"                               => $page->post_name,
    530                                 "wp_password"                   => $page->post_password,
    531                                 "wp_author"                             => $author->display_name,
    532                                 "wp_page_parent_id"             => $page->post_parent,
    533                                 "wp_page_parent_title"  => $parent_title,
    534                                 "wp_page_order"                 => $page->menu_order,
    535                                 "wp_author_id"                  => $author->ID,
    536                                 "wp_author_display_name"        => $author->display_name,
    537                                 "date_created_gmt"              => new IXR_Date($page_date_gmt),
    538                                 "custom_fields"                 => $this->get_custom_fields($page_id),
    539                                 "wp_page_template"              => $page_template
     516                                'dateCreated'                   => new IXR_Date($page_date),
     517                                'userid'                                => $page->post_author,
     518                                'page_id'                               => $page->ID,
     519                                'page_status'                   => $page->post_status,
     520                                'description'                   => $full_page['main'],
     521                                'title'                                 => $page->post_title,
     522                                'link'                                  => $link,
     523                                'permaLink'                             => $link,
     524                                'categories'                    => $categories,
     525                                'excerpt'                               => $page->post_excerpt,
     526                                'text_more'                             => $full_page['extended'],
     527                                'mt_allow_comments'             => $allow_comments,
     528                                'mt_allow_pings'                => $allow_pings,
     529                                'wp_slug'                               => $page->post_name,
     530                                'wp_password'                   => $page->post_password,
     531                                'wp_author'                             => $author->display_name,
     532                                'wp_page_parent_id'             => $page->post_parent,
     533                                'wp_page_parent_title'  => $parent_title,
     534                                'wp_page_order'                 => $page->menu_order,
     535                                'wp_author_id'                  => $author->ID,
     536                                'wp_author_display_name'        => $author->display_name,
     537                                'date_created_gmt'              => new IXR_Date($page_date_gmt),
     538                                'custom_fields'                 => $this->get_custom_fields($page_id),
     539                                'wp_page_template'              => $page_template
    540540                        );
    541541
     
    544544                // If the page doesn't exist indicate that.
    545545                else {
    546                         return(new IXR_Error(404, __("Sorry, no such page.")));
     546                        return(new IXR_Error(404, __('Sorry, no such page.')));
    547547                }
    548548        }
     
    619619
    620620                // Make sure the user is allowed to add new pages.
    621                 if ( !current_user_can("publish_pages") )
    622                         return(new IXR_Error(401, __("Sorry, you cannot add new pages.")));
     621                if ( !current_user_can('publish_pages') )
     622                        return(new IXR_Error(401, __('Sorry, you cannot add new pages.')));
    623623
    624624                // Mark this as content for a page.
    625                 $args[3]["post_type"] = "page";
     625                $args[3]["post_type"] = 'page';
    626626
    627627                // Let mw_newPost do all of the heavy lifting.
     
    653653                // make sure it is a page and not a post.
    654654                $actual_page = wp_get_single_post($page_id, ARRAY_A);
    655                 if ( !$actual_page || ($actual_page["post_type"] != "page") )
    656                         return(new IXR_Error(404, __("Sorry, no such page.")));
     655                if ( !$actual_page || ($actual_page['post_type'] != 'page') )
     656                        return(new IXR_Error(404, __('Sorry, no such page.')));
    657657
    658658                // Make sure the user can delete pages.
    659                 if ( !current_user_can("delete_page", $page_id) )
    660                         return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page.")));
     659                if ( !current_user_can('delete_page', $page_id) )
     660                        return(new IXR_Error(401, __('Sorry, you do not have the right to delete this page.')));
    661661
    662662                // Attempt to delete the page.
    663663                $result = wp_delete_post($page_id);
    664664                if ( !$result )
    665                         return(new IXR_Error(500, __("Failed to delete the page.")));
     665                        return(new IXR_Error(500, __('Failed to delete the page.')));
    666666
    667667                return(true);
     
    692692                // Get the page data and make sure it is a page.
    693693                $actual_page = wp_get_single_post($page_id, ARRAY_A);
    694                 if ( !$actual_page || ($actual_page["post_type"] != "page") )
    695                         return(new IXR_Error(404, __("Sorry, no such page.")));
     694                if ( !$actual_page || ($actual_page['post_type'] != 'page') )
     695                        return(new IXR_Error(404, __('Sorry, no such page.')));
    696696
    697697                // Make sure the user is allowed to edit pages.
    698                 if ( !current_user_can("edit_page", $page_id) )
    699                         return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page.")));
     698                if ( !current_user_can('edit_page', $page_id) )
     699                        return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.')));
    700700
    701701                // Mark this as content for a page.
    702                 $content["post_type"] = "page";
     702                $content['post_type'] = 'page';
    703703
    704704                // Arrange args in the way mw_editPost understands.
     
    756756                $num_pages = count($page_list);
    757757                for ( $i = 0; $i < $num_pages; $i++ ) {
    758                         $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date, false);
    759                         $post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt, false);
     758                        $post_date = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date, false);
     759                        $post_date_gmt = mysql2date('Ymd\TH:i:s', $page_list[$i]->post_date_gmt, false);
    760760
    761761                        $page_list[$i]->dateCreated = new IXR_Date($post_date);
     
    795795                        return $this->error;
    796796
    797                 if ( !current_user_can("edit_posts") )
    798                         return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site.")));
     797                if ( !current_user_can('edit_posts') )
     798                        return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.')));
    799799
    800800                do_action('xmlrpc_call', 'wp.getAuthors');
     
    803803                foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) {
    804804                        $authors[] = array(
    805                                 "user_id"       => $user->ID,
    806                                 "user_login"    => $user->user_login,
    807                                 "display_name"  => $user->display_name
     805                                'user_id'       => $user->ID,
     806                                'user_login'    => $user->user_login,
     807                                'display_name'  => $user->display_name
    808808                        );
    809809                }
     
    875875
    876876                // Make sure the user is allowed to add a category.
    877                 if ( !current_user_can("manage_categories") )
    878                         return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
     877                if ( !current_user_can('manage_categories') )
     878                        return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.')));
    879879
    880880                // If no slug was provided make it empty so that
    881881                // WordPress will generate one.
    882                 if ( empty($category["slug"]) )
    883                         $category["slug"] = "";
     882                if ( empty($category['slug']) )
     883                        $category['slug'] = '';
    884884
    885885                // If no parent_id was provided make it empty
    886886                // so that it will be a top level page (no parent).
    887                 if ( !isset($category["parent_id"]) )
    888                         $category["parent_id"] = "";
     887                if ( !isset($category['parent_id']) )
     888                        $category['parent_id'] = '';
    889889
    890890                // If no description was provided make it empty.
     
    893893
    894894                $new_category = array(
    895                         "cat_name"                              => $category["name"],
    896                         "category_nicename"             => $category["slug"],
    897                         "category_parent"               => $category["parent_id"],
    898                         "category_description"  => $category["description"]
     895                        'cat_name'                              => $category['name'],
     896                        'category_nicename'             => $category['slug'],
     897                        'category_parent'               => $category['parent_id'],
     898                        'category_description'  => $category['description']
    899899                );
    900900
     
    904904                                return (int) $cat_id->get_error_data();
    905905                        else
    906                                 return(new IXR_Error(500, __("Sorry, the new category failed.")));
     906                                return(new IXR_Error(500, __('Sorry, the new category failed.')));
    907907                } elseif ( ! $cat_id ) {
    908                         return(new IXR_Error(500, __("Sorry, the new category failed.")));
     908                        return(new IXR_Error(500, __('Sorry, the new category failed.')));
    909909                }
    910910
     
    933933                do_action('xmlrpc_call', 'wp.deleteCategory');
    934934
    935                 if ( !current_user_can("manage_categories") )
    936                         return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) );
     935                if ( !current_user_can('manage_categories') )
     936                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) );
    937937
    938938                return wp_delete_term( $category_id, 'category' );
     
    968968                foreach ( (array) get_categories($args) as $cat ) {
    969969                        $category_suggestions[] = array(
    970                                 "category_id"   => $cat->term_id,
    971                                 "category_name" => $cat->name
     970                                'category_id'   => $cat->term_id,
     971                                'category_name' => $cat->name
    972972                        );
    973973                }
     
    10041004
    10051005                // Format page date.
    1006                 $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false);
    1007                 $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false);
     1006                $comment_date = mysql2date('Ymd\TH:i:s', $comment->comment_date, false);
     1007                $comment_date_gmt = mysql2date('Ymd\TH:i:s', $comment->comment_date_gmt, false);
    10081008
    10091009                if ( '0' == $comment->comment_approved )
     
    10191019
    10201020                $comment_struct = array(
    1021                         "date_created_gmt"              => new IXR_Date($comment_date_gmt),
    1022                         "user_id"                               => $comment->user_id,
    1023                         "comment_id"                    => $comment->comment_ID,
    1024                         "parent"                                => $comment->comment_parent,
    1025                         "status"                                => $comment_status,
    1026                         "content"                               => $comment->comment_content,
    1027                         "link"                                  => $link,
    1028                         "post_id"                               => $comment->comment_post_ID,
    1029                         "post_title"                    => get_the_title($comment->comment_post_ID),
    1030                         "author"                                => $comment->comment_author,
    1031                         "author_url"                    => $comment->comment_author_url,
    1032                         "author_email"                  => $comment->comment_author_email,
    1033                         "author_ip"                             => $comment->comment_author_IP,
    1034                         "type"                                  => $comment->comment_type,
     1021                        'date_created_gmt'              => new IXR_Date($comment_date_gmt),
     1022                        'user_id'                               => $comment->user_id,
     1023                        'comment_id'                    => $comment->comment_ID,
     1024                        'parent'                                => $comment->comment_parent,
     1025                        'status'                                => $comment_status,
     1026                        'content'                               => $comment->comment_content,
     1027                        'link'                                  => $link,
     1028                        'post_id'                               => $comment->comment_post_ID,
     1029                        'post_title'                    => get_the_title($comment->comment_post_ID),
     1030                        'author'                                => $comment->comment_author,
     1031                        'author_url'                    => $comment->comment_author_url,
     1032                        'author_email'                  => $comment->comment_author_email,
     1033                        'author_ip'                             => $comment->comment_author_IP,
     1034                        'type'                                  => $comment->comment_type,
    10351035                );
    10361036
     
    13741374                $count = wp_count_comments( $post_id );
    13751375                return array(
    1376                         "approved" => $count->approved,
    1377                         "awaiting_moderation" => $count->moderated,
    1378                         "spam" => $count->spam,
    1379                         "total_comments" => $count->total_comments
     1376                        'approved' => $count->approved,
     1377                        'awaiting_moderation' => $count->moderated,
     1378                        'spam' => $count->spam,
     1379                        'total_comments' => $count->total_comments
    13801380                );
    13811381        }
     
    15871587
    15881588                // Format page date.
    1589                 $attachment_date = mysql2date("Ymd\TH:i:s", $attachment->post_date, false);
    1590                 $attachment_date_gmt = mysql2date("Ymd\TH:i:s", $attachment->post_date_gmt, false);
     1589                $attachment_date = mysql2date('Ymd\TH:i:s', $attachment->post_date, false);
     1590                $attachment_date_gmt = mysql2date('Ymd\TH:i:s', $attachment->post_date_gmt, false);
    15911591
    15921592                $link = wp_get_attachment_url($attachment->ID);
     
    15941594
    15951595                $attachment_struct = array(
    1596                         "date_created_gmt"              => new IXR_Date($attachment_date_gmt),
    1597                         "parent"                                => $attachment->post_parent,
    1598                         "link"                                  => $link,
    1599                         "thumbnail"                             => $thumbnail_link,
    1600                         "title"                                 => $attachment->post_title,
    1601                         "caption"                               => $attachment->post_excerpt,
    1602                         "description"                   => $attachment->post_content,
    1603                         "metadata"                              => wp_get_attachment_metadata($attachment->ID),
     1596                        'date_created_gmt'              => new IXR_Date($attachment_date_gmt),
     1597                        'parent'                                => $attachment->post_parent,
     1598                        'link'                                  => $link,
     1599                        'thumbnail'                             => $thumbnail_link,
     1600                        'title'                                 => $attachment->post_title,
     1601                        'caption'                               => $attachment->post_excerpt,
     1602                        'description'                   => $attachment->post_content,
     1603                        'metadata'                              => wp_get_attachment_metadata($attachment->ID),
    16041604                );
    16051605
     
    22442244                // one has been provided.
    22452245                $post_name = "";
    2246                 if ( isset($content_struct["wp_slug"]) )
    2247                         $post_name = $content_struct["wp_slug"];
     2246                if ( isset($content_struct['wp_slug']) )
     2247                        $post_name = $content_struct['wp_slug'];
    22482248
    22492249                // Only use a password if one was given.
    2250                 if ( isset($content_struct["wp_password"]) )
    2251                         $post_password = $content_struct["wp_password"];
     2250                if ( isset($content_struct['wp_password']) )
     2251                        $post_password = $content_struct['wp_password'];
    22522252
    22532253                // Only set a post parent if one was provided.
    2254                 if ( isset($content_struct["wp_page_parent_id"]) )
    2255                         $post_parent = $content_struct["wp_page_parent_id"];
     2254                if ( isset($content_struct['wp_page_parent_id']) )
     2255                        $post_parent = $content_struct['wp_page_parent_id'];
    22562256
    22572257                // Only set the menu_order if it was provided.
    2258                 if ( isset($content_struct["wp_page_order"]) )
    2259                         $menu_order = $content_struct["wp_page_order"];
     2258                if ( isset($content_struct['wp_page_order']) )
     2259                        $menu_order = $content_struct['wp_page_order'];
    22602260
    22612261                $post_author = $user->ID;
    22622262
    22632263                // If an author id was provided then use it instead.
    2264                 if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {
     2264                if ( isset($content_struct['wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) {
    22652265                        switch ( $post_type ) {
    22662266                                case "post":
    2267                                         if ( !current_user_can("edit_others_posts") )
    2268                                                 return(new IXR_Error(401, __("You are not allowed to post as this user")));
     2267                                        if ( !current_user_can('edit_others_posts') )
     2268                                                return(new IXR_Error(401, __('You are not allowed to post as this user')));
    22692269                                        break;
    22702270                                case "page":
    2271                                         if ( !current_user_can("edit_others_pages") )
    2272                                                 return(new IXR_Error(401, __("You are not allowed to create pages as this user")));
     2271                                        if ( !current_user_can('edit_others_pages') )
     2272                                                return(new IXR_Error(401, __('You are not allowed to create pages as this user')));
    22732273                                        break;
    22742274                                default:
    2275                                         return(new IXR_Error(401, __("Invalid post type.")));
     2275                                        return(new IXR_Error(401, __('Invalid post type.')));
    22762276                                        break;
    22772277                        }
    2278                         $post_author = $content_struct["wp_author_id"];
     2278                        $post_author = $content_struct['wp_author_id'];
    22792279                }
    22802280
     
    23032303                $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null;
    23042304
    2305                 if ( isset($content_struct["mt_allow_comments"]) ) {
    2306                         if ( !is_numeric($content_struct["mt_allow_comments"]) ) {
    2307                                 switch ( $content_struct["mt_allow_comments"] ) {
    2308                                         case "closed":
    2309                                                 $comment_status = "closed";
     2305                if ( isset($content_struct['mt_allow_comments']) ) {
     2306                        if ( !is_numeric($content_struct['mt_allow_comments']) ) {
     2307                                switch ( $content_struct['mt_allow_comments'] ) {
     2308                                        case 'closed':
     2309                                                $comment_status = 'closed';
    23102310                                                break;
    2311                                         case "open":
    2312                                                 $comment_status = "open";
     2311                                        case 'open':
     2312                                                $comment_status = 'open';
    23132313                                                break;
    23142314                                        default:
    2315                                                 $comment_status = get_option("default_comment_status");
     2315                                                $comment_status = get_option('default_comment_status');
    23162316                                                break;
    23172317                                }
    23182318                        } else {
    2319                                 switch ( (int) $content_struct["mt_allow_comments"] ) {
     2319                                switch ( (int) $content_struct['mt_allow_comments'] ) {
    23202320                                        case 0:
    23212321                                        case 2:
    2322                                                 $comment_status = "closed";
     2322                                                $comment_status = 'closed';
    23232323                                                break;
    23242324                                        case 1:
    2325                                                 $comment_status = "open";
     2325                                                $comment_status = 'open';
    23262326                                                break;
    23272327                                        default:
    2328                                                 $comment_status = get_option("default_comment_status");
     2328                                                $comment_status = get_option('default_comment_status');
    23292329                                                break;
    23302330                                }
    23312331                        }
    23322332                } else {
    2333                         $comment_status = get_option("default_comment_status");
    2334                 }
    2335 
    2336                 if ( isset($content_struct["mt_allow_pings"]) ) {
    2337                         if ( !is_numeric($content_struct["mt_allow_pings"]) ) {
     2333                        $comment_status = get_option('default_comment_status');
     2334                }
     2335
     2336                if ( isset($content_struct['mt_allow_pings']) ) {
     2337                        if ( !is_numeric($content_struct['mt_allow_pings']) ) {
    23382338                                switch ( $content_struct['mt_allow_pings'] ) {
    2339                                         case "closed":
    2340                                                 $ping_status = "closed";
     2339                                        case 'closed':
     2340                                                $ping_status = 'closed';
    23412341                                                break;
    2342                                         case "open":
    2343                                                 $ping_status = "open";
     2342                                        case 'open':
     2343                                                $ping_status = 'open';
    23442344                                                break;
    23452345                                        default:
    2346                                                 $ping_status = get_option("default_ping_status");
     2346                                                $ping_status = get_option('default_ping_status');
    23472347                                                break;
    23482348                                }
    23492349                        } else {
    2350                                 switch ( (int) $content_struct["mt_allow_pings"] ) {
     2350                                switch ( (int) $content_struct['mt_allow_pings'] ) {
    23512351                                        case 0:
    2352                                                 $ping_status = "closed";
     2352                                                $ping_status = 'closed';
    23532353                                                break;
    23542354                                        case 1:
    2355                                                 $ping_status = "open";
     2355                                                $ping_status = 'open';
    23562356                                                break;
    23572357                                        default:
    2358                                                 $ping_status = get_option("default_ping_status");
     2358                                                $ping_status = get_option('default_ping_status');
    23592359                                                break;
    23602360                                }
    23612361                        }
    23622362                } else {
    2363                         $ping_status = get_option("default_ping_status");
     2363                        $ping_status = get_option('default_ping_status');
    23642364                }
    23652365
    23662366                if ( $post_more )
    2367                         $post_content = $post_content . "<!--more-->" . $post_more;
     2367                        $post_content = $post_content . '<!--more-->' . $post_more;
    23682368
    23692369                $to_ping = null;
     
    25522552                // created (which was the old behavior).
    25532553                if ( empty($postdata["ID"]) )
    2554                         return(new IXR_Error(404, __("Invalid post ID.")));
     2554                        return(new IXR_Error(404, __('Invalid post ID.')));
    25552555
    25562556                $this->escape($postdata);
     
    25602560                $post_name = "";
    25612561                $post_name = $postdata['post_name'];
    2562                 if ( isset($content_struct["wp_slug"]) )
    2563                         $post_name = $content_struct["wp_slug"];
     2562                if ( isset($content_struct['wp_slug']) )
     2563                        $post_name = $content_struct['wp_slug'];
    25642564
    25652565                // Only use a password if one was given.
    2566                 if ( isset($content_struct["wp_password"]) )
    2567                         $post_password = $content_struct["wp_password"];
     2566                if ( isset($content_struct['wp_password']) )
     2567                        $post_password = $content_struct['wp_password'];
    25682568
    25692569                // Only set a post parent if one was given.
    2570                 if ( isset($content_struct["wp_page_parent_id"]) )
    2571                         $post_parent = $content_struct["wp_page_parent_id"];
     2570                if ( isset($content_struct['wp_page_parent_id']) )
     2571                        $post_parent = $content_struct['wp_page_parent_id'];
    25722572
    25732573                // Only set the menu_order if it was given.
    2574                 if ( isset($content_struct["wp_page_order"]) )
    2575                         $menu_order = $content_struct["wp_page_order"];
    2576 
    2577                 $post_author = $postdata["post_author"];
     2574                if ( isset($content_struct['wp_page_order']) )
     2575                        $menu_order = $content_struct['wp_page_order'];
     2576
     2577                $post_author = $postdata['post_author'];
    25782578
    25792579                // Only set the post_author if one is set.
    2580                 if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {
     2580                if ( isset($content_struct['wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) {
    25812581                        switch ( $post_type ) {
    2582                                 case "post":
    2583                                         if ( !current_user_can("edit_others_posts") )
    2584                                                 return(new IXR_Error(401, __("You are not allowed to change the post author as this user.")));
     2582                                case 'post':
     2583                                        if ( !current_user_can('edit_others_posts') )
     2584                                                return(new IXR_Error(401, __('You are not allowed to change the post author as this user.')));
    25852585                                        break;
    2586                                 case "page":
    2587                                         if ( !current_user_can("edit_others_pages") )
    2588                                                 return(new IXR_Error(401, __("You are not allowed to change the page author as this user.")));
     2586                                case 'page':
     2587                                        if ( !current_user_can('edit_others_pages') )
     2588                                                return(new IXR_Error(401, __('You are not allowed to change the page author as this user.')));
    25892589                                        break;
    25902590                                default:
    2591                                         return(new IXR_Error(401, __("Invalid post type.")));
     2591                                        return(new IXR_Error(401, __('Invalid post type.')));
    25922592                                        break;
    25932593                        }
    2594                         $post_author = $content_struct["wp_author_id"];
    2595                 }
    2596 
    2597                 if ( isset($content_struct["mt_allow_comments"]) ) {
    2598                         if ( !is_numeric($content_struct["mt_allow_comments"]) ) {
    2599                                 switch ( $content_struct["mt_allow_comments"] ) {
    2600                                         case "closed":
    2601                                                 $comment_status = "closed";
     2594                        $post_author = $content_struct['wp_author_id'];
     2595                }
     2596
     2597                if ( isset($content_struct['mt_allow_comments']) ) {
     2598                        if ( !is_numeric($content_struct['mt_allow_comments']) ) {
     2599                                switch ( $content_struct['mt_allow_comments'] ) {
     2600                                        case 'closed':
     2601                                                $comment_status = 'closed';
    26022602                                                break;
    2603                                         case "open":
    2604                                                 $comment_status = "open";
     2603                                        case 'open':
     2604                                                $comment_status = 'open';
    26052605                                                break;
    26062606                                        default:
    2607                                                 $comment_status = get_option("default_comment_status");
     2607                                                $comment_status = get_option('default_comment_status');
    26082608                                                break;
    26092609                                }
    26102610                        } else {
    2611                                 switch ( (int) $content_struct["mt_allow_comments"] ) {
     2611                                switch ( (int) $content_struct['mt_allow_comments'] ) {
    26122612                                        case 0:
    26132613                                        case 2:
    2614                                                 $comment_status = "closed";
     2614                                                $comment_status = 'closed';
    26152615                                                break;
    26162616                                        case 1:
    2617                                                 $comment_status = "open";
     2617                                                $comment_status = 'open';
    26182618                                                break;
    26192619                                        default:
    2620                                                 $comment_status = get_option("default_comment_status");
     2620                                                $comment_status = get_option('default_comment_status');
    26212621                                                break;
    26222622                                }
     
    26242624                }
    26252625
    2626                 if ( isset($content_struct["mt_allow_pings"]) ) {
    2627                         if ( !is_numeric($content_struct["mt_allow_pings"]) ) {
    2628                                 switch ( $content_struct["mt_allow_pings"] ) {
    2629                                         case "closed":
    2630                                                 $ping_status = "closed";
     2626                if ( isset($content_struct['mt_allow_pings']) ) {
     2627                        if ( !is_numeric($content_struct['mt_allow_pings']) ) {
     2628                                switch ( $content_struct['mt_allow_pings'] ) {
     2629                                        case 'closed':
     2630                                                $ping_status = 'closed';
    26312631                                                break;
    2632                                         case "open":
    2633                                                 $ping_status = "open";
     2632                                        case 'open':
     2633                                                $ping_status = 'open';
    26342634                                                break;
    26352635                                        default:
    2636                                                 $ping_status = get_option("default_ping_status");
     2636                                                $ping_status = get_option('default_ping_status');
    26372637                                                break;
    26382638                                }
     
    26402640                                switch ( (int) $content_struct["mt_allow_pings"] ) {
    26412641                                        case 0:
    2642                                                 $ping_status = "closed";
     2642                                                $ping_status = 'closed';
    26432643                                                break;
    26442644                                        case 1:
    2645                                                 $ping_status = "open";
     2645                                                $ping_status = 'open';
    26462646                                                break;
    26472647                                        default:
    2648                                                 $ping_status = get_option("default_ping_status");
     2648                                                $ping_status = get_option('default_ping_status');
    26492649                                                break;
    26502650                                }
     
    30633063                }
    30643064
    3065                 if ( $upload_err = apply_filters( "pre_upload_error", false ) )
     3065                if ( $upload_err = apply_filters( 'pre_upload_error', false ) )
    30663066                        return new IXR_Error(500, $upload_err);
    30673067
    3068                 if ( !empty($data["overwrite"]) && ($data["overwrite"] == true) ) {
     3068                if ( !empty($data['overwrite']) && ($data['overwrite'] == true) ) {
    30693069                        // Get postmeta info on the object.
    30703070                        $old_file = $wpdb->get_row("
     
    30803080                        // Make sure the new name is different by pre-pending the
    30813081                        // previous post id.
    3082                         $filename = preg_replace("/^wpid\d+-/", "", $name);
     3082                        $filename = preg_replace('/^wpid\d+-/', '', $name);
    30833083                        $name = "wpid{$old_file->ID}-{$filename}";
    30843084                }
Note: See TracChangeset for help on using the changeset viewer.