Ticket #1964: fix-sameslug-pages.diff
File fix-sameslug-pages.diff, 3.7 KB (added by , 19 years ago) |
---|
-
wp-includes/template-functions-post.php
283 283 $page_list = array_merge($page_list, $children); 284 284 } 285 285 } 286 287 286 return $page_list; 288 287 } 289 288 -
wp-includes/classes.php
257 257 // First let's clear some variables 258 258 $whichcat = ''; 259 259 $whichauthor = ''; 260 $whichpage = ''; 260 261 $result = ''; 261 262 $where = ''; 262 263 $limits = ''; … … 350 351 $q['name'] = sanitize_title($q['name']); 351 352 $where .= " AND post_name = '" . $q['name'] . "'"; 352 353 } else if ('' != $q['pagename']) { 353 $q['pagename'] = sanitize_title(basename(str_replace('%2F', '/', urlencode($q['pagename']))));354 354 $q['name'] = $q['pagename']; 355 $where .= " AND post_name = '" . $q['pagename'] . "'";356 355 } elseif ('' != $q['attachment']) { 357 356 $q['attachment'] = sanitize_title($q['attachment']); 358 357 $q['name'] = $q['attachment']; … … 511 510 $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'"); 512 511 $whichauthor .= ' AND (post_author = '.intval($q['author']).')'; 513 512 } 513 514 //Page stuff 515 if ($this->is_page) { 516 $page_paths = '/' . trim(urldecode($q['pagename']), '/'); 517 $q['pagename'] = sanitize_title(basename($page_paths)); 518 $page_paths = explode('/', $page_paths); 519 foreach($page_paths as $pathdir) 520 $page_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 521 522 $all_page_ids = get_all_page_ids(); 523 $reqpage = 0; 524 foreach ( $all_page_ids as $page_id ) { 525 $page = get_page($page_id); 526 if ( $page->fullpath == $page_path ) { 527 $reqpage = $page_id; 528 break; 529 } 530 } 531 532 $whichpage = " AND (ID = '$reqpage'"; 533 foreach (get_page_children($reqpage, get_pages()) as $child) { 534 $whichpage .= " OR ID = '{$child->ID}' "; 535 } 536 $whichpage .= ")"; 537 } 538 539 $where .= $search.$whichcat.$whichauthor.$whichpage; 514 540 515 $where .= $search.$whichcat.$whichauthor;516 517 541 if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) { 518 542 $q['order']='DESC'; 519 543 } -
wp-includes/functions.php
583 583 } 584 584 } 585 585 586 function set_page_path($page) { 587 $page->fullpath = '/' . $page->post_name; 588 $path = $page->fullpath; 589 $curpage = $page; 590 while ($curpage->post_parent != 0) { 591 $curpage = get_page($curpage->post_parent); 592 $path = '/' . $curpage->post_name . $path; 593 } 594 595 $page->fullpath = $path; 596 597 return $page; 598 } 599 586 600 // Retrieves page data given a page ID or page object. 587 601 // Handles page caching. 588 602 function &get_page(&$page, $output = OBJECT) { … … 610 624 wp_cache_add($_page->ID, $_page, 'pages'); 611 625 } 612 626 } 627 628 if (!isset($_page->fullpath)) { 629 $_page = set_page_path($_page); 630 wp_cache_replace($_page->cat_ID, $_page, 'pages'); 631 } 613 632 614 633 if ( $output == OBJECT ) { 615 634 return $_page; … … 718 737 return $cat_ids; 719 738 } 720 739 740 function get_all_page_ids() { 741 global $wpdb; 742 743 if ( ! $page_ids = wp_cache_get('all_page_ids', 'posts') ) { 744 $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status='static'"); 745 wp_cache_add('all_page_ids', $page_ids, 'pages'); 746 } 747 748 return $page_ids; 749 } 750 721 751 function gzip_compression() { 722 752 if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) return false; 723 753 if ( !get_settings('gzipcompression') ) return false;