Make WordPress Core

Changeset 5281


Ignore:
Timestamp:
04/17/2007 10:00:00 PM (18 years ago)
Author:
ryan
Message:

XML-RPC fixes to allow for empty/zero settings in various fields. Props Joseph Scott. fixes #4156

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r5279 r5281  
    940940        // one has been provided.
    941941        $post_name = "";
    942         if(!empty($content_struct["wp_slug"])) {
     942        if(isset($content_struct["wp_slug"])) {
    943943            $post_name = $content_struct["wp_slug"];
    944944        }
    945945
    946946        // Only use a password if one was given.
    947         if(!empty($content_struct["wp_password"])) {
     947        if(isset($content_struct["wp_password"])) {
    948948            $post_password = $content_struct["wp_password"];
    949949        }
     
    955955
    956956        // Only set the menu_order if it was provided.
    957         if(!empty($content_struct["wp_page_order"])) {
     957        if(isset($content_struct["wp_page_order"])) {
    958958            $menu_order = $content_struct["wp_page_order"];
    959959        }
     
    962962
    963963        // If an author id was provided then use it instead.
    964         if(!empty($content_struct["wp_author_id"])) {
     964        if(
     965            isset($content_struct["wp_author_id"])
     966            && ($user->ID != $content_struct["wp_author_id"])
     967        ) {
    965968            switch($post_type) {
    966969                case "post":
     
    990993      $post_more = $content_struct['mt_text_more'];
    991994
    992       $comment_status = (!isset($content_struct['mt_allow_comments'])) ?
    993         get_option('default_comment_status')
    994         : $content_struct['mt_allow_comments'];
    995 
    996       $ping_status = (!isset($content_struct['mt_allow_pings'])) ?
    997         get_option('default_ping_status')
    998         : $content_struct['mt_allow_pings'];
     995        if(isset($content_struct["mt_allow_comments"])) {
     996            switch((int) $content_struct["mt_allow_comments"]) {
     997                case 0:
     998                    $comment_status = "closed";
     999                    break;
     1000                case 1:
     1001                    $comment_status = "open";
     1002                    break;
     1003                default:
     1004                    $comment_status = get_option("default_comment_status");
     1005                    break;
     1006            }
     1007        }
     1008
     1009        if(isset($content_struct["mt_allow_pings"])) {
     1010            switch((int) $content_struct["mt_allow_pings"]) {
     1011                case 0:
     1012                    $ping_status = "closed";
     1013                    break;
     1014                case 1:
     1015                    $ping_status = "open";
     1016                    break;
     1017                default:
     1018                    $ping_status = get_option("default_ping_status");
     1019                    break;
     1020            }
     1021        }
    9991022
    10001023      if ($post_more) {
     
    10741097      }
    10751098
    1076       set_current_user(0, $user_login);
     1099        $user = set_current_user(0, $user_login);
    10771100
    10781101        // The post_type defaults to post, but could also be page.
     
    11031126        // Let WordPress manage slug if none was provided.
    11041127        $post_name = "";
    1105         if(!empty($content_struct["wp_slug"])) {
     1128        if(isset($content_struct["wp_slug"])) {
    11061129            $post_name = $content_struct["wp_slug"];
    11071130        }
    11081131
    11091132        // Only use a password if one was given.
    1110         if(!empty($content_struct["wp_password"])) {
     1133        if(isset($content_struct["wp_password"])) {
    11111134            $post_password = $content_struct["wp_password"];
    11121135        }
     
    11181141
    11191142        // Only set the menu_order if it was given.
    1120         if(!empty($content_struct["wp_page_order"])) {
     1143        if(isset($content_struct["wp_page_order"])) {
    11211144            $menu_order = $content_struct["wp_page_order"];
    11221145        }
    11231146
     1147        $post_author = $user->ID;
     1148
    11241149        // Only set the post_author if one is set.
    1125         if(!empty($content_struct["wp_author_id"])) {
     1150        if(
     1151            isset($content_struct["wp_author_id"])
     1152            && ($user->ID != $content_struct["wp_author_id"])
     1153        ) {
    11261154            switch($post_type) {
    11271155                case "post":
     
    11461174        // Only set ping_status if it was provided.
    11471175        if(isset($content_struct["mt_allow_pings"])) {
    1148             switch($content_struct["mt_allow_pings"]) {
    1149                 case "0":
     1176            switch((int) $content_struct["mt_allow_pings"]) {
     1177                case 0:
    11501178                    $ping_status = "closed";
    11511179                    break;
    1152                 case "1":
     1180                case 1:
    11531181                    $ping_status = "open";
    11541182                    break;
     
    11881216
    11891217      if(isset($content_struct["mt_allow_comments"])) {
    1190         $comment_status = $content_struct["mt_allow_comments"];
     1218        $comment_status = (int) $content_struct["mt_allow_comments"];
    11911219      }
    11921220     
Note: See TracChangeset for help on using the changeset viewer.