Changeset 1752
- Timestamp:
- 10/06/2004 02:18:37 AM (20 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r1747 r1752 486 486 } 487 487 488 function 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 518 function 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 488 536 function the_quicktags () { 489 537 // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP … … 708 756 } 709 757 710 function parent_dropdown($ parent = 0, $level = 0) {758 function parent_dropdown($default = 0, $parent = 0, $level = 0) { 711 759 global $wpdb; 712 760 $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"); … … 714 762 foreach ($items as $item) { 715 763 $pad = str_repeat(' ', $level * 3); 716 if ($item->ID == $ current)764 if ($item->ID == $default) 717 765 $current = ' selected="selected"'; 718 766 else … … 720 768 721 769 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); 723 771 } 724 772 } else { -
trunk/wp-admin/edit-page-form.php
r1747 r1752 53 53 <div><select name="parent_id"> 54 54 <option value='0'>Main Page (no parent)</option> 55 <?php parent_dropdown( ); ?>55 <?php parent_dropdown($post_parent); ?> 56 56 </select> 57 57 </div> -
trunk/wp-admin/edit-pages.php
r1747 r1752 68 68 $ping_status = get_settings('default_ping_status'); 69 69 $post_pingback = get_settings('default_pingback_flag'); 70 $post_parent = 0; 70 71 71 72 include('edit-page-form.php'); -
trunk/wp-admin/options-permalink.php
r1689 r1752 32 32 } 33 33 34 generate_page_rewrite_rules(); 35 34 36 if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) 35 37 $writable = true; … … 42 44 $usingpi = false; 43 45 44 if ( $writable && !$usingpi && $is_apache ) { 45 $rules = explode("\n", mod_rewrite_rules($permalink_structure)); 46 insert_with_markers($home_path.'.htaccess', 'WordPress', $rules); 47 } 46 save_mod_rewrite_rules(); 48 47 ?> 49 48 -
trunk/wp-admin/post.php
r1751 r1752 57 57 $post_status = $_POST['post_status']; 58 58 $post_name = $_POST['post_name']; 59 $post_parent = 0; 60 if (isset($_POST['parent_id'])) { 61 $post_parent = $_POST['parent_id']; 62 } 59 63 60 64 if (empty($post_status)) $post_status = 'draft'; … … 109 113 110 114 $postquery ="INSERT INTO $wpdb->posts 111 (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt )115 (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent) 112 116 VALUES 113 ('0', '$user_ID', '$now', '$now_gmt', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback', '$now', '$now_gmt' )117 ('0', '$user_ID', '$now', '$now_gmt', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback', '$now', '$now_gmt', '$post_parent') 114 118 "; 115 119 … … 195 199 } // end if publish 196 200 201 if ($post_status = 'static') { 202 generate_page_rewrite_rules(); 203 } 204 197 205 exit(); 198 206 break; … … 223 231 $pinged = $postdata->pinged; 224 232 $post_name = $postdata->post_name; 225 226 if ($post_status == 'static') { 227 include('edit-page-form.php'); 228 } else { 229 include('edit-form-advanced.php'); 230 } 233 $post_parent = $postdata->post_parent; 234 235 if ($post_status == 'static') { 236 include('edit-page-form.php'); 237 } else { 238 include('edit-form-advanced.php'); 239 } 231 240 232 241 $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'"); … … 287 296 if (empty($post_name)) { 288 297 $post_name = $post_title; 298 } 299 300 $post_parent = 0; 301 if (isset($_POST['parent_id'])) { 302 $post_parent = $_POST['parent_id']; 289 303 } 290 304 … … 354 368 to_ping = '$trackback', 355 369 post_modified = '$now', 356 post_modified_gmt = '$now_gmt' 370 post_modified_gmt = '$now_gmt', 371 post_parent = '$post_parent' 357 372 WHERE ID = $post_ID "); 358 373 … … 421 436 } 422 437 } // end if publish 438 439 if ($post_status = 'static') { 440 generate_page_rewrite_rules(); 441 } 423 442 424 443 do_action('edit_post', $post_ID); -
trunk/wp-admin/upgrade-schema.php
r1749 r1752 212 212 add_option('stylesheet', 'default'); 213 213 add_option('comment_whitelist', 0); 214 add_option('page_uris'); 214 215 215 216 // Delete unused options -
trunk/wp-includes/functions.php
r1746 r1752 1216 1216 } 1217 1217 1218 function 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 1232 function 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 1218 1243 function generate_rewrite_rules($permalink_structure = '', $matches = '') { 1219 1244 $rewritecode = … … 1410 1435 $page_rewrite = generate_rewrite_rules($page_structure, $matches); 1411 1436 1437 // Pages 1438 $pages_rewrite = page_rewrite_rules(); 1439 1412 1440 // 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; 1414 1442 1415 1443 // Add on archive rewrite rules if needed. -
trunk/wp-includes/template-functions-links.php
r1695 r1752 50 50 } 51 51 52 if ($idpost->post_status == 'static') { 53 return get_page_link(); 54 } 55 52 56 $permalink = get_settings('permalink_structure'); 53 57 54 58 if ('' != $permalink) { 55 if ($idpost->post_status == 'static')56 $permalink = page_permastruct();57 58 59 $unixtime = strtotime($idpost->post_date); 59 60 … … 79 80 } else { // if they're not using the fancy permalink option 80 81 $permalink = get_settings('home') . '/' . get_settings('blogfilename') . '?p=' . $idpost->ID; 81 if ($idpost->post_status == 'static')82 $permalink .= '&static=1';83 82 return $permalink; 84 83 } 84 } 85 86 function get_page_link($id = false) { 87 global $post; 88 89 if (! $id) { 90 $id = $post->ID; 91 } 92 93 $permalink = get_settings('permalink_structure'); 94 95 if ('' != $permalink) { 96 $link = get_page_uri($id); 97 $link = get_settings('home') . "/$link/"; 98 } else { 99 $link = get_settings('home') . "/index.php?p=$id&static=1"; 100 } 101 102 return $link; 85 103 } 86 104
Note: See TracChangeset
for help on using the changeset viewer.