Merge branch 'develop' of https://github.com/tainacan/tainacan into develop

This commit is contained in:
mateuswetah 2018-09-12 22:01:14 -03:00
commit e77176268b
2 changed files with 18 additions and 7 deletions

View File

@ -329,14 +329,14 @@ class Search_Engine {
$searchand = '';
$searchSlug = '';
foreach ( $search_terms as $term ) {
$term = $wpdb->prepare("%s", $exact ? $term : "%". sanitize_title_with_dashes($term) . "%");
$searchSlug .= "{$searchand}(tter.slug LIKE $term)";
$term = $wpdb->prepare("%s", $exact ? $term : "%". $term . "%");
$searchSlug .= "{$searchand}(tter.name LIKE $term)";
$searchand = ' AND ';
}
$term = $wpdb->prepare("%s", $exact ? $term : "%". sanitize_title_with_dashes($s) . "%");
$term = $wpdb->prepare("%s", $exact ? $term : "%". $s . "%");
if ( count( $search_terms ) > 1 && $search_terms[0] != $s ) {
$searchSlug = "($searchSlug) OR (tter.slug LIKE $term)";
$searchSlug = "($searchSlug) OR (tter.name LIKE $term)";
}
if ( !empty( $searchSlug ) )
$search = " OR ({$searchSlug}) ";

View File

@ -182,13 +182,17 @@ function tainacan_the_faceted_search() {
$props = ' ';
$default_view_mode = apply_filters( 'tainacan-default-view-mode-for-themes', 'masonry' );
$enabled_view_modes = apply_filters( 'tainacan-enabled-view-modes-for-themes', ['table', 'cards', 'masonry'] );
// if in a collection page
$collection_id = tainacan_get_collection_id();
if ($collection_id) {
$props .= 'collection-id="' . $collection_id . '" ';
$collection = new \Tainacan\Entities\Collection($collection_id);
$props .= 'default-view-mode="' . $collection->get_default_view_mode() . '" ';
$props .= 'enabled-view-modes="' . implode(',', $collection->get_enabled_view_modes()) . '" ';
$default_view_mode = $collection->get_default_view_mode();
$enabled_view_modes = $collection->get_enabled_view_modes();
}
// if in a tainacan taxonomy
@ -198,6 +202,9 @@ function tainacan_the_faceted_search() {
$props .= 'taxonomy="' . $term->taxonomy . '" ';
}
$props .= 'default-view-mode="' . $default_view_mode . '" ';
$props .= 'enabled-view-modes="' . implode(',', $enabled_view_modes) . '" ';
echo "<div id='tainacan-items-page' $props ></div>";
}
@ -279,6 +286,10 @@ function tainacan_register_view_mode($slug, $args = []) {
function tainacan_get_item($post_id = 0) {
$post = get_post( $post_id );
if (!$post) {
return null;
}
$theme_helper = \Tainacan\Theme_Helper::get_instance();
if (!$theme_helper->is_post_an_item($post))