Make WordPress Core

Changeset 3200


Ignore:
Timestamp:
11/23/2005 01:35:08 AM (19 years ago)
Author:
ryan
Message:

Allow wp_insert/update_post to handle classes in addition to associative arrays. This should avoid the 'Cannot use object of type stdClass as array' warnings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-post.php

    r3190 r3200  
    88function wp_insert_post($postarr = array()) {
    99    global $wpdb, $allowedtags, $user_ID;
     10
     11    if ( is_object($postarr) )
     12        $postarr = get_object_vars($postarr);
    1013
    1114    // export array as variables
     
    197200function wp_insert_attachment($object, $file, $post_parent = 0) {
    198201    global $wpdb, $user_ID;
     202
     203    if ( is_object($object) )
     204        $object = get_object_vars($object);
    199205   
    200206    // Export array as variables
     
    222228    $post_status = 'attachment';
    223229
    224     // Get the post ID.
    225     if ( $update )
    226         $post_ID = $ID;
     230    // Are we updating or creating?
     231    $update = false;
     232    if ( !empty($ID) ) {
     233        $update = true;
     234        $post_ID = $ID;
     235    }
    227236
    228237    // Create a valid post name.
     
    379388    global $wpdb;
    380389
     390    if ( is_object($postarr) )
     391        $postarr = get_object_vars($postarr);
     392
    381393    // First, get all of the original fields
    382394    $post = wp_get_single_post($postarr['ID'], ARRAY_A);   
Note: See TracChangeset for help on using the changeset viewer.