-
Notifications
You must be signed in to change notification settings - Fork 1
/
wp-smart-pagination.php
67 lines (44 loc) · 1.55 KB
/
wp-smart-pagination.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/*
Plugin Name: WP Smart Pagination
Plugin URI: https://github.com/kharissulistiyo/WP-Smart-Pagination
Description: Smart WordPress post pagination with input number filed.
Author: Kharis Sulistiyono
Version: 0.1
Author URI: http://kharisulistiyo.github.io
*/
/*
* Front-end style
*/
if(!function_exists('wp_smart_pagination_style')){
function wp_smart_pagination_style(){
wp_enqueue_style( 'wp-smart-pagination', plugins_url( 'wp-smart-pagination.css' , __FILE__ ) );
}
}
add_action( 'wp_enqueue_scripts', 'wp_smart_pagination_style' );
// Function
if ( ! function_exists( 'wp_smart_pagination' ) ) :
function wp_smart_pagination() {
global $wp_query;
echo '<div class="wp-smart-pagination">';
echo '<div class="wpsp-page-nav">';
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) ); ?>
</div><!-- /.wpsp-page-nav -->
<form class="wpsp-page-nav-form" action="<?php echo $_SERVER['REQUEST_URI'];?>" method="get">
<label for="sortby" class="wpsp-label wpsp-hidden"><?php _e('Go to', 'wp-smart-pagination'); ?></label>
<input class="wpsp-input-number" type="text" placeholder="Jump to" size="6" name="paged" />
<input class="wpsp-button" value="Go" type="submit" >
</form>
</div><!-- /.wp-smart-pagination -->
<?php
}
endif;
// Shortcode
add_shortcode( 'wpsp', 'wp_smart_pagination' );
?>