1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Pagination Test for WP 4.3 |
---|
4 | Version: 1.0 |
---|
5 | Description: Demonstrates potential issues with WP 4.3 commit https://core.trac.wordpress.org/changeset/32948 |
---|
6 | Author: Marcus Sykes |
---|
7 | */ |
---|
8 | |
---|
9 | function paginate_test_options_page(){ |
---|
10 | $total = 1000; |
---|
11 | $limit = 20; |
---|
12 | $page = !empty($_REQUEST['pno']) ? absint($_REQUEST['pno']) : 1; |
---|
13 | $base = esc_url_raw(add_query_arg( 'pno', '%#%' )); |
---|
14 | ?> |
---|
15 | <h1>Check out pagination... </h1> |
---|
16 | <div class="tablenav" style="width:50%;"> |
---|
17 | <div class="tablenav-pages"> |
---|
18 | <?php |
---|
19 | echo sprintf( '<span class="displaying-num">Displaying %s–%s of %s</span>', number_format_i18n( ( $page - 1 ) * $limit + 1 ), number_format_i18n( min( $page * $limit, $total ) ), number_format_i18n( $total )); |
---|
20 | echo paginate_links( array( |
---|
21 | 'base' => $base, |
---|
22 | 'total' => ceil($total / $limit), |
---|
23 | 'current' => $page |
---|
24 | )); |
---|
25 | ?> |
---|
26 | </div> |
---|
27 | </div> |
---|
28 | <h2>Without the prev/next text still causes issues:</h2> |
---|
29 | <div class="tablenav" style="width:50%;"> |
---|
30 | <div class="tablenav-pages"> |
---|
31 | <?php |
---|
32 | echo sprintf( '<span class="displaying-num">Displaying %s–%s of %s</span>', number_format_i18n( ( $page - 1 ) * $limit + 1 ), number_format_i18n( min( $page * $limit, $total ) ), number_format_i18n( $total )); |
---|
33 | echo paginate_links( array( |
---|
34 | 'base' => $base, |
---|
35 | 'total' => ceil($total / $limit), |
---|
36 | 'current' => $page, |
---|
37 | 'prev_text' =>'«', |
---|
38 | 'next_text' => '»' |
---|
39 | )); |
---|
40 | ?> |
---|
41 | </div> |
---|
42 | </div> |
---|
43 | <?php |
---|
44 | } |
---|
45 | |
---|
46 | function pagination_test_settings_menu(){ |
---|
47 | add_options_page('Pagination Test', 'Pagination Test', 'list_users', 'paginate-test', 'paginate_test_options_page'); |
---|
48 | } |
---|
49 | add_action ( 'admin_menu', 'pagination_test_settings_menu'); |
---|