diff --git a/singular-bookshelf.php b/singular-bookshelf.php index 9fa2c822..695f3449 100644 --- a/singular-bookshelf.php +++ b/singular-bookshelf.php @@ -22,10 +22,10 @@ if ( ! is_user_logged_in() || get_option( 'fictioneer_enable_public_cache_compat // Setup $user = wp_get_current_user(); -$current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : null; -$order = isset( $_GET['order'] ) ? strtolower( $_GET['order'] ) : 'desc'; -$order = in_array( $order, ['desc', 'asc'] ) ? $order : 'desc'; -$current_page = get_query_var( 'pg', 1 ); +$current_tab = $_GET['tab'] ?? null; +$order = array_intersect( [ strtolower( $_GET['order'] ?? 0 ) ], ['desc', 'asc'] ); +$order = reset( $order ) ?: 'desc'; +$current_page = get_query_var( 'pg', 1 ) ?: 1; $max_pages = 1; $tabs = []; @@ -102,14 +102,10 @@ $tabs[ $current_tab ]['classes'][] = '_current'; $order_link = add_query_arg( array( 'tab' => $current_tab, - 'order' => ['desc' => 'asc', 'asc' => 'desc'][ $order ] + 'order' => $order === 'desc' ? 'asc' : 'desc' ), $current_url ) . '#main'; - - // Pagination - $current_page = get_query_var( 'pg', 1 ); - $max_pages = 1; ?>
@@ -130,19 +126,16 @@ $tabs[ $current_tab ]['classes'][] = '_current';
$value ) : ?> - - - () - +
@@ -162,7 +155,7 @@ $tabs[ $current_tab ]['classes'][] = '_current'; 'current' => max( 1, $current_page ), 'prev_text' => fcntr( 'previous' ), 'next_text' => fcntr( 'next' ), - 'add_args' => $current_tab ? ['tab' => $current_tab] : null, + 'add_args' => $current_tab ? array( 'tab' => $current_tab ) : null, 'add_fragment' => '#tabs', 'total' => 0 ); @@ -179,7 +172,7 @@ $tabs[ $current_tab ]['classes'][] = '_current'; 'order' => $order ), $tabs[ $current_tab ]['empty'], - ['show_latest' => true] + array( 'show_latest' => true ) ); // Output list