From 80842ce65bac256fd97bd2bd130d366112a1c60b Mon Sep 17 00:00:00 2001 From: rboren Date: Mon, 23 Aug 2004 23:28:14 +0000 Subject: [PATCH] Fix a path info paging bug. Add using_mod_rewrite(). git-svn-id: http://svn.automattic.com/wordpress/trunk@1555 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 25 ++++++++++++++++++++---- wp-includes/template-functions-links.php | 8 +++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 44a776d61..537cb53eb 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1163,6 +1163,23 @@ function remove_action($tag, $function_to_remove, $priority = 10) { remove_filter($tag, $function_to_remove, $priority); } +function using_mod_rewrite($permalink_structure = '') { + if (empty($permalink_structure)) { + $permalink_structure = get_settings('permalink_structure'); + + if (empty($permalink_structure)) { + return false; + } + } + + // If the index is not in the permalink, we're using mod_rewrite. + if (! preg_match('#^/*' . get_settings('blogfilename') . '#', $permalink_structure)) { + return true; + } + + return false; +} + function preg_index($number, $matches = '') { $match_prefix = '$'; $match_suffix = ''; @@ -1251,9 +1268,9 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') { $num_tokens = count($tokens[0]); - $index = 'index.php'; - $feedindex = 'index.php'; - $trackbackindex = 'index.php'; + $index = get_settings('blogfilename');; + $feedindex = $index; + $trackbackindex = $index; for ($i = 0; $i < $num_tokens; ++$i) { if (0 < $i) { $queries[$i] = $queries[$i - 1] . '&'; @@ -1334,7 +1351,7 @@ function rewrite_rules($matches = '', $permalink_structure = '') { $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); $index = get_settings('blogfilename'); $prefix = ''; - if (preg_match('#^/*' . $index . '#', $front)) { + if (! using_mod_rewrite($permalink_structure)) { $prefix = $index . '/'; } diff --git a/wp-includes/template-functions-links.php b/wp-includes/template-functions-links.php index e64882cf8..f1c475b52 100644 --- a/wp-includes/template-functions-links.php +++ b/wp-includes/template-functions-links.php @@ -349,8 +349,14 @@ function get_pagenum_link($pagenum = 1){ $permalink = 1; // If it's not a path info permalink structure, trim the index. - if ( ! preg_match('#^/*' . get_settings('blogfilename') . '#', get_settings('permalink_structure'))) { + if (using_mod_rewrite()) { $qstr = preg_replace("#/*" . get_settings('blogfilename') . "/*#", '/', $qstr); + } else { + // If using path info style permalinks, make sure the index is in + // the URI. + if (! strstr($qstr, get_settings('blogfilename'))) { + $qstr = '/' . get_settings('blogfilename') . $qstr; + } } $qstr = trailingslashit($qstr) . $page_modstring . $pagenum;