| 382 | | $home_root = parse_url(get_settings('home')); |
| 383 | | $home_root = $home_root['path']; |
| 384 | | $home_root = trailingslashit($home_root); |
| 385 | | $qstr = preg_replace('|^'. $home_root . '|', '', $qstr); |
| 386 | | $qstr = preg_replace('|^/+|', '', $qstr); |
| | 383 | $home_root = parse_url(get_settings('home')); |
| | 384 | $home_root = $home_root['path']; |
| | 385 | $home_root = trailingslashit($home_root); |
| | 386 | $qstr = preg_replace('|^'. $home_root . '|', '', $qstr); |
| | 387 | $qstr = preg_replace('|^/+|', '', $qstr); |
| 388 | | // if we already have a QUERY style page string |
| 389 | | if( stristr( $qstr, $page_querystring ) ) { |
| 390 | | $replacement = "$page_querystring=$pagenum"; |
| 391 | | $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr); |
| 392 | | // if we already have a mod_rewrite style page string |
| 393 | | } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ){ |
| 394 | | $permalink = 1; |
| 395 | | $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr); |
| | 389 | // if we already have a QUERY style page string |
| | 390 | if( stristr( $qstr, $page_querystring ) ) { |
| | 391 | $replacement = "$page_querystring=$pagenum"; |
| | 392 | $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr); |
| | 393 | // if we already have a mod_rewrite style page string |
| | 394 | } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ){ |
| | 395 | $permalink = 1; |
| | 396 | $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr); |
| 397 | | // if we don't have a page string at all ... |
| 398 | | // lets see what sort of URL we have... |
| 399 | | } else { |
| 400 | | // we need to know the way queries are being written |
| 401 | | // if there's a querystring_start (a "?" usually), it's deffinitely not mod_rewritten |
| 402 | | if ( stristr( $qstr, '?' ) ){ |
| 403 | | // so append the query string (using &, since we already have ?) |
| 404 | | $qstr .= '&' . $page_querystring . '=' . $pagenum; |
| 405 | | // otherwise, it could be rewritten, OR just the default index ... |
| 406 | | } elseif( '' != get_settings('permalink_structure')) { |
| 407 | | $permalink = 1; |
| | 398 | // if we don't have a page string at all ... |
| | 399 | // lets see what sort of URL we have... |
| | 400 | } else { |
| | 401 | // we need to know the way queries are being written |
| | 402 | // if there's a querystring_start (a "?" usually), it's definitely not mod_rewritten |
| | 403 | if ( stristr( $qstr, '?' ) ){ |
| | 404 | // so append the query string (using &, since we already have ?) |
| | 405 | $qstr .= '&' . $page_querystring . '=' . $pagenum; |
| | 406 | // otherwise, it could be rewritten, OR just the default index ... |
| | 407 | } elseif( '' != get_settings('permalink_structure') && ! is_admin()) { |
| | 408 | $permalink = 1; |
| | 409 | $index = $wp_rewrite->index; |
| | 410 | // If it's not a path info permalink structure, trim the index. |
| | 411 | if (! $wp_rewrite->using_index_permalinks()) { |
| | 412 | $qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr); |
| | 413 | } else { |
| | 414 | // If using path info style permalinks, make sure the index is in |
| | 415 | // the URI. |
| | 416 | if (strpos($qstr, $index) === false) { |
| | 417 | $qstr = '/' . $index . $qstr; |
| | 418 | } |
| | 419 | } |
| 409 | | // If it's not a path info permalink structure, trim the index. |
| 410 | | if (! $wp_rewrite->using_index_permalinks()) { |
| 411 | | $qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr); |
| 412 | | } else { |
| 413 | | // If using path info style permalinks, make sure the index is in |
| 414 | | // the URI. |
| 415 | | if (strpos($qstr, $index) === false) { |
| 416 | | $qstr = '/' . $index . $qstr; |
| 417 | | } |
| 418 | | } |
| | 421 | $qstr = trailingslashit($qstr) . $page_modstring . $pagenum; |
| | 422 | } else { |
| | 423 | $qstr = $index . '?' . $page_querystring . '=' . $pagenum; |
| | 424 | } |
| | 425 | } |
| 420 | | $qstr = trailingslashit($qstr) . $page_modstring . $pagenum; |
| 421 | | } else { |
| 422 | | $qstr = $index . '?' . $page_querystring . '=' . $pagenum; |
| 423 | | } |
| 424 | | } |
| 425 | | |
| 426 | | $qstr = preg_replace('|^/+|', '', $qstr); |
| 427 | | if ($permalink) $qstr = trailingslashit($qstr); |
| 428 | | return preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_settings('home') ) . $qstr ); |
| | 427 | $qstr = preg_replace('|^/+|', '', $qstr); |
| | 428 | if ($permalink) $qstr = trailingslashit($qstr); |
| | 429 | return preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_settings('home') ) . $qstr ); |