Make WordPress Core

Ticket #2363: objects.diff

File objects.diff, 7.0 KB (added by mdawaffe, 20 years ago)

changes to classes.php and functions-post.php

  • wp-includes/functions-post.php

     
    3131        $post_name       = apply_filters('name_save_pre',      $post_name);
    3232        $comment_status  = apply_filters('comment_status_pre', $comment_status);
    3333        $ping_status     = apply_filters('ping_status_pre',    $ping_status);
     34        $post_type       = apply_filters('post_type_pre',      $post_type);
    3435       
    3536        // Make sure we set a valid category
    3637        if (0 == count($post_category) || !is_array($post_category)) {
     
    101102        if ( !isset($post_password) )
    102103                $post_password = '';
    103104
    104         if ( ('publish' == $post_status) || ('static' == $post_status) ) {
    105                 $post_name_check = ('publish' == $post_status)
    106                         ? $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1")
    107                         : $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'static' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
     105        if ( ('publish' == $post_status) || ('static' == $post_status) || ('object' == $post_status) ) {
     106                $parent_check = ( 'static' == $post_status ) ? " AND post_parent = '$post_parent'" : '';
     107                $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = '$post_status' AND ID != '$post_ID'$parent_check LIMIT 1");
    108108
    109109                if ($post_name_check) {
    110110                        $suffix = 2;
    111111                        while ($post_name_check) {
    112112                                $alt_post_name = $post_name . "-$suffix";
    113                                 $post_name_check = ('publish' == $post_status)
    114                                         ? $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1")
    115                                         : $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'static' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
     113                                $post_name_check = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = '$post_status' AND ID != '$post_ID'$parent_check LIMIT 1");
    116114                                $suffix++;
    117115                        }
    118116                        $post_name = $alt_post_name;
     
    139137                        post_modified = '".current_time('mysql')."',
    140138                        post_modified_gmt = '".current_time('mysql',1)."',
    141139                        post_parent = '$post_parent',
    142                         menu_order = '$menu_order'
     140                        menu_order = '$menu_order',
     141                        post_type = '$post_type'
    143142                        WHERE ID = $post_ID");
    144143        } else {
    145144                $wpdb->query(
    146145                        "INSERT IGNORE INTO $wpdb->posts
    147                         (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
     146                        (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_type, post_mime_type)
    148147                        VALUES
    149                         ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type')");
     148                        ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_type', '$post_mime_type')");
    150149                        $post_ID = $wpdb->insert_id;                   
    151150        }
    152151
  • wp-includes/classes.php

     
    3232        var $is_comments_popup = false;
    3333        var $is_admin = false;
    3434        var $is_attachment = false;
     35        var $is_dingus = false;
    3536
    3637        function init_query_flags() {
    3738                $this->is_single = false;
     
    5253                $this->is_paged = false;
    5354                $this->is_admin = false;
    5455                $this->is_attachment = false;
     56                $this->is_dingus = false;
    5557        }
    5658       
    5759        function init () {
     
    101103                if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) {
    102104                        $this->is_single = true;
    103105                        $this->is_attachment = true;
     106                } elseif ( ('' != $qv['object']) || (int) $qv['object_id'] ) {
     107                        $this->is_single = true;
     108                        $this->is_dingus = true;
    104109                } elseif ('' != $qv['name']) {
    105110                        $this->is_single = true;
    106111                } elseif ( $qv['p'] ) {
     
    236241                        $this->is_admin = true;
    237242                }
    238243
    239                 if ( ! ($this->is_attachment || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
     244                if ( ! ($this->is_dingus || $this->is_attachment || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
    240245                        $this->is_home = true;
    241246                }
    242247
     
    392397                        $q['attachment'] = sanitize_title(basename($attach_paths));
    393398                        $q['name'] = $q['attachment'];
    394399                        $where .= " AND post_name = '" . $q['attachment'] . "'";
     400                } elseif ('' != $q['object']) {
     401                        $q['object'] = sanitize_title($q['object']);
     402                        $q['name'] = $q['object'];
     403                        $where .= " AND post_name = '" . $q['object'] . "'";
    395404                }
    396405
    397406                if ( (int) $q['w'] ) {
     
    402411                if ( intval($q['comments_popup']) )
    403412                        $q['p'] = intval($q['comments_popup']);
    404413
    405                 // If a attachment is requested by number, let it supercede any post number.
     414                // If a attachment or object is requested by number, let it supercede any post number.
     415                if ( ($q['object_id'] != '') && (intval($q['object_id']) != 0) )
     416                        $q['p'] = (int) $q['object_id'];
    406417                if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0) )
    407418                        $q['p'] = (int) $q['attachment_id'];
    408419
     
    594605
    595606                if ( $this->is_attachment ) {
    596607                        $where .= ' AND (post_status = "attachment")';
    597                 } elseif ($this->is_page) {
     608                } elseif ( $this->is_dingus ) {
     609                        $where .= ' AND (post_status = "object")';
     610                } elseif ( $this->is_page ) {
    598611                        $where .= ' AND (post_status = "static")';
    599                 } elseif ($this->is_single) {
     612                } elseif ( $this->is_single ) {
    600613                        $where .= ' AND (post_status != "static")';
    601614                } else {
    602615                        $where .= ' AND (post_status = "publish"';
     
    656669                // Check post status to determine if post should be displayed.
    657670                if ($this->is_single) {
    658671                        $status = get_post_status($this->posts[0]);
    659                         if ( ('publish' != $status) && ('static' != $status) ) {
     672                        if ( ('publish' != $status) && ('static' != $status) && ('object' != $status) ) {
    660673                                if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
    661674                                        // User must be logged in to view unpublished posts.
    662675                                        $this->posts = array();