| 1 |
<?php |
| 2 |
/** |
| 3 |
* Search item page template |
| 4 |
* |
| 5 |
* @package Welcart |
| 6 |
*/ |
| 7 |
|
| 8 |
$uscpaged = isset( $_REQUEST['paged'] ) ? absint( wp_unslash( $_REQUEST['paged'] ) ) : 1; |
| 9 |
|
| 10 |
$html = '<script type="text/javascript"> |
| 11 |
function usces_nextpage() { |
| 12 |
document.getElementById(\'usces_paged\').value = ' . ( $uscpaged + 1 ) . '; |
| 13 |
document.searchindetail.submit(); |
| 14 |
} |
| 15 |
function usces_prepage() { |
| 16 |
document.getElementById(\'usces_paged\').value = ' . ( $uscpaged - 1 ) . '; |
| 17 |
document.searchindetail.submit(); |
| 18 |
} |
| 19 |
function newsubmit() { |
| 20 |
document.getElementById(\'usces_paged\').value = 1; |
| 21 |
} |
| 22 |
</script>'; |
| 23 |
|
| 24 |
$html .= '<div id="searchbox">'; |
| 25 |
|
| 26 |
if ( isset( $_REQUEST['usces_search'] ) ) { |
| 27 |
|
| 28 |
$catresult = usces_search_categories(); |
| 29 |
$search_query = array( |
| 30 |
'category__and' => $catresult, |
| 31 |
'posts_per_page' => 10, |
| 32 |
'paged' => $uscpaged, |
| 33 |
); |
| 34 |
$search_query = apply_filters( 'usces_filter_search_query', $search_query ); |
| 35 |
|
| 36 |
$my_query = new WP_Query( $search_query ); |
| 37 |
|
| 38 |
$html .= '<div class="title">' . esc_html__( 'Search results', 'usces' ) . ' ' . number_format( $my_query->found_posts ) . esc_html__( 'cases', 'usces' ) . '</div>'; |
| 39 |
|
| 40 |
if ( $my_query->have_posts() ) { |
| 41 |
|
| 42 |
$html .= apply_filters( 'usces_filter_search_result_pre', null, $my_query ); |
| 43 |
|
| 44 |
$html .= '<div class="navigation clearfix">'; |
| 45 |
if ( 1 < $uscpaged ) { |
| 46 |
$html .= '<a style="float:left; cursor:pointer;" onclick="usces_prepage();">' . esc_html__( '« Previous article', 'usces' ) . '</a>'; |
| 47 |
} |
| 48 |
if ( $uscpaged < $my_query->max_num_pages ) { |
| 49 |
$html .= '<a style="float:right; cursor:pointer;" onclick="usces_nextpage();">' . esc_html__( 'Next article »', 'usces' ) . '</a>'; |
| 50 |
} |
| 51 |
$html .= '</div>'; |
| 52 |
|
| 53 |
$itemhtml = '<div class="searchitems">'; |
| 54 |
while ( $my_query->have_posts() ) { |
| 55 |
$my_query->the_post(); |
| 56 |
usces_the_item(); |
| 57 |
|
| 58 |
$itemhtml .= '<div class="itemlist clearfix"><div class="loopimg"> |
| 59 |
<a href="' . get_permalink( $post->ID ) . '">' . usces_the_itemImage( 0, 100, 100, $post, 'return' ) . '</a> |
| 60 |
</div> |
| 61 |
<div class="loopexp"> |
| 62 |
<div class="itemtitle"><a href="' . get_permalink( $post->ID ) . '">' . esc_html( $post->post_title ) . '</a></div> |
| 63 |
<div class="field">' . $post->post_content . '</div> |
| 64 |
</div> |
| 65 |
</div>'; |
| 66 |
} |
| 67 |
$itemhtml .= '</div><!-- searchitems -->'; |
| 68 |
$html .= apply_filters( 'usces_filter_search_result', $itemhtml, $my_query ); |
| 69 |
|
| 70 |
$html .= '<div class="navigation clearfix">'; |
| 71 |
if ( 1 < $uscpaged ) { |
| 72 |
$html .= '<a style="float:left; cursor:pointer;" onclick="usces_prepage();">' . esc_html__( '« Previous article', 'usces' ) . '</a>'; |
| 73 |
} |
| 74 |
if ( $uscpaged < $my_query->max_num_pages ) { |
| 75 |
$html .= '<a style="float:right; cursor:pointer;" onclick="usces_nextpage();">' . esc_html__( 'Next article »', 'usces' ) . '</a>'; |
| 76 |
} |
| 77 |
$html .= '</div>'; |
| 78 |
|
| 79 |
wp_reset_postdata(); |
| 80 |
|
| 81 |
} else { |
| 82 |
|
| 83 |
$html .= '<div class="searchitems">'; |
| 84 |
$html .= '<p>' . esc_html__( 'The article was not found.', 'usces' ) . '</p>'; |
| 85 |
$html .= '</div><!-- searchitems -->'; |
| 86 |
} |
| 87 |
} |
| 88 |
$html .= '<form name="searchindetail" action="' . esc_url( USCES_CART_URL ) . $this->delim . 'usces_page=search_item" method="post"> |
| 89 |
<div class="field"> |
| 90 |
<label class="outlabel">' . esc_html__( 'Categories: AND Search', 'usces' ) . '</label>' . usces_categories_checkbox( 'return' ) . ' |
| 91 |
</div>'; |
| 92 |
|
| 93 |
$usces_search_button = '<input name="usces_search_button" class="usces_search_button" type="submit" value="' . esc_html__( 'Search', 'usces' ) . '" onclick="newsubmit()" />'; |
| 94 |
$html .= apply_filters( 'usces_filter_search_button', $usces_search_button ); |
| 95 |
|
| 96 |
$html .= '<input name="paged" id="usces_paged" type="hidden" value="' . esc_attr( $uscpaged ) . '" /> |
| 97 |
<input name="usces_search" type="hidden" /> |
| 98 |
</form>'; |
| 99 |
$html .= '</div><!-- searchbox -->'; |
| 100 |
|