diff options
Diffstat (limited to 'includes/giglogadmin-shortcodes.php')
-rw-r--r-- | includes/giglogadmin-shortcodes.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/includes/giglogadmin-shortcodes.php b/includes/giglogadmin-shortcodes.php index 5a3d70d..1fba82e 100644 --- a/includes/giglogadmin-shortcodes.php +++ b/includes/giglogadmin-shortcodes.php @@ -22,15 +22,27 @@ if ( ! function_exists( 'giglogadmin_shortcode_public' ) ) { * This shortcode does not have any attributes. */ function giglogadmin_shortcode_public() : string { - $filters = array( - 'offset' => 0, - 'limit' => 15, - ); + $filters = array(); if ( isset( $_GET['city'] ) && ! empty( $_GET['city'] ) ) { $filters['city'] = sanitize_text_field( wp_unslash( $_GET['city'] ) ); } + $pages = GiglogAdmin_Concert::count_pages( $filters ); + $page = 1; + + if ( isset( $_GET['pg'] ) && ! empty( $_GET['pg'] ) ) { + $page = intval( wp_unslash( $_GET['pg'] ) ); + + if ( $page < 1 || $page > $pages ) { + // Just silently redirect to first page if we're outside + // the acceptable range. + wp_redirect( get_page_link() ); + } + } + + $filters['page'] = $page; + $concerts = GiglogAdmin_Concert::find_concerts( $filters ); ob_start(); |