diff --git a/src/assets/js/search-bar-redirect.js b/src/assets/js/search-bar-redirect.js index 8cdb6f1..a99bc04 100644 --- a/src/assets/js/search-bar-redirect.js +++ b/src/assets/js/search-bar-redirect.js @@ -1,5 +1,5 @@ function onTainacanSearchSubmit($event) { - + if (document['tainacan-search-form']) { if (document['tainacan-search-form'].archive && tainacan_plugin !== undefined) { @@ -10,18 +10,19 @@ function onTainacanSearchSubmit($event) { case 'tainacan-collections': document['tainacan-search-form'].action = tainacan_plugin.theme_collection_list_url + (document['tainacan-search-form'].s ? '?s=' + document['tainacan-search-form'].s.value : ''); break; - case 'everywhere': - document['tainacan-search-form'].action = '/' + (document['tainacan-search-form'].s ? '?everywhere=true&s=' + document['tainacan-search-form'].s.value : ''); - break; case 'posts': + document['tainacan-search-form'].action = '/' + (document['tainacan-search-form'].s ? '?onlyposts=true&s=' + document['tainacan-search-form'].s.value : ''); + break; + case 'global': default: document['tainacan-search-form'].action = '/' + (document['tainacan-search-form'].s ? '?s=' + document['tainacan-search-form'].s.value : ''); } } else { document['tainacan-search-form'].action = '/' + (document['tainacan-search-form'].s ? '?s=' + document['tainacan-search-form'].s.value : ''); } - - $event.preventDefault(); + + if ($event) + $event.preventDefault(); } return true; } \ No newline at end of file diff --git a/src/functions.php b/src/functions.php index 5462180..31bf912 100644 --- a/src/functions.php +++ b/src/functions.php @@ -191,7 +191,8 @@ add_action( 'admin_head', 'tainacan_customize_editor_css'); * @param object $query The main WordPress query. */ function tainacan_include_items_in_search_results( $query ) { - if ( $_GET['everywhere'] && $query->is_main_query() && $query->is_search() && ! is_admin()) { + + if ( $query->get( 'post_type' ) !== 'tainacan-collection' && !$_GET['onlyposts'] && $query->is_main_query() && $query->is_search() && ! is_admin()) { $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers(); $existing_post_types = $query->get( 'post_type' ); diff --git a/src/functions/customizer.php b/src/functions/customizer.php index 47467bb..8c6502b 100644 --- a/src/functions/customizer.php +++ b/src/functions/customizer.php @@ -156,19 +156,18 @@ function tainacan_customize_register( $wp_customize ) { 'label' => __( 'Display option to search on tainacan collections list', 'tainacan-interface' ) ) ); - // Option to search globally posts, iem and collections - $wp_customize->add_setting( 'tainacan_search_global', array( + // Option to search on wordpress posts only + $wp_customize->add_setting( 'tainacan_search_on_posts', array( 'type' => 'theme_mod', 'default' => false, 'capability' => 'edit_theme_options', 'sanitize_callback' => 'tainacan_callback_sanitize_checkbox', ) ); - $wp_customize->add_control( 'tainacan_search_global', array( + $wp_customize->add_control( 'tainacan_search_on_posts', array( 'type' => 'checkbox', - 'settings' => 'tainacan_search_global', + 'settings' => 'tainacan_search_on_posts', 'section' => 'tainacan_header_search', - 'label' => __( 'Display option to search globally on items, collections and posts', 'tainacan-interface' ), - 'description'=> __( 'By searching via this mode, the list result will include posts, items and collecitions. You wil be able do distinguish them by a tag next to the title.', 'tainacan-interface' ) + 'label' => __( 'Display option to search only on WordPress posts', 'tainacan-interface' ) ) ); /** diff --git a/src/searchform.php b/src/searchform.php index 2c2502a..0a52a31 100644 --- a/src/searchform.php +++ b/src/searchform.php @@ -7,17 +7,17 @@ - +
- - - + if ( get_theme_mod('tainacan_search_on_posts', false) ) : ?> + +
diff --git a/src/template-parts/list-post.php b/src/template-parts/list-post.php index f3490f6..472babe 100644 --- a/src/template-parts/list-post.php +++ b/src/template-parts/list-post.php @@ -1,5 +1,5 @@ labels->singular_name; @@ -15,7 +15,7 @@
- +