Make WordPress Core

Ticket #4079: draft-14.patch

File draft-14.patch, 2.1 KB (added by eliast, 20 years ago)
  • app.php

     
    261261
    262262        var $ATOM_CONTENT_TYPE = 'application/atom+xml';
    263263        var $CATEGORIES_CONTENT_TYPE = 'application/atomcat+xml';
    264         var $INTROSPECTION_CONTENT_TYPE = 'application/atomserv+xml';
     264        var $INTROSPECTION_CONTENT_TYPE = 'application/atomsvc+xml';
    265265
    266266        var $ENTRIES_PATH = "posts";
    267267        var $CATEGORIES_PATH = "categories";
    … …  
    409409                }
    410410
    411411                $entry = $parser->entry;
     412    $catnames = array();
     413    foreach($entry->categories as $cat)
     414      array_push($catnames, $cat["term"]);
     415   
     416    $wp_cats = get_categories(array('hide_empty' => false));
    412417
     418    $post_categories = array();
     419
     420    foreach($wp_cats as $cat) {
     421      if(in_array($cat->cat_name, $catnames))
     422        array_push($post_categories, $cat->cat_ID);
     423    }
     424
    413425                $publish = (isset($entry->draft) && trim($entry->draft) == 'yes') ? false : true;
    414426
    415427                $cap = ($publish) ? 'publish_posts' : 'edit_posts';
    … …  
    425437                $post_excerpt = $entry->summary;
    426438                $post_date = current_time('mysql');
    427439                $post_date_gmt = current_time('mysql', 1);
     440                if ( isset( $_SERVER['HTTP_SLUG'] ) )
     441                        $post_name = $_SERVER['HTTP_SLUG'];
    428442
    429                 $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt');
     443                $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_name');
    430444
    431445                log_app('Inserting Post. Data:', print_r($post_data,true));
    432446
    … …  
    436450                        $this->internal_error('Sorry, your entry could not be posted. Something wrong happened.');
    437451                }
    438452
     453    // getting warning here about unable to set headers
     454    // because something in the cache is printing to the buffer
     455    // could we clean up wp_set_post_categories or cache to not print
     456    // this could affect our ability to send back the right headers
     457    @wp_set_post_categories($postID, $post_categories);
     458
    439459                $output = $this->get_entry($postID);
    440460
    441461                log_app('function',"create_post($postID)");