Ticket #2363: objects.diff
| File objects.diff, 7.0 KB (added by , 20 years ago) |
|---|
-
wp-includes/functions-post.php
31 31 $post_name = apply_filters('name_save_pre', $post_name); 32 32 $comment_status = apply_filters('comment_status_pre', $comment_status); 33 33 $ping_status = apply_filters('ping_status_pre', $ping_status); 34 $post_type = apply_filters('post_type_pre', $post_type); 34 35 35 36 // Make sure we set a valid category 36 37 if (0 == count($post_category) || !is_array($post_category)) { … … 101 102 if ( !isset($post_password) ) 102 103 $post_password = ''; 103 104 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"); 108 108 109 109 if ($post_name_check) { 110 110 $suffix = 2; 111 111 while ($post_name_check) { 112 112 $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"); 116 114 $suffix++; 117 115 } 118 116 $post_name = $alt_post_name; … … 139 137 post_modified = '".current_time('mysql')."', 140 138 post_modified_gmt = '".current_time('mysql',1)."', 141 139 post_parent = '$post_parent', 142 menu_order = '$menu_order' 140 menu_order = '$menu_order', 141 post_type = '$post_type' 143 142 WHERE ID = $post_ID"); 144 143 } else { 145 144 $wpdb->query( 146 145 "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) 148 147 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')"); 150 149 $post_ID = $wpdb->insert_id; 151 150 } 152 151 -
wp-includes/classes.php
32 32 var $is_comments_popup = false; 33 33 var $is_admin = false; 34 34 var $is_attachment = false; 35 var $is_dingus = false; 35 36 36 37 function init_query_flags() { 37 38 $this->is_single = false; … … 52 53 $this->is_paged = false; 53 54 $this->is_admin = false; 54 55 $this->is_attachment = false; 56 $this->is_dingus = false; 55 57 } 56 58 57 59 function init () { … … 101 103 if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) { 102 104 $this->is_single = true; 103 105 $this->is_attachment = true; 106 } elseif ( ('' != $qv['object']) || (int) $qv['object_id'] ) { 107 $this->is_single = true; 108 $this->is_dingus = true; 104 109 } elseif ('' != $qv['name']) { 105 110 $this->is_single = true; 106 111 } elseif ( $qv['p'] ) { … … 236 241 $this->is_admin = true; 237 242 } 238 243 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)) { 240 245 $this->is_home = true; 241 246 } 242 247 … … 392 397 $q['attachment'] = sanitize_title(basename($attach_paths)); 393 398 $q['name'] = $q['attachment']; 394 399 $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'] . "'"; 395 404 } 396 405 397 406 if ( (int) $q['w'] ) { … … 402 411 if ( intval($q['comments_popup']) ) 403 412 $q['p'] = intval($q['comments_popup']); 404 413 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']; 406 417 if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0) ) 407 418 $q['p'] = (int) $q['attachment_id']; 408 419 … … 594 605 595 606 if ( $this->is_attachment ) { 596 607 $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 ) { 598 611 $where .= ' AND (post_status = "static")'; 599 } elseif ( $this->is_single) {612 } elseif ( $this->is_single ) { 600 613 $where .= ' AND (post_status != "static")'; 601 614 } else { 602 615 $where .= ' AND (post_status = "publish"'; … … 656 669 // Check post status to determine if post should be displayed. 657 670 if ($this->is_single) { 658 671 $status = get_post_status($this->posts[0]); 659 if ( ('publish' != $status) && ('static' != $status) ) {672 if ( ('publish' != $status) && ('static' != $status) && ('object' != $status) ) { 660 673 if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) { 661 674 // User must be logged in to view unpublished posts. 662 675 $this->posts = array();