Reduce min/max word query params in search

12 characters less. Yay?
This commit is contained in:
Tetrakern 2024-05-25 14:44:03 +02:00
parent 0a44ddd138
commit addcaa9c0a
3 changed files with 8 additions and 8 deletions

View File

@ -211,8 +211,8 @@ function fictioneer_extend_search_query( $query ) {
$tax_array = []; $tax_array = [];
$authors = []; $authors = [];
$author_name = sanitize_text_field( $_GET['author_name'] ?? '' ); $author_name = sanitize_text_field( $_GET['author_name'] ?? '' );
$min_words = absint( $_GET['min_words'] ?? 0 ); $min_words = absint( $_GET['miw'] ?? 0 );
$max_words = absint( $_GET['max_words'] ?? 0 ); $max_words = absint( $_GET['maw'] ?? 0 );
$is_any_post = isset( $_GET['post_type'] ) && ( $_GET['post_type'] === 'any' ) ? 1 : 0; $is_any_post = isset( $_GET['post_type'] ) && ( $_GET['post_type'] === 'any' ) ? 1 : 0;
$authors_in = empty( $_GET['authors'] ) ? [] : array_map( 'absint', explode( ',', $_GET['authors'] ) ); $authors_in = empty( $_GET['authors'] ) ? [] : array_map( 'absint', explode( ',', $_GET['authors'] ) );

View File

@ -761,12 +761,12 @@ add_action( 'fictioneer_search_form_filters', 'fictioneer_add_search_for_status'
*/ */
function fictioneer_add_search_for_min_words( $args ) { function fictioneer_add_search_for_min_words( $args ) {
$words = absint( $_GET['min_words'] ?? 0 ); $words = absint( $_GET['miw'] ?? 0 );
// Start HTML ---> ?> // Start HTML ---> ?>
<div class="search-form__select-wrapper select-wrapper"> <div class="search-form__select-wrapper select-wrapper">
<div class="search-form__select-title"><?php _ex( 'Min Words', 'Advanced search heading.', 'fictioneer' ); ?></div> <div class="search-form__select-title"><?php _ex( 'Min Words', 'Advanced search heading.', 'fictioneer' ); ?></div>
<select name="min_words" class="search-form__select" autocomplete="off" data-default="0"> <select name="miw" class="search-form__select" autocomplete="off" data-default="0">
<option value="0" <?php echo ! $words ? 'selected' : ''; ?>><?php _ex( 'Minimum', 'Advanced search option.', 'fictioneer' ); ?></option> <option value="0" <?php echo ! $words ? 'selected' : ''; ?>><?php _ex( 'Minimum', 'Advanced search option.', 'fictioneer' ); ?></option>
<option value="1000" <?php echo $words == 1000 ? 'selected' : ''; ?>><?php _ex( '1,000 Words', 'Advanced search option.', 'fictioneer' ); ?></option> <option value="1000" <?php echo $words == 1000 ? 'selected' : ''; ?>><?php _ex( '1,000 Words', 'Advanced search option.', 'fictioneer' ); ?></option>
<option value="5000" <?php echo $words == 5000 ? 'selected' : ''; ?>><?php _ex( '5,000 Words', 'Advanced search option.', 'fictioneer' ); ?></option> <option value="5000" <?php echo $words == 5000 ? 'selected' : ''; ?>><?php _ex( '5,000 Words', 'Advanced search option.', 'fictioneer' ); ?></option>
@ -792,12 +792,12 @@ add_action( 'fictioneer_search_form_filters', 'fictioneer_add_search_for_min_wor
*/ */
function fictioneer_add_search_for_max_words( $args ) { function fictioneer_add_search_for_max_words( $args ) {
$words = absint( $_GET['max_words'] ?? 0 ); $words = absint( $_GET['maw'] ?? 0 );
// Start HTML ---> ?> // Start HTML ---> ?>
<div class="search-form__select-wrapper select-wrapper"> <div class="search-form__select-wrapper select-wrapper">
<div class="search-form__select-title"><?php _ex( 'Max Words', 'Advanced search heading.', 'fictioneer' ); ?></div> <div class="search-form__select-title"><?php _ex( 'Max Words', 'Advanced search heading.', 'fictioneer' ); ?></div>
<select name="max_words" class="search-form__select" autocomplete="off" data-default="0"> <select name="maw" class="search-form__select" autocomplete="off" data-default="0">
<option value="0" <?php echo ! $words ? 'selected' : ''; ?>><?php _ex( 'Maximum', 'Advanced search option.', 'fictioneer' ); ?></option> <option value="0" <?php echo ! $words ? 'selected' : ''; ?>><?php _ex( 'Maximum', 'Advanced search option.', 'fictioneer' ); ?></option>
<option value="1000" <?php echo $words == 1000 ? 'selected' : ''; ?>><?php _ex( '1,000 Words', 'Advanced search option.', 'fictioneer' ); ?></option> <option value="1000" <?php echo $words == 1000 ? 'selected' : ''; ?>><?php _ex( '1,000 Words', 'Advanced search option.', 'fictioneer' ); ?></option>
<option value="5000" <?php echo $words == 5000 ? 'selected' : ''; ?>><?php _ex( '5,000 Words', 'Advanced search option.', 'fictioneer' ); ?></option> <option value="5000" <?php echo $words == 5000 ? 'selected' : ''; ?>><?php _ex( '5,000 Words', 'Advanced search option.', 'fictioneer' ); ?></option>

View File

@ -31,8 +31,8 @@ if ( $show_advanced ) {
$sentence = sanitize_text_field( $_GET['sentence'] ?? 0 ); $sentence = sanitize_text_field( $_GET['sentence'] ?? 0 );
$order = sanitize_text_field( $_GET['order'] ?? 'desc' ); $order = sanitize_text_field( $_GET['order'] ?? 'desc' );
$orderby = sanitize_text_field( $_GET['orderby'] ?? 'modified' ); $orderby = sanitize_text_field( $_GET['orderby'] ?? 'modified' );
$min_words = absint( $_GET['min_words'] ?? 0 ); $min_words = absint( $_GET['miw'] ?? 0 );
$max_words = absint( $_GET['max_words'] ?? 0 ); $max_words = absint( $_GET['maw'] ?? 0 );
$story_status = fictioneer_sanitize_query_var( $story_status = fictioneer_sanitize_query_var(
$_GET['story_status'] ?? 0, $_GET['story_status'] ?? 0,