Ticket #1964: fix-sameslug-pages.2.diff
File fix-sameslug-pages.2.diff, 3.6 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 } 534 535 $where .= $search.$whichcat.$whichauthor.$whichpage; 514 536 515 $where .= $search.$whichcat.$whichauthor;516 517 537 if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) { 518 538 $q['order']='DESC'; 519 539 } -
wp-includes/functions.php
585 585 } 586 586 } 587 587 588 function set_page_path($page) { 589 $page->fullpath = '/' . $page->post_name; 590 $path = $page->fullpath; 591 $curpage = $page; 592 while ($curpage->post_parent != 0) { 593 $curpage = get_page($curpage->post_parent); 594 $path = '/' . $curpage->post_name . $path; 595 } 596 597 $page->fullpath = $path; 598 599 return $page; 600 } 601 588 602 // Retrieves page data given a page ID or page object. 589 603 // Handles page caching. 590 604 function &get_page(&$page, $output = OBJECT) { … … 612 626 wp_cache_add($_page->ID, $_page, 'pages'); 613 627 } 614 628 } 629 630 if (!isset($_page->fullpath)) { 631 $_page = set_page_path($_page); 632 wp_cache_replace($_page->cat_ID, $_page, 'pages'); 633 } 615 634 616 635 if ( $output == OBJECT ) { 617 636 return $_page; … … 720 739 return $cat_ids; 721 740 } 722 741 742 function get_all_page_ids() { 743 global $wpdb; 744 745 if ( ! $page_ids = wp_cache_get('all_page_ids', 'posts') ) { 746 $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status='static'"); 747 wp_cache_add('all_page_ids', $page_ids, 'pages'); 748 } 749 750 return $page_ids; 751 } 752 723 753 function gzip_compression() { 724 754 if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) return false; 725 755 if ( !get_settings('gzipcompression') ) return false;