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-admin/admin-functions.php

    r1747 r1752  
    486486}
    487487
     488function save_mod_rewrite_rules() {
     489    global $is_apache;
     490    $home = get_settings('home');
     491    if ( $home != '' && $home != get_settings('siteurl') ) {
     492        $home_path = parse_url($home);
     493        $home_path = $home_root['path'];
     494        $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
     495        $home_path = $root . $home_path . "/";
     496    } else {
     497        $home_path = ABSPATH;
     498    }
     499
     500    if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
     501        $writable = true;
     502    else
     503        $writable = false;
     504
     505    $permalink_structure = get_settings('permalink_structure');
     506
     507    if ( strstr($permalink_structure, 'index.php') ) // If they're using
     508        $usingpi = true;
     509    else
     510        $usingpi = false;
     511
     512    if ( $writable && !$usingpi && $is_apache ) {
     513        $rules = explode("\n", mod_rewrite_rules($permalink_structure));
     514        insert_with_markers($home_path.'.htaccess', 'WordPress', $rules);
     515    }
     516}
     517
     518function generate_page_rewrite_rules() {
     519    global $wpdb;
     520    $posts = $wpdb->get_results("SELECT ID, post_name FROM $wpdb->posts WHERE post_status = 'static'");
     521
     522    $page_rewrite_rules = array();
     523
     524    foreach ($posts as $post) {
     525        // URI => page name
     526        $uri = get_page_uri($post->ID);
     527
     528        $page_rewrite_rules[$uri] = $post->post_name;
     529    }
     530
     531    update_option('page_uris', $page_rewrite_rules);
     532
     533    save_mod_rewrite_rules();
     534}
     535
    488536function the_quicktags () {
    489537// Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP
     
    708756}
    709757
    710 function parent_dropdown($parent = 0, $level = 0) {
     758function parent_dropdown($default = 0, $parent = 0, $level = 0) {
    711759    global $wpdb;
    712760    $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order");
     
    714762        foreach ($items as $item) {
    715763            $pad = str_repeat(' ', $level * 3);
    716             if ($item->ID == $current)
     764            if ($item->ID == $default)
    717765                $current = ' selected="selected"';
    718766            else
     
    720768
    721769            echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</a></option>";
    722                 parent_dropdown($item->ID, $level + 1);
     770            parent_dropdown($default, $item->ID, $level + 1);
    723771        }
    724772    } else {
Note: See TracChangeset for help on using the changeset viewer.