WordPress.org

Make WordPress Core

Ticket #10801: 10801.diff

File 10801.diff, 876 bytes (added by ryan, 6 years ago)

Check filter before sanitizing. Untested.

  • wp-includes/post.php

     
    821821 */ 
    822822function sanitize_post($post, $context = 'display') { 
    823823        if ( is_object($post) ) { 
     824                // Is post already filtered for this context. 
     825                if ( isset($post->filter) && $context == $post->filter ) 
     826                        return $post; 
     827 
    824828                if ( !isset($post->ID) ) 
    825829                        $post->ID = 0; 
    826830                foreach ( array_keys(get_object_vars($post)) as $field ) 
    827831                        $post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context); 
    828832                $post->filter = $context; 
    829833        } else { 
     834                // Is post already filtered for this context. 
     835                if ( isset($post['filter']) && $context == $post['filter'] ) 
     836                        return $post; 
     837 
    830838                if ( !isset($post['ID']) ) 
    831839                        $post['ID'] = 0; 
    832840                foreach ( array_keys($post) as $field )