Changeset 3511
- Timestamp:
- 02/10/2006 12:54:16 AM (19 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r3510 r3511 368 368 $where .= " AND post_name = '" . $q['name'] . "'"; 369 369 } else if ('' != $q['pagename']) { 370 $reqpage = get_page_by_path($q['pagename']); 370 371 $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename']))); 371 372 $page_paths = '/' . trim($q['pagename'], '/'); 372 373 $q['pagename'] = sanitize_title(basename($page_paths)); 373 374 $q['name'] = $q['pagename']; 374 $page_paths = explode('/', $page_paths);375 foreach($page_paths as $pathdir)376 $page_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);377 378 $all_page_ids = get_all_page_ids();379 $reqpage = 0;380 if (is_array($all_page_ids)) { foreach ( $all_page_ids as $page_id ) {381 $page = get_page($page_id);382 if ( $page->fullpath == $page_path ) {383 $reqpage = $page_id;384 break;385 }386 } }387 375 388 376 $where .= " AND (ID = '$reqpage')"; … … 1413 1401 1414 1402 function flush_rules() { 1415 generate_page_ rewrite_rules();1403 generate_page_uri_index(); 1416 1404 delete_option('rewrite_rules'); 1417 1405 $this->wp_rewrite_rules(); -
trunk/wp-includes/functions-post.php
r3510 r3511 793 793 } 794 794 795 function generate_page_ rewrite_rules() {795 function generate_page_uri_index() { 796 796 global $wpdb; 797 797 … … 801 801 $posts = array_reverse($posts, true); 802 802 803 $page_ rewrite_rules = array();804 $page_attachment_ rewrite_rules = array();803 $page_uris = array(); 804 $page_attachment_uris = array(); 805 805 806 806 if ($posts) { … … 814 814 foreach ( $attachments as $attachment ) { 815 815 $attach_uri = get_page_uri($attachment->ID); 816 $page_attachment_ rewrite_rules[$attach_uri] = $attachment->post_name;816 $page_attachment_uris[$attach_uri] = $attachment->ID; 817 817 } 818 818 } 819 819 820 $page_ rewrite_rules[$uri] = $post;821 } 822 823 update_option('page_uris', $page_ rewrite_rules);820 $page_uris[$uri] = $id; 821 } 822 823 update_option('page_uris', $page_uris); 824 824 825 if ( $page_attachment_ rewrite_rules )826 update_option('page_attachment_uris', $page_attachment_ rewrite_rules);825 if ( $page_attachment_uris ) 826 update_option('page_attachment_uris', $page_attachment_uris); 827 827 } 828 828 } -
trunk/wp-includes/functions.php
r3510 r3511 664 664 665 665 return $page; 666 } 667 668 function get_page_by_path($page_path) { 669 global $wpdb; 670 671 $page_path = str_replace('%2F', '/', urlencode(urldecode($page_path))); 672 $page_paths = '/' . trim($page_path, '/'); 673 $leaf_path = sanitize_title(basename($page_paths)); 674 $page_paths = explode('/', $page_paths); 675 foreach($page_paths as $pathdir) 676 $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); 677 678 $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path'"); 679 680 if ( empty($pages) ) 681 return 0; 682 683 foreach ($pages as $page) { 684 $path = '/' . $leaf_path; 685 $curpage = $page; 686 while ($curpage->post_parent != 0) { 687 $curpage = $wpdb->get_row("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = '$curpage->post_parent'"); 688 $path = '/' . $curpage->post_name . $path; 689 } 690 691 if ( $path == $full_path ) 692 return $page->ID; 693 } 694 695 return 0; 666 696 } 667 697
Note: See TracChangeset
for help on using the changeset viewer.