Changeset 6803

Show
Ignore:
Timestamp:
02/13/08 06:49:23 (9 months ago)
Author:
ryan
Message:

Use array keys instead of hard coded list when traversing post fields to sanitize. Props andy. fixes #5836

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/post.php

    r6777 r6803  
    697697 
    698698function sanitize_post($post, $context = 'display') { 
    699  
    700699    if ( 'raw' == $context ) 
    701700        return $post; 
    702701 
    703     // TODO: Use array keys instead of hard coded list 
    704     $fields = array('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_date', 'post_date_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'post_category'); 
    705  
    706     $do_object = false; 
    707702    if ( is_object($post) ) 
    708         $do_object = true; 
    709  
    710     foreach ( $fields as $field ) { 
    711         if ( $do_object ) 
     703        foreach ( array_keys(get_object_vars($post)) as $field ) 
    712704            $post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context); 
    713         else 
     705    else 
     706        foreach ( array_keys($post) as $field ) 
    714707            $post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context); 
    715     } 
    716708 
    717709    return $post;