WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/06/2004 02:18:37 AM (16 years ago)
Author:
rboren
Message:

Page/subpage URIs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r1746 r1752  
    12161216}
    12171217
     1218function get_page_uri($page) {
     1219    global $wpdb;
     1220    $page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page'");
     1221
     1222    $uri = $page->post_name;
     1223
     1224    while ($page->post_parent != 0) {
     1225        $page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page->post_parent'");
     1226        $uri = $page->post_name . "/" . $uri;
     1227    }
     1228
     1229    return $uri;
     1230}
     1231
     1232function page_rewrite_rules() {
     1233    $uris = get_settings('page_uris');
     1234
     1235    $rewrite_rules = array();
     1236    foreach ($uris as $uri => $pagename) {
     1237        $rewrite_rules += array($uri . '/?$' => "index.php?pagename=$pagename");
     1238    }
     1239
     1240    return $rewrite_rules;
     1241}
     1242
    12181243function generate_rewrite_rules($permalink_structure = '', $matches = '') {
    12191244    $rewritecode =
     
    14101435    $page_rewrite = generate_rewrite_rules($page_structure, $matches);
    14111436
     1437        // Pages
     1438        $pages_rewrite = page_rewrite_rules();
     1439
    14121440    // Put them together.
    1413     $rewrite = $site_rewrite + $page_rewrite + $search_rewrite + $category_rewrite + $author_rewrite;
     1441    $rewrite = $pages_rewrite + $site_rewrite + $page_rewrite + $search_rewrite + $category_rewrite + $author_rewrite;
    14141442
    14151443    // Add on archive rewrite rules if needed.
Note: See TracChangeset for help on using the changeset viewer.