Skip to content

Commit dd4e4b9

Browse files
committed
Move rewrite and permalink functions into WP_Rewrite class.
git-svn-id: https://develop.svn.wordpress.org/trunk@1908 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d9f15fd commit dd4e4b9

7 files changed

Lines changed: 431 additions & 391 deletions

File tree

wp-admin/admin-functions.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ function extract_from_markers($filename, $marker) {
490490
}
491491

492492
function save_mod_rewrite_rules() {
493-
global $is_apache;
493+
global $is_apache, $wp_rewrite;
494494
$home = get_settings('home');
495495
if ( $home != '' && $home != get_settings('siteurl') ) {
496496
$home_path = parse_url($home);
@@ -506,15 +506,13 @@ function save_mod_rewrite_rules() {
506506
else
507507
$writable = false;
508508

509-
$permalink_structure = get_settings('permalink_structure');
510-
511-
if ( strstr($permalink_structure, 'index.php') ) // If they're using
509+
if ($wp_rewrite->using_index_permalinks())
512510
$usingpi = true;
513511
else
514512
$usingpi = false;
515513

516514
if ( $writable && !$usingpi && $is_apache ) {
517-
$rules = explode("\n", mod_rewrite_rules($permalink_structure));
515+
$rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
518516
insert_with_markers($home_path.'.htaccess', 'WordPress', $rules);
519517
}
520518
}

wp-admin/options-permalink.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,28 @@
2121
$permalink_structure = $_POST['permalink_structure'];
2222
if (! empty($permalink_structure) )
2323
$permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
24-
update_option('permalink_structure', $permalink_structure);
24+
$wp_rewrite->set_permalink_structure($permalink_structure);
2525
}
2626

2727
if ( isset($_POST['category_base']) ) {
2828
$category_base = $_POST['category_base'];
2929
if (! empty($category_base) )
3030
$category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
31-
update_option('category_base', $category_base);
31+
$wp_rewrite->set_category_base($category_base);
3232
}
3333
}
3434

3535
$permalink_structure = get_settings('permalink_structure');
3636
$category_base = get_settings('category_base');
3737

38-
get_date_permastruct();
39-
4038
generate_page_rewrite_rules();
4139

4240
if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
4341
$writable = true;
4442
else
4543
$writable = false;
4644

47-
if ( strstr($permalink_structure, 'index.php') ) // If they're using
45+
if ($wp_rewrite->using_index_permalinks())
4846
$usingpi = true;
4947
else
5048
$usingpi = false;
@@ -106,7 +104,7 @@
106104
<p><?php _e('If your <code>.htaccess</code> was <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a> we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
107105
<form action="options-permalink.php" method="post">
108106
<p>
109-
<textarea rows="5" style="width: 98%;" name="rules"><?php echo mod_rewrite_rules($permalink_structure); ?>
107+
<textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?>
110108
</textarea>
111109
</p>
112110
<?php endif; ?>

wp-blog-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$error = '404';
1919

2020
// Fetch the rewrite rules.
21-
$rewrite = rewrite_rules('matches');
21+
$rewrite = $wp_rewrite->wp_rewrite_rules();
2222

2323
if (! empty($rewrite)) {
2424
$pathinfo = $_SERVER['PATH_INFO'];

0 commit comments

Comments
 (0)