Changeset 28397 for trunk/src/wp-includes/general-template.php
- Timestamp:
- 05/14/2014 10:28:08 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r28379 r28397 2448 2448 2449 2449 $args = wp_parse_args( $args, $defaults ); 2450 extract($args, EXTR_SKIP);2451 2450 2452 2451 // Who knows what else people pass in $args 2453 $total = (int) $ total;2454 if ( $total < 2 ) 2452 $total = (int) $args['total']; 2453 if ( $total < 2 ) { 2455 2454 return; 2456 $current = (int) $current; 2457 $end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default. 2458 $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2; 2459 $add_args = is_array($add_args) ? $add_args : false; 2455 } 2456 $current = (int) $args['current']; 2457 $end_size = (int) $args['end_size']; // Out of bounds? Make it the default. 2458 if ( $end_size < 1 ) { 2459 $end_size = 1; 2460 } 2461 $mid_size = (int) $args['mid_size']; 2462 if ( $mid_size < 0 ) { 2463 $mid_size = 2; 2464 } 2465 $add_args = is_array( $args['add_args'] ) ? $args['add_args'] : false; 2460 2466 $r = ''; 2461 2467 $page_links = array(); 2462 2468 $dots = false; 2463 2469 2464 if ( $ prev_next&& $current && 1 < $current ) :2465 $link = str_replace( '%_%', 2 == $current ? '' : $format, $base);2466 $link = str_replace( '%#%', $current - 1, $link);2470 if ( $args['prev_next'] && $current && 1 < $current ) : 2471 $link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] ); 2472 $link = str_replace( '%#%', $current - 1, $link ); 2467 2473 if ( $add_args ) 2468 2474 $link = add_query_arg( $add_args, $link ); 2469 $link .= $a dd_fragment;2475 $link .= $args['add_fragment']; 2470 2476 2471 2477 /** … … 2476 2482 * @param string $link The paginated link URL. 2477 2483 */ 2478 $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $ prev_text. '</a>';2484 $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>'; 2479 2485 endif; 2480 2486 for ( $n = 1; $n <= $total; $n++ ) : 2481 2487 if ( $n == $current ) : 2482 $page_links[] = "<span class='page-numbers current'>" . $ before_page_number . number_format_i18n( $n ) . $after_page_number. "</span>";2488 $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>"; 2483 2489 $dots = true; 2484 2490 else : 2485 if ( $ show_all|| ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :2486 $link = str_replace( '%_%', 1 == $n ? '' : $format, $base);2487 $link = str_replace( '%#%', $n, $link);2491 if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) : 2492 $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); 2493 $link = str_replace( '%#%', $n, $link ); 2488 2494 if ( $add_args ) 2489 2495 $link = add_query_arg( $add_args, $link ); 2490 $link .= $a dd_fragment;2496 $link .= $args['add_fragment']; 2491 2497 2492 2498 /** This filter is documented in wp-includes/general-template.php */ 2493 $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $ before_page_number . number_format_i18n( $n ) . $after_page_number. "</a>";2499 $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</a>"; 2494 2500 $dots = true; 2495 elseif ( $dots && ! $show_all) :2501 elseif ( $dots && ! $args['show_all'] ) : 2496 2502 $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>'; 2497 2503 $dots = false; … … 2499 2505 endif; 2500 2506 endfor; 2501 if ( $ prev_next&& $current && ( $current < $total || -1 == $total ) ) :2502 $link = str_replace( '%_%', $format, $base);2503 $link = str_replace( '%#%', $current + 1, $link);2507 if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) : 2508 $link = str_replace( '%_%', $args['format'], $args['base'] ); 2509 $link = str_replace( '%#%', $current + 1, $link ); 2504 2510 if ( $add_args ) 2505 2511 $link = add_query_arg( $add_args, $link ); 2506 $link .= $a dd_fragment;2512 $link .= $args['add_fragment']; 2507 2513 2508 2514 /** This filter is documented in wp-includes/general-template.php */ 2509 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $ next_text. '</a>';2515 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>'; 2510 2516 endif; 2511 switch ( $ type) {2517 switch ( $args['type'] ) { 2512 2518 case 'array' : 2513 2519 return $page_links;
Note: See TracChangeset
for help on using the changeset viewer.