Fixes to the new search logic. Global search now is default.
This commit is contained in:
parent
b224b3b0b4
commit
4cdb20fc5c
|
@ -1,5 +1,5 @@
|
||||||
function onTainacanSearchSubmit($event) {
|
function onTainacanSearchSubmit($event) {
|
||||||
|
|
||||||
if (document['tainacan-search-form']) {
|
if (document['tainacan-search-form']) {
|
||||||
|
|
||||||
if (document['tainacan-search-form'].archive && tainacan_plugin !== undefined) {
|
if (document['tainacan-search-form'].archive && tainacan_plugin !== undefined) {
|
||||||
|
@ -10,18 +10,19 @@ function onTainacanSearchSubmit($event) {
|
||||||
case 'tainacan-collections':
|
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 : '');
|
document['tainacan-search-form'].action = tainacan_plugin.theme_collection_list_url + (document['tainacan-search-form'].s ? '?s=' + document['tainacan-search-form'].s.value : '');
|
||||||
break;
|
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':
|
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:
|
default:
|
||||||
document['tainacan-search-form'].action = '/' + (document['tainacan-search-form'].s ? '?s=' + document['tainacan-search-form'].s.value : '');
|
document['tainacan-search-form'].action = '/' + (document['tainacan-search-form'].s ? '?s=' + document['tainacan-search-form'].s.value : '');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
document['tainacan-search-form'].action = '/' + (document['tainacan-search-form'].s ? '?s=' + document['tainacan-search-form'].s.value : '');
|
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;
|
return true;
|
||||||
}
|
}
|
|
@ -191,7 +191,8 @@ add_action( 'admin_head', 'tainacan_customize_editor_css');
|
||||||
* @param object $query The main WordPress query.
|
* @param object $query The main WordPress query.
|
||||||
*/
|
*/
|
||||||
function tainacan_include_items_in_search_results( $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();
|
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
|
||||||
$existing_post_types = $query->get( 'post_type' );
|
$existing_post_types = $query->get( 'post_type' );
|
||||||
|
|
||||||
|
|
|
@ -156,19 +156,18 @@ function tainacan_customize_register( $wp_customize ) {
|
||||||
'label' => __( 'Display option to search on tainacan collections list', 'tainacan-interface' )
|
'label' => __( 'Display option to search on tainacan collections list', 'tainacan-interface' )
|
||||||
) );
|
) );
|
||||||
|
|
||||||
// Option to search globally posts, iem and collections
|
// Option to search on wordpress posts only
|
||||||
$wp_customize->add_setting( 'tainacan_search_global', array(
|
$wp_customize->add_setting( 'tainacan_search_on_posts', array(
|
||||||
'type' => 'theme_mod',
|
'type' => 'theme_mod',
|
||||||
'default' => false,
|
'default' => false,
|
||||||
'capability' => 'edit_theme_options',
|
'capability' => 'edit_theme_options',
|
||||||
'sanitize_callback' => 'tainacan_callback_sanitize_checkbox',
|
'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',
|
'type' => 'checkbox',
|
||||||
'settings' => 'tainacan_search_global',
|
'settings' => 'tainacan_search_on_posts',
|
||||||
'section' => 'tainacan_header_search',
|
'section' => 'tainacan_header_search',
|
||||||
'label' => __( 'Display option to search globally on items, collections and posts', 'tainacan-interface' ),
|
'label' => __( 'Display option to search only on WordPress 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' )
|
|
||||||
) );
|
) );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,17 +7,17 @@
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<?php if ( defined ( 'TAINACAN_VERSION' ) && (get_theme_mod('tainacan_search_on_items', false) || get_theme_mod('tainacan_search_on_collections', false) || get_theme_mod('tainacan_search_global', false) ) ) : ?>
|
<?php if ( defined ( 'TAINACAN_VERSION' ) && (get_theme_mod('tainacan_search_on_items', false) || get_theme_mod('tainacan_search_on_collections', false) || get_theme_mod('tainacan_search_on_posts', false) ) ) : ?>
|
||||||
<div class="search-controls">
|
<div class="search-controls">
|
||||||
|
|
||||||
<label for="search-on-posts">
|
<label for="search-global">
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
value="posts"
|
value="global"
|
||||||
name="archive"
|
name="archive"
|
||||||
checked="checked"
|
checked="checked"
|
||||||
id="search-on-posts">
|
id="search-global">
|
||||||
<?php _e( 'Site posts', 'tainacan-interface' ); ?>
|
<?php _e( 'Global search', 'tainacan-interface' ); ?>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<?php if ( get_theme_mod('tainacan_search_on_items', false) ) : ?>
|
<?php if ( get_theme_mod('tainacan_search_on_items', false) ) : ?>
|
||||||
|
@ -42,16 +42,16 @@
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<?php endif;
|
<?php endif;
|
||||||
if ( get_theme_mod('tainacan_search_global', false) ) : ?>
|
if ( get_theme_mod('tainacan_search_on_posts', false) ) : ?>
|
||||||
|
<label for="search-on-posts">
|
||||||
<label for="search-everywhere">
|
<input
|
||||||
<input
|
type="radio"
|
||||||
type="radio"
|
value="posts"
|
||||||
value="everywhere"
|
name="archive"
|
||||||
name="archive"
|
id="search-on-posts">
|
||||||
id="search-everywhere">
|
<?php _e( 'Site posts', 'tainacan-interface' ); ?>
|
||||||
<?php _e( 'Everywhere', 'tainacan-interface' ); ?>
|
</label>
|
||||||
</label>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
if ( $_GET['everywhere'] ) {
|
if ( !$_GET['onlyposts'] && is_search() ) {
|
||||||
$post_type = get_post_type();
|
$post_type = get_post_type();
|
||||||
$post_type_object = get_post_type_object($post_type);
|
$post_type_object = get_post_type_object($post_type);
|
||||||
$post_type_label = $post_type_object->labels->singular_name;
|
$post_type_label = $post_type_object->labels->singular_name;
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="col-xs-12 blog-content <?php if ( has_post_thumbnail() ) :?>col-md-8 blog-flex<?php else : ?>col-md-12<?php endif; ?> align-self-center">
|
<div class="col-xs-12 blog-content <?php if ( has_post_thumbnail() ) :?>col-md-8 blog-flex<?php else : ?>col-md-12<?php endif; ?> align-self-center">
|
||||||
<?php if ( $_GET['everywhere'] ) : ?>
|
<?php if ( !$_GET['onlyposts'] && is_search() ) : ?>
|
||||||
<div class="title-area">
|
<div class="title-area">
|
||||||
<h3 class="mb-3">
|
<h3 class="mb-3">
|
||||||
<a href="<?php the_permalink(); ?>" class="font-weight-bold"><?php the_title(); ?></a>
|
<a href="<?php the_permalink(); ?>" class="font-weight-bold"><?php the_title(); ?></a>
|
||||||
|
|
Loading…
Reference in New Issue