Changeset 1373 for trunk/wp-includes/template-functions-post.php
- Timestamp:
- 05/31/2004 05:22:25 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/template-functions-post.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/template-functions-post.php
r1355 r1373 351 351 } 352 352 353 function get_pagenum_link($pagenum = 1){ 354 $qstr = $_SERVER['REQUEST_URI']; 355 356 $page_querystring = "paged"; 357 $page_modstring = "page/"; 358 $page_modregex = "page/?"; 359 360 // if we already have a QUERY style page string 361 if( stristr( $qstr, $page_querystring ) ) { 362 $replacement = "$page_querystring=$pagenum"; 363 $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr); 364 // if we already have a mod_rewrite style page string 365 } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ){ 366 $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr); 367 368 // if we don't have a page string at all ... 369 // lets see what sort of URL we have... 370 } else { 371 // we need to know the way queries are being written 372 global $querystring_start, $querystring_equal, $querystring_separator; 373 // if there's a querystring_start (a "?" usually), it's deffinitely not mod_rewritten 374 if ( stristr( $qstr, $querystring_start ) ){ 375 // so append the query string (using &, since we already have ?) 376 $qstr .= $querystring_separator.$page_querystring.$querystring_equal.$pagenum; 377 // otherwise, it could be rewritten, OR just the default index ... 378 } elseif( '' != get_settings('permalink_structure')) { 379 $qstr = preg_replace('|(.*)/[^/]*|', '$1/', $qstr).$page_modstring.$pagenum; 380 } else { 381 $qstr = get_settings('blogfilename') . $querystring_start.$page_querystring.$querystring_equal.$pagenum; 382 } 383 } 384 385 $home_root = str_replace('http://', '', trim(get_settings('home'))); 386 $home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root); 387 if ('/' != substr($home_root, -1)) $home_root = $home_root . '/'; 388 389 $qstr = str_replace($home_root, '', $qstr); 390 return trailingslashit(get_settings('home')).$qstr; 391 } 392 353 393 function next_posts($max_page = 0) { // original by cfactor at cooltux.org 354 394 global $p, $paged, $what_to_show, $pagenow; 355 395 global $querystring_start, $querystring_equal, $querystring_separator; 356 if (empty($p) && ($what_to_show == 'paged')) { 357 $qstr = $_SERVER['QUERY_STRING']; 358 if (!empty($qstr)) { 359 $qstr = preg_replace('/&paged=\d{0,}/', '', $qstr); 360 $qstr = preg_replace('/paged=\d{0,}/', '', $qstr); 361 } elseif (stristr($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'] )) { 362 if ('' != $qstr = str_replace($_SERVER['SCRIPT_NAME'], '', 363 $_SERVER['REQUEST_URI']) ) { 364 $qstr = preg_replace('/^\//', '', $qstr); 365 $qstr = preg_replace('/paged\/\d{0,}\//', '', $qstr); 366 $qstr = preg_replace('/paged\/\d{0,}/', '', $qstr); 367 $qstr = preg_replace('/\/$/', '', $qstr); 368 } 369 } 370 if (!$paged) $paged = 1; 371 $nextpage = intval($paged) + 1; 372 if (!$max_page || $max_page >= $nextpage) { 373 echo get_settings('home') .'/'.$pagenow.$querystring_start. 374 ($qstr == '' ? '' : $qstr.$querystring_separator) . 375 'paged'.$querystring_equal.$nextpage; 376 } 377 } 396 // if (empty($p) && ($what_to_show == 'paged')) { 397 // $qstr = $_SERVER['QUERY_STRING']; 398 // if (!empty($qstr)) { 399 // $qstr = preg_replace('/&paged=\d{0,}/', '', $qstr); 400 // $qstr = preg_replace('/paged=\d{0,}/', '', $qstr); 401 // } elseif (stristr($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'] )) { 402 // if ('' != $qstr = str_replace($_SERVER['SCRIPT_NAME'], '', 403 // $_SERVER['REQUEST_URI']) ) { 404 // $qstr = preg_replace('/^\//', '', $qstr); 405 // $qstr = preg_replace('/paged\/\d{0,}\//', '', $qstr); 406 // $qstr = preg_replace('/paged\/\d{0,}/', '', $qstr); 407 // $qstr = preg_replace('/\/$/', '', $qstr); 408 // } 409 // } 410 // if (!$paged) $paged = 1; 411 // $nextpage = intval($paged) + 1; 412 // if (!$max_page || $max_page >= $nextpage) { 413 // echo get_settings('home') .'/'.$pagenow.$querystring_start. 414 // ($qstr == '' ? '' : $qstr.$querystring_separator) . 415 // 'paged'.$querystring_equal.$nextpage; 416 // } 417 // } 418 419 if (empty($p) && ($what_to_show == 'paged')) { 420 if (!$paged) $paged = 1; 421 $nextpage = intval($paged) + 1; 422 if (!$max_page || $max_page >= $nextpage) { 423 echo get_pagenum_link($nextpage); 424 } 425 } 378 426 } 379 427 … … 407 455 global $_SERVER, $p, $paged, $what_to_show, $pagenow; 408 456 global $querystring_start, $querystring_equal, $querystring_separator; 409 if (empty($p) && ($what_to_show == 'paged')) { 410 $qstr = $_SERVER['QUERY_STRING']; 411 if (!empty($qstr)) { 412 $qstr = preg_replace('/&paged=\d{0,}/', '', $qstr); 413 $qstr = preg_replace('/paged=\d{0,}/', '', $qstr); 414 } elseif (stristr($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'] )) { 415 if ('' != $qstr = str_replace($_SERVER['SCRIPT_NAME'], '', 416 $_SERVER['REQUEST_URI']) ) { 417 $qstr = preg_replace('/^\//', '', $qstr); 418 $qstr = preg_replace("/paged\/\d{0,}\//", '', $qstr); 419 $qstr = preg_replace('/paged\/\d{0,}/', '', $qstr); 420 $qstr = preg_replace('/\/$/', '', $qstr); 421 } 422 } 423 $nextpage = intval($paged) - 1; 424 if ($nextpage < 1) $nextpage = 1; 425 echo get_settings('home') .'/'.$pagenow.$querystring_start. 426 ($qstr == '' ? '' : $qstr.$querystring_separator) . 427 'paged'.$querystring_equal.$nextpage; 428 } 457 // if (empty($p) && ($what_to_show == 'paged')) { 458 // $qstr = $_SERVER['QUERY_STRING']; 459 // if (!empty($qstr)) { 460 // $qstr = preg_replace('/&paged=\d{0,}/', '', $qstr); 461 // $qstr = preg_replace('/paged=\d{0,}/', '', $qstr); 462 // } elseif (stristr($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'] )) { 463 // if ('' != $qstr = str_replace($_SERVER['SCRIPT_NAME'], '', 464 // $_SERVER['REQUEST_URI']) ) { 465 // $qstr = preg_replace('/^\//', '', $qstr); 466 // $qstr = preg_replace("/paged\/\d{0,}\//", '', $qstr); 467 // $qstr = preg_replace('/paged\/\d{0,}/', '', $qstr); 468 // $qstr = preg_replace('/\/$/', '', $qstr); 469 // } 470 // } 471 // $nextpage = intval($paged) - 1; 472 // if ($nextpage < 1) $nextpage = 1; 473 // echo get_settings('home') .'/'.$pagenow.$querystring_start. 474 // ($qstr == '' ? '' : $qstr.$querystring_separator) . 475 // 'paged'.$querystring_equal.$nextpage; 476 // } 477 478 if (empty($p) && ($what_to_show == 'paged')) { 479 $nextpage = intval($paged) - 1; 480 if ($nextpage < 1) $nextpage = 1; 481 echo get_pagenum_link($nextpage); 482 } 429 483 } 430 484
Note: See TracChangeset
for help on using the changeset viewer.