function widget($args, $instance) { extract($args); global $TFUSE; $title = apply_filters('widget_title', empty($instance['title']) ? __('Search', 'tfuse') : $instance['title'], $instance, $this->id_base); ?> <?php if (is_tax('reviews') || is_tax('games') || is_tax('platforms') || is_tax('genres') || is_tax('platforms_game') || is_tax('genres_game') || is_tax('producers_game') || is_tax('age_ratings') || $TFUSE->request->isset_GET('tax_reviews') || $TFUSE->request->isset_GET('tax_games')) { ?> <?php $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); $ids = tfuse_get_search_tems(); ?> <!-- widget filters --> <div class="widget filter-form"> <h3 class="widget-title"><?php echo $title; ?> </h3> <form method="get" action="<?php echo home_url('/'); ?> " id="filter-form"> <div class="row_form range_field inputtext clearfix"> <input type="text" name="s" id="s" class="inputtext" placeholder="<?php _e('Search by keywords', 'tfuse'); ?> "/> </div> <?php if (is_tax('reviews') || is_tax('platforms') || is_tax('genres') || $TFUSE->request->isset_GET('tax_reviews')) { ?> <?php $terms_platforms = get_terms('platforms'); $terms_genres = get_terms('genres'); ?> <input type="hidden" value="<?php echo $term ? $term->term_id : $TFUSE->request->GET('tax_reviews'); ?> " name="tax_reviews" id="s" class="tax_reviews" placeholder="<?php _e('Search', 'tfuse'); ?> "/> <div class="row_form range_field clearfix"> <label class="label_title"><?php _e('Review rating', 'tfuse'); ?> <span class="toggle-field-trigger"></span></label> <div class="range-slider toggle-field"> <?php if (!empty($ids['price-range'])) { ?> <input id="rating-range" type="text" name="price-range" value="<?php echo implode(';', $ids['price-range']); ?> "> <?php } else { ?> <input id="rating-range" type="text" name="price-range" value="0;10"> <?php } ?> </div> </div> <?php if (!empty($terms_platforms)) { ?> <?php $term_platf = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); ?> <div class="row_form input_styled checklist"> <label class="label_title"><?php _e('Platform', 'tfuse'); ?> <span class="toggle-field-trigger"></span></label> <div class="toggle-field"> <?php foreach ($terms_platforms as $term) { ?> <?php if (!empty($ids['platforms'])) { ?> <?php if (in_array($term->term_id, $ids['platforms'])) { ?> <input type="checkbox" name="platforms_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="platforms_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <?php } elseif (!empty($term_platf) && $term_platf->term_id == $term->term_id) { ?> <input type="checkbox" name="platforms_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="platforms_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <label for="checkbox_<?php echo $term->term_id; ?> "><?php echo $term->name; ?> <span>(<?php echo $term->count; ?> )</span></label> <?php } ?> </div> </div> <?php } ?> <?php if (!empty($terms_genres)) { ?> <?php $term_genr = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); ?> <div class="row_form input_styled checklist"> <label class="label_title"><?php _e('Genre', 'tfuse'); ?> <span class="toggle-field-trigger"></span></label> <div class="toggle-field"> <?php foreach ($terms_genres as $term) { ?> <?php if (!empty($ids['genres'])) { ?> <?php if (in_array($term->term_id, $ids['genres'])) { ?> <input type="checkbox" name="genres_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="genres_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <?php } elseif (!empty($term_genr) && $term_genr->term_id == $term->term_id) { ?> <input type="checkbox" name="genres_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="genres_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <label for="checkbox_<?php echo $term->term_id; ?> "><?php echo $term->name; ?> <span>(<?php echo $term->count; ?> )</span></label> <?php } ?> </div> </div> <?php } ?> <?php } ?> <?php if (is_tax('games') || is_tax('platforms_game') || is_tax('genres_game') || is_tax('producers_game') || is_tax('age_ratings') || $TFUSE->request->isset_GET('tax_games')) { ?> <?php $terms_platforms = get_terms('platforms_game'); $terms_producers = get_terms('producers_game'); $terms_genres = get_terms('genres_game'); $terms_age = get_terms('age_ratings'); ?> <input type="hidden" value="<?php echo $term ? $term->term_id : $TFUSE->request->GET('tax_games'); ?> " name="tax_games" id="s" class="tax_games" placeholder="<?php _e('Search', 'tfuse'); ?> "/> <?php if (!empty($terms_platforms)) { ?> <?php $term_pl = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); ?> <div class="row_form input_styled checklist"> <label class="label_title"><?php _e('Platform', 'tfuse'); ?> <span class="toggle-field-trigger"></span></label> <div class="toggle-field"> <?php foreach ($terms_platforms as $term) { ?> <?php if (!empty($ids['platforms'])) { ?> <?php if (in_array($term->term_id, $ids['platforms'])) { ?> <input type="checkbox" name="platforms_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="platforms_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <?php } elseif (!empty($term_pl) && $term_pl->term_id == $term->term_id) { ?> <input type="checkbox" name="platforms_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="platforms_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <label for="checkbox_<?php echo $term->term_id; ?> "><?php echo $term->name; ?> <span>(<?php echo $term->count; ?> )</span></label> <?php } ?> </div> </div> <?php } ?> <?php if (!empty($terms_producers)) { ?> <?php $term_pr = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); ?> <div class="row_form input_styled checklist"> <label class="label_title"><?php _e('Producers', 'tfuse'); ?> <span class="toggle-field-trigger"></span></label> <div class="toggle-field"> <?php foreach ($terms_producers as $term) { ?> <?php if (!empty($ids['producers'])) { ?> <?php if (in_array($term->term_id, $ids['producers'])) { ?> <input type="checkbox" name="producers_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="producers_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <?php } elseif (!empty($term_pr) && $term_pr->term_id == $term->term_id) { ?> <input type="checkbox" name="producers_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="producers_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <label for="checkbox_<?php echo $term->term_id; ?> "><?php echo $term->name; ?> <span>(<?php echo $term->count; ?> )</span></label> <?php } ?> </div> </div> <?php } ?> <?php if (!empty($terms_genres)) { ?> <?php $term_act = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); ?> <div class="row_form input_styled checklist"> <label class="label_title"><?php _e('Genre', 'tfuse'); ?> <span class="toggle-field-trigger"></span></label> <div class="toggle-field"> <?php foreach ($terms_genres as $term) { ?> <?php if (!empty($ids['genres'])) { ?> <?php if (in_array($term->term_id, $ids['genres'])) { ?> <input type="checkbox" name="genres_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="genres_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <?php } elseif (!empty($term_act) && $term_act->term_id == $term->term_id) { ?> <input type="checkbox" name="genres_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="genres_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <label for="checkbox_<?php echo $term->term_id; ?> "><?php echo $term->name; ?> <span>(<?php echo $term->count; ?> )</span></label> <?php } ?> </div> </div> <?php } ?> <?php if (!empty($terms_age)) { ?> <?php $term_age = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); ?> <div class="row_form input_styled checklist"> <label class="label_title"><?php _e('Age rating', 'tfuse'); ?> <span class="toggle-field-trigger"></span></label> <div class="toggle-field"> <?php foreach ($terms_age as $term) { ?> <?php if (!empty($ids['age'])) { ?> <?php if (in_array($term->term_id, $ids['age'])) { ?> <input type="checkbox" name="age_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="age_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <?php } elseif (!empty($term_age) && $term_age->term_id == $term->term_id) { ?> <input type="checkbox" name="age_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> " checked> <?php } else { ?> <input type="checkbox" name="age_<?php echo $term->term_id; ?> " id="checkbox_<?php echo $term->term_id; ?> " value="<?php echo $term->term_id; ?> "> <?php } ?> <label for="checkbox_<?php echo $term->term_id; ?> "><?php echo $term->name; ?> <span>(<?php echo $term->count; ?> )</span></label> <?php } ?> </div> </div> <?php } ?> <?php } ?> <div class="row_form row_submit"> <button type="submit" class="btn btn-primary" id="apply_filters"><?php _e('Apply Filters', 'tfuse'); ?> </button> </div> </form> <script type="text/javascript" > jQuery(document).ready(function($) { jQuery('#apply_filters').on('click',function(){ var value = jQuery(this).parents('#filter-form').find('.row_form .inputtext').val(); if(value.length == '0') { jQuery(this).parents('#filter-form').find('.inputtext').attr('value','~'); } }); // Rating Range Input jQuery("#rating-range").rangeslider({ from: 0, to: 10, limits: 0, scale: ['0', '10'], heterogeneity: ['50/5'], step: 1, smooth: true, dimension: '' }); }); </script> </div> <?php } ?> <?php }
function tfuse_get_search_posts() { global $TFUSE; $ids = $p_ids = $all_posts = array(); if ($TFUSE->request->isset_GET('tax_reviews')) { $ids = tfuse_get_search_tems(); $paged = get_query_var('paged') ? get_query_var('paged') : 1; $search = $TFUSE->request->GET('s'); $searched_query = $search !== '~' ? array('s' => $search) : ''; if (!empty($ids['platforms']) && !empty($ids['genres'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'review', 'tax_query' => array('relation' => 'OR', array('taxonomy' => 'platforms', 'field' => 'id', 'terms' => $ids['platforms']), array('taxonomy' => 'genres', 'field' => 'id', 'terms' => $ids['genres']))); } elseif (!empty($ids['platforms']) && empty($ids['genres'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'review', 'tax_query' => array(array('taxonomy' => 'platforms', 'field' => 'id', 'terms' => $ids['platforms']))); } elseif (empty($ids['platforms']) && !empty($ids['genres'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'review', 'tax_query' => array(array('taxonomy' => 'genres', 'field' => 'id', 'terms' => $ids['genres']))); } else { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'review'); } if (is_array($searched_query)) { $args = array_merge($args, $searched_query); } $price_range = array('meta_key' => '', 'meta_query' => array(array('key' => 'tfuse_rating', 'value' => $ids['price-range'], 'type' => 'numeric', 'compare' => 'BETWEEN'))); $args = array_merge($args, $price_range); $all_posts = new WP_Query($args); } if ($TFUSE->request->isset_GET('tax_games')) { $ids = tfuse_get_search_tems(); $search = $TFUSE->request->GET('s'); $searched_query = $search !== '~' ? array('s' => $search) : ''; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $platforms_args = array('taxonomy' => 'platforms_game', 'field' => 'id', 'terms' => $ids['platforms']); $genres_args = array('taxonomy' => 'genres_game', 'field' => 'id', 'terms' => $ids['genres']); $producers_args = array('taxonomy' => 'producers_game', 'field' => 'id', 'terms' => $ids['producers']); $age_args = array('taxonomy' => 'age_ratings', 'field' => 'id', 'terms' => $ids['age']); if (!empty($ids['platforms']) && !empty($ids['genres']) && !empty($ids['producers']) && !empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $platforms_args, $genres_args, $producers_args, $age_args)); } elseif (!empty($ids['platforms']) && !empty($ids['genres']) && !empty($ids['producers']) && empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $platforms_args, $genres_args, $producers_args)); } elseif (!empty($ids['platforms']) && empty($ids['genres']) && !empty($ids['producers']) && !empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $platforms_args, $producers_args, $age_args)); } elseif (empty($ids['platforms']) && !empty($ids['genres']) && !empty($ids['producers']) && !empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $genres_args, $producers_args, $age_args)); } elseif (!empty($ids['platforms']) && !empty($ids['genres']) && empty($ids['producers']) && !empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $platforms_args, $genres_args, $age_args)); } elseif (!empty($ids['platforms']) && !empty($ids['genres']) && empty($ids['producers']) && empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $platforms_args, $genres_args)); } elseif (!empty($ids['platforms']) && empty($ids['genres']) && !empty($ids['producers']) && empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $platforms_args, $producers_args)); } elseif (!empty($ids['platforms']) && empty($ids['genres']) && empty($ids['producers']) && !empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $platforms_args, $age_args)); } elseif (empty($ids['platforms']) && !empty($ids['genres']) && !empty($ids['producers']) && empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $genres_args, $producers_args)); } elseif (empty($ids['platforms']) && !empty($ids['genres']) && empty($ids['producers']) && !empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $genres_args, $age_args)); } elseif (empty($ids['platforms']) && empty($ids['genres']) && !empty($ids['producers']) && !empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array('relation' => 'OR', $producers_args, $age_args)); } elseif (!empty($ids['platforms']) && empty($ids['genres']) && empty($ids['producers']) && empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array($platforms_args)); } elseif (empty($ids['platforms']) && !empty($ids['genres']) && empty($ids['producers']) && empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array($genres_args)); } elseif (empty($ids['platforms']) && empty($ids['genres']) && !empty($ids['producers']) && empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array($producers_args)); } elseif (empty($ids['platforms']) && empty($ids['genres']) && empty($ids['producers']) && !empty($ids['age'])) { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game', 'tax_query' => array($age_args)); } else { $args = array('paged' => $paged, 'posts_per_page' => get_option('posts_per_page'), 'post_status' => 'publish', 'post_type' => 'game'); } if (is_array($searched_query)) { $args = array_merge($args, $searched_query); } $all_posts = new WP_Query($args); } return $all_posts; }
tfuse_pagination(); wp_reset_query(); ?> </section> <?php } elseif ($TFUSE->request->isset_GET('tax_games')) { ?> <section class="postlist postlist-grid"> <h1><?php _e('Games', 'tfuse'); ?> </h1> <?php $ids = tfuse_get_search_tems(); ?> <?php if (!empty($ids['platforms']) || !empty($ids['producers']) || !empty($ids['genres']) || !empty($ids['age'])) { ?> <div class="top-filter"> <span class="top-filter-title"><?php _e('Filters', 'tfuse'); ?> :</span> <ul> <?php if (!empty($ids['platforms'])) { ?> <?php