Skip to content

Commit

Permalink
bump version to 1.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasKau committed Feb 13, 2023
1 parent 12f8985 commit 8c10bf4
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.0.13: 2023-02-13
## Changed
* air_search_search_on_empty changed to a setting in search locations registration to allow different settings for each search location.

### 1.0.12: 2023-02-13
## Added
* air_search_search_on_empty filter that can be used to enable searching even when no input is given.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ If you are not using Air-Light you need to register your search locations with `
```php
add_filters( 'air_search_location_data', [
'general' => [
'search_on_empty' => true, // Enables searching on empty fields, disables start search state. Accepts true as a boolean or string.
'query_args' => [
'posts_per_page' => '7',
],
Expand Down Expand Up @@ -219,5 +220,4 @@ Shown when no results are found.
* `add_filter( 'air_search_min_length', $length )` Allows user to change needed length of the search input before automatic search can start.
* `add_filter( 'air_search_disable_checkbox_auto_search', false )` Setting this to true will stop form from automatically submitting after clicking an input with type of checkbox.
* `add_filter( 'air_search_disable_select_auto_search', false )` Setting this to true will stop form from automatically submitting after changing a select field.
* `add_filter( 'air_search_pre_items', null, $post_ids, $post_type, $search_location )` This can be used to completely change the way results are listed. Filter should return html as a string. Instead of items containing all the search results and their datas, this one "item" will replace all of them. Items will need to be handled and listed in the filters html, this allows you to for example group results in groups based on post taxonomy.
* `add_filter( 'air_search_search_on_empty', false )` Can be set to true to enable searching even when no input is given, normally this would set search state to start. If set to true will disable start state and instead do search with default arguments.
* `add_filter( 'air_search_pre_items', null, $post_ids, $post_type, $search_location )` This can be used to completely change the way results are listed. Filter should return html as a string. Instead of items containing all the search results and their datas, this one "item" will replace all of them. Items will need to be handled and listed in the filters html, this allows you to for example group results in groups based on post taxonomy.
4 changes: 2 additions & 2 deletions air-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Author URI: https://dude.fi
* License: GPL2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Version: 1.0.12
* Version: 1.0.13
*
* @package air-search
*/
Expand All @@ -16,7 +16,7 @@

defined( 'ABSPATH' ) || exit;

const PLUGIN_VERSION = '1.0.12';
const PLUGIN_VERSION = '1.0.13';

include plugin_dir_path( __FILE__ ) . '/query.php';
include plugin_dir_path( __FILE__ ) . '/helpers.php';
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"plugin"
],
"license": "GPL-3.0+",
"version": "1.0.12",
"version": "1.0.13",
"authors": [
{
"name": "Digitoimisto Dude Oy",
Expand Down
21 changes: 20 additions & 1 deletion helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,23 @@ function get_result_locations() {
}

return $result_locations;
} // end get_result_locations
} // end get_result_locations

function get_location_search_on_empty_setting() {
$locations = get_location_data();
if ( empty( $locations ) ) {
return false;
}

$settings = [];
foreach ( $locations as $location => $values ) {
$settings[ $location ] = false;
if ( isset( $values['search_on_empty'] ) ) {
if ( true === $values['search_on_empty'] || 'true' === $values['search_on_empty'] ) {
$settings[ $location ] = true;
}
}
}

return $settings;
}
9 changes: 8 additions & 1 deletion scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ if (searchForm) {
fallbackResults.setAttribute('hidden', true);
}

let searchOnEmpty = JSON.parse(`${air_search_settings.search_on_empty}`)[location];
if (searchOnEmpty !== true && searchOnEmpty !== false) {
searchOnEmpty = false;
}

clearPagination();
showDiv('loading');
if (location && ((searchText || args !== '?') || `${air_search_settings.search_on_empty}`)) {
if (location && ((searchText || args !== '?') || searchOnEmpty)) {
callApi(searchText, location, args);
} else {
showDiv('start');
Expand Down Expand Up @@ -284,5 +289,7 @@ function updateResultsText(text) {
const searchTextElement = document.querySelector(`#${air_search_settings.result_text_id}`);
if (searchTextElement && text) {
searchTextElement.innerHTML = text;
} else if (searchTextElement) {
searchTextElement.innerHTML = '';
}
}

0 comments on commit 8c10bf4

Please sign in to comment.