From 0d7a4542ef0c0114ae9788c83df80993449b18ce Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 29 Jan 2023 15:40:18 +0100 Subject: Add filters to shortcode concert table. --- includes/giglogadmin-shortcodes.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'includes/giglogadmin-shortcodes.php') diff --git a/includes/giglogadmin-shortcodes.php b/includes/giglogadmin-shortcodes.php index 053e297..8e410b2 100644 --- a/includes/giglogadmin-shortcodes.php +++ b/includes/giglogadmin-shortcodes.php @@ -22,11 +22,20 @@ if ( ! function_exists( 'giglogadmin_shortcode_public' ) ) { * This shortcode does not have any attributes. */ function giglogadmin_shortcode_public() : string { - $opts = array( + $filters = array( 'offset' => 0, 'limit' => 15, ); - $concerts = GiglogAdmin_Concert::find_concerts( $opts ); + + if ( isset( $_GET['city'] ) && ! empty( $_GET['city'] ) ) { + $filters['city'] = sanitize_text_field( wp_unslash( $_GET['city'] ) ); + } + + if ( isset( $_GET['venue'] ) && ! empty( $_GET['venue'] ) ) { + $filters['venue'] = sanitize_text_field( wp_unslash( $_GET['venue'] ) ); + } + + $concerts = GiglogAdmin_Concert::find_concerts( $filters ); ob_start(); include __DIR__ . '/templates/giglogadmin-concerts-table.php'; -- cgit v1.2.3