Ticket #12267: wp-post-patch-take-2.diff

File wp-post-patch-take-2.diff, 4.5 KB (added by toppa, 10 months ago)
  • wp-includes/post.php

     
    403403                        $_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id)); 
    404404                        if ( ! $_post ) 
    405405                                return $null; 
     406            $_post = WP_Post::get_instance($_post); 
    406407                        _get_post_ancestors($_post); 
    407408                        $_post = sanitize_post($_post, 'raw'); 
    408409                        wp_cache_add($_post->ID, $_post, 'posts'); 
  • wp-includes/post-template.php

     
    102102 */ 
    103103function get_the_title( $id = 0 ) { 
    104104        $post = &get_post($id); 
    105  
    106         $title = isset($post->post_title) ? $post->post_title : ''; 
    107         $id = isset($post->ID) ? $post->ID : (int) $id; 
    108  
    109         if ( !is_admin() ) { 
    110                 if ( !empty($post->post_password) ) { 
    111                         $protected_title_format = apply_filters('protected_title_format', __('Protected: %s')); 
    112                         $title = sprintf($protected_title_format, $title); 
    113                 } else if ( isset($post->post_status) && 'private' == $post->post_status ) { 
    114                         $private_title_format = apply_filters('private_title_format', __('Private: %s')); 
    115                         $title = sprintf($private_title_format, $title); 
    116                 } 
    117         } 
    118         return apply_filters( 'the_title', $title, $id ); 
     105        return $post->get_the_title($id); 
    119106} 
    120107 
    121108/** 
  • wp-includes/class-wp-post.php

     
     1<?php 
     2 
     3class WP_Post { 
     4        public $ID; 
     5        public $post_author; 
     6        public $post_date; 
     7        public $post_date_gmt; 
     8        public $post_content; 
     9        public $post_title; 
     10        public $post_excerpt; 
     11        public $post_status; 
     12        public $comment_status; 
     13        public $ping_status; 
     14        public $post_password; 
     15        public $post_name; 
     16        public $to_ping; 
     17        public $pinged; 
     18        public $post_modified; 
     19        public $post_modified_gmt; 
     20        public $post_content_filtered; 
     21        public $post_parent; 
     22        public $guid; 
     23        public $menu_order; 
     24        public $post_type; 
     25        public $post_mime_type; 
     26        public $comment_count; 
     27        public $filter; 
     28 
     29        public static function get_instance( $post_data ) { 
     30                $post = new WP_Post(); 
     31 
     32                foreach ( $post_data as $k=>$v ) { 
     33                        if ( property_exists('WP_Post', $k) ) { 
     34                                $post->$k = $v; 
     35                        } 
     36                } 
     37 
     38                return $post; 
     39        } 
     40 
     41        public function __set( $name, $value ) { 
     42                if ( property_exists('WP_Post', $name) ) { 
     43                        $this->$name = $value; 
     44                        return $this->$name; 
     45                } 
     46 
     47                return false; 
     48        } 
     49 
     50        public function get_the_title( $id = 0 ) { 
     51                $title = isset($this->post_title) ? $this->post_title : ''; 
     52                $id = isset($this->ID) ? $this->ID : (int) $id; 
     53 
     54                if ( !is_admin() ) { 
     55                        if ( !empty($this->post_password) ) { 
     56                                $protected_title_format = apply_filters('protected_title_format', __('Protected: %s')); 
     57                                $title = sprintf($protected_title_format, $title); 
     58                        } else if ( isset($this->post_status) && 'private' == $this->post_status ) { 
     59                                $private_title_format = apply_filters('private_title_format', __('Private: %s')); 
     60                                $title = sprintf($private_title_format, $title); 
     61                        } 
     62                } 
     63                return apply_filters( 'the_title', $title, $id ); 
     64        } 
     65} 
  • wp-includes/query.php

     
    26602660                if ( !$q['suppress_filters'] ) 
    26612661                        $this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) ); 
    26622662 
     2663                // Convert posts to WP_Post objects 
     2664                if ( is_array($this->posts) ) { 
     2665                        $this->posts = array_map(array( 'WP_Post', 'get_instance' ), $this->posts ); 
     2666                } 
     2667 
    26632668                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { 
    26642669                        $cjoin = apply_filters_ref_array('comment_feed_join', array( '', &$this ) ); 
    26652670                        $cwhere = apply_filters_ref_array('comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) ); 
  • wp-settings.php

     
    142142require( ABSPATH . WPINC . '/nav-menu.php' ); 
    143143require( ABSPATH . WPINC . '/nav-menu-template.php' ); 
    144144require( ABSPATH . WPINC . '/admin-bar.php' ); 
     145require( ABSPATH . WPINC . '/class-wp-post.php' ); 
    145146 
    146147// Load multisite-specific files. 
    147148if ( is_multisite() ) {