Passes s instead of search param on the Search Block #428.
This commit is contained in:
parent
b1128f1229
commit
d58f1b82c4
|
@ -69,7 +69,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
'authorid' => 'author',
|
||||
'authorname' => 'author_name',
|
||||
'search' => 's',
|
||||
's' => 's',
|
||||
's' => 's',
|
||||
'searchterm' => 'search',
|
||||
'status' => 'post_status',
|
||||
'offset' => 'offset',
|
||||
|
@ -147,7 +147,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
}
|
||||
|
||||
$args['perm'] = 'readable';
|
||||
|
||||
|
||||
return apply_filters('tainacan-api-prepare-items-args', $args, $request);
|
||||
}
|
||||
|
||||
|
|
|
@ -364,7 +364,6 @@ class REST_Items_Controller extends REST_Controller {
|
|||
|
||||
// Free php session early so simultaneous requests dont get queued
|
||||
session_write_close();
|
||||
|
||||
$args = $this->prepare_filters($request);
|
||||
|
||||
/**
|
||||
|
|
|
@ -306,7 +306,6 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
public function prepare_item_for_response( $item, $request ) {
|
||||
if(!empty($item)){
|
||||
$item_arr = $item->_toArray();
|
||||
|
||||
$item_arr['metadata_type_object'] = $item->get_metadata_type_object()->_toArray();
|
||||
|
||||
if(isset($item_arr['metadata_type_options']) && isset($item_arr['metadata_type_options']['taxonomy_id'])){
|
||||
|
@ -392,7 +391,7 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
}
|
||||
|
||||
return new \WP_REST_Response($prepared_item, 200);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \WP_REST_Request $request
|
||||
|
|
|
@ -38,8 +38,6 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
if (postQueries.advancedSearch)
|
||||
advancedSearchResults = postQueries.advancedSearch;
|
||||
}
|
||||
if (postQueries.s != undefined && postQueries.s != null)
|
||||
postQueries.search = postQueries.s;
|
||||
|
||||
let query = qs.stringify(postQueries);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ export const set_postquery = ({ commit }, postquery ) => {
|
|||
|
||||
export const set_advanced_query = ({commit}, advancedSearchQuery) => {
|
||||
commit('removePostQueryAttribute', 'search');
|
||||
commit('removePostQueryAttribute', 's');
|
||||
commit('setAdvancedSearchQuery', advancedSearchQuery);
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ export const getOrderBy = state => {
|
|||
};
|
||||
|
||||
export const getSearchQuery = state => {
|
||||
return state.postquery.search;
|
||||
return state.postquery.search || state.postquery.s;
|
||||
};
|
||||
|
||||
export const getStatus = state => {
|
||||
|
|
|
@ -134,11 +134,13 @@ export const setItemsPerPage = ( state, itemsPerPage ) => {
|
|||
|
||||
export const setSearchQuery = ( state, searchQuery ) => {
|
||||
|
||||
if (searchQuery != '') {
|
||||
if (searchQuery != '')
|
||||
state.postquery.search = searchQuery;
|
||||
} else {
|
||||
else
|
||||
delete state.postquery.search;
|
||||
}
|
||||
|
||||
// In case a s parameter was passed
|
||||
delete state.postquery.s;
|
||||
};
|
||||
|
||||
export const setStatus = ( state, status ) => {
|
||||
|
|
|
@ -184,7 +184,7 @@ registerBlockType('tainacan/search-bar', {
|
|||
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
|
||||
id="tainacan-search-bar-block_input"
|
||||
label={ __('Search', 'tainacan')}
|
||||
name='search'
|
||||
name='s'
|
||||
placeholder={ placeholderText }
|
||||
/>
|
||||
<button
|
||||
|
@ -229,7 +229,7 @@ registerBlockType('tainacan/search-bar', {
|
|||
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
|
||||
id="tainacan-search-bar-block_input"
|
||||
label={ __('Search', 'tainacan')}
|
||||
name='search'
|
||||
name='s'
|
||||
placeholder={ placeholderText }
|
||||
/>
|
||||
<button
|
||||
|
@ -621,7 +621,7 @@ registerBlockType('tainacan/search-bar', {
|
|||
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
|
||||
id="tainacan-search-bar-block_input"
|
||||
label={ __('Search', 'tainacan')}
|
||||
name='search'
|
||||
name='s'
|
||||
placeholder={ placeholderText }
|
||||
/>
|
||||
<button
|
||||
|
@ -667,7 +667,7 @@ registerBlockType('tainacan/search-bar', {
|
|||
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
|
||||
id="tainacan-search-bar-block_input"
|
||||
label={ __('Search', 'tainacan')}
|
||||
name='search'
|
||||
name='s'
|
||||
placeholder={ placeholderText }
|
||||
/>
|
||||
<button
|
||||
|
|
|
@ -6,7 +6,7 @@ document.addEventListener("DOMContentLoaded",() => {
|
|||
let input = document.getElementById('tainacan-search-bar-block_input');
|
||||
if (input) {
|
||||
if (input.value)
|
||||
window.location.href = e.target.action + '?search=' + input.value;
|
||||
window.location.href = e.target.action + '?s=' + input.value;
|
||||
return;
|
||||
}
|
||||
}));
|
||||
|
|
Loading…
Reference in New Issue