Update search form template.

This commit is contained in:
Hoang Huu 2019-10-10 10:41:57 +07:00
parent a701ccc5f4
commit f6a07185a8
14 changed files with 157 additions and 91 deletions

View File

@ -263,7 +263,7 @@ class Opalestate_Property_Api extends Opalestate_Base_API {
$search_min_area = isset( $request['min_area'] ) ? sanitize_text_field( $request['min_area'] ) : '';
$search_max_area = isset( $request['max_area'] ) ? sanitize_text_field( $request['max_area'] ) : '';
$s = isset( $request['search_text'] ) ? sanitize_text_field( $request['search_text'] ) : null;
$per_page = isset( $request['per_page'] ) && $request['per_page'] ? $request['per_page'] : 5;
$per_page = isset( $request['per_page'] ) && $request['per_page'] ? $request['per_page'] : opalestate_options( 'search_property_per_page', 5 );
$paged = isset( $request['page'] ) && $request['page'] ? $request['page'] : 1;
if ( isset( $request['paged'] ) && intval( $request['paged'] ) > 0 ) {

View File

@ -1169,7 +1169,7 @@ function opalestate_get_property_statuses() {
* @param $key
*/
function opalestate_get_property_meta_icon( $key ) {
$classes = '';
$classes = '';
$classes .= 'icon-property-' . esc_attr( $key );
switch ( $key ) {
@ -1214,3 +1214,21 @@ function opalestate_get_property_meta_icon( $key ) {
return $classes;
}
/**
* Is enable price field in the search forms?
*
* @return bool
*/
function opalestate_is_enable_price_field() {
return 'on' == opalestate_get_option( 'opalestate_ppt_price_opt', 'on' );
}
/**
* Is enable areasize field in the search forms?
*
* @return bool
*/
function opalestate_is_enable_areasize_field() {
return 'on' == opalestate_get_option( 'opalestate_ppt_areasize_opt', 'on' );
}

View File

@ -62,13 +62,17 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?>
<div class="col-lg-3 col-md-3 col-sm-3">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<div class="col-lg-3 col-md-3 col-sm-3">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<div class="col-lg-3 col-md-3 col-sm-3">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<div class="col-lg-3 col-md-3 col-sm-3">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
</div>
<?php

View File

@ -48,13 +48,17 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?>
<div class="col-lg-3 col-md-3 col-sm-3">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<div class="col-lg-3 col-md-3 col-sm-3">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<div class="col-lg-3 col-md-3 col-sm-3">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<div class="col-lg-3 col-md-3 col-sm-3">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
<?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?>
<div class="col-lg-3 col-md-3 col-sm-3">

View File

@ -61,9 +61,13 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?>
<div class="col-lg-6 col-md-6 col-sm-6">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
<?php endif; ?>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
<?php endif; ?>
</div>
<?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?>

View File

@ -51,12 +51,12 @@ $form_classes = [
</div>
<div class="searchbox-field searchbox-field--categories">
<?php echo opalestate_load_template_path( 'search-box/fields/categories' ); ?>
<?php echo opalestate_load_template_path( 'search-box/fields/categories' ); ?>
</div>
<div class="searchbox-field searchbox-field--collapse">
<button type="button" class="opal-collapse-button opalestate-collapse-btn btn btn-primary" data-collapse="#collapse-city-<?php echo esc_attr( $unique_id ); ?>">
<?php echo apply_filters( 'opalestate_search_form_collapse_button', '<i class="fa fa-caret-down" aria-hidden="true"></i>' ); ?>
<?php echo apply_filters( 'opalestate_search_form_collapse_button', '<i class="fa fa-caret-down" aria-hidden="true"></i>' ); ?>
</button>
</div>
@ -71,13 +71,17 @@ $form_classes = [
<div class="opal-row">
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
</div>
<?php

View File

@ -7,7 +7,7 @@
defined( 'ABSPATH' ) || exit;
$unique_id = esc_attr( wp_unique_id() );
$unique_id = esc_attr( wp_unique_id() );
$GLOBALS['group-info-column'] = 4;
if ( isset( $nobutton ) && $nobutton ) {
@ -48,7 +48,7 @@ $form_classes = [
<div class="col-lg-<?php echo esc_attr( $grid[2] ); ?> col-md-<?php echo esc_attr( $grid[2] ); ?> col-sm-<?php echo esc_attr( $grid[2] ); ?> col-xs-12">
<button type="button" class="opal-collapse-button opalestate-collapse-btn btn btn-primary" data-collapse="#collapse-city-<?php echo esc_attr( $unique_id ); ?>">
<?php echo apply_filters( 'opalestate_search_form_collapse_button', '<i class="fa fa-caret-down" aria-hidden="true"></i>' ); ?>
<?php echo apply_filters( 'opalestate_search_form_collapse_button', '<i class="fa fa-caret-down" aria-hidden="true"></i>' ); ?>
</button>
</div>
@ -67,20 +67,24 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
</div>
<?php
if ( $display_more_options ) {
echo opalestate_load_template_path( 'search-box/fields/more-options' );
}
?>
<?php
if ( $display_more_options ) {
echo opalestate_load_template_path( 'search-box/fields/more-options' );
}
?>
</div>
<?php do_action( 'opalestate_after_search_properties_form' ); ?>

View File

@ -56,7 +56,7 @@ $form_classes = [
<div class="col-lg-<?php echo absint( $grid[3] ); ?> col-md-<?php echo absint( $grid[3] ); ?> col-sm-<?php echo absint( $grid[3] ); ?> col-xs-12">
<button type="button" class="opal-collapse-button opalestate-collapse-btn btn btn-primary" data-collapse="#collapse-keyword-<?php echo esc_attr( $unique_id ); ?>">
<?php echo apply_filters( 'opalestate_search_form_collapse_button', '<i class="fa fa-caret-down" aria-hidden="true"></i>' ); ?>
<?php echo apply_filters( 'opalestate_search_form_collapse_button', '<i class="fa fa-caret-down" aria-hidden="true"></i>' ); ?>
</button>
</div>
@ -89,13 +89,17 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
</div>
<?php

View File

@ -1 +1,6 @@
<?php opalestate_property_areasize_field_template(); ?>
<?php
if ( ! opalestate_is_enable_areasize_field() ) {
return;
}
opalestate_property_areasize_field_template();

View File

@ -1,4 +1,8 @@
<?php
if ( ! opalestate_is_enable_price_field() ) {
return;
}
$search_min_price = isset( $_GET['min_price'] ) ? sanitize_text_field( $_GET['min_price'] ): opalestate_options( 'search_min_price', 0 );
$search_max_price = isset( $_GET['max_price'] ) ? sanitize_text_field( $_GET['max_price'] ): opalestate_options( 'search_max_price', 10000000 );

View File

@ -54,13 +54,18 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/types' ); ?>
</div>
<div class="col-lg-3 col-md-3 col-sm-12">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<div class="col-lg-3 col-md-3 col-sm-12">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<div class="col-lg-3 col-md-3 col-sm-12">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
<div class="col-lg-3 col-md-3 col-sm-12">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?>
<div class="col-lg-3 col-md-3 col-sm-12">
<?php echo opalestate_load_template_path( 'search-box/fields/submit-button' ); ?>

View File

@ -41,7 +41,9 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info', [ 'type' => 'input' ] ); ?>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
<?php endif; ?>
<?php
if ( $display_more_options ) {

View File

@ -22,40 +22,44 @@ $form_classes = [
<form class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $form_classes ) ) ); ?>" action="<?php echo esc_url( opalestate_get_search_link() ); ?>" method="GET">
<div class="opal-form-content">
<div class="form-item form-item--location-text">
<?php echo opalestate_load_template_path( 'search-box/fields/search-city-text' ); ?>
<?php echo opalestate_load_template_path( 'search-box/fields/search-city-text' ); ?>
</div>
<div class="form-item form-item--types">
<h6> <?php esc_html_e( 'Types', 'opalestate-pro' );?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/types' , array( 'ismultiple' => true ) ); ?>
<h6> <?php esc_html_e( 'Types', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/types', [ 'ismultiple' => true ] ); ?>
</div>
<div class="form-item form-item--information">
<h6> <?php esc_html_e( 'Information', 'opalestate-pro' );?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/group-info', array( 'type' => 'input' ) ); ?>
<div class="form-item form-item--information">
<h6> <?php esc_html_e( 'Information', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/group-info', [ 'type' => 'input' ] ); ?>
</div>
<div class="form-item form-item--price">
<h6> <?php esc_html_e( 'Price', 'opalestate-pro' );?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<div class="form-item form-item--area">
<h6> <?php esc_html_e( 'Area', 'opalestate-pro' );?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php
if ( $display_more_options ) {
echo opalestate_load_template_path( 'search-box/fields/more-options' );
}
?>
<?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?>
<div class="form-item form-item--submit">
<?php echo opalestate_load_template_path( 'search-box/fields/submit-button' ); ?>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<div class="form-item form-item--price">
<h6> <?php esc_html_e( 'Price', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<div class="form-item form-item--area">
<h6> <?php esc_html_e( 'Area', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
<?php
if ( $display_more_options ) {
echo opalestate_load_template_path( 'search-box/fields/more-options' );
}
?>
<?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?>
<div class="form-item form-item--submit">
<?php echo opalestate_load_template_path( 'search-box/fields/submit-button' ); ?>
</div>
<?php endif; ?>
</div>
<?php do_action( 'opalestate_after_search_properties_form' ); ?>

View File

@ -52,21 +52,25 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info', [ 'type' => 'input' ] ); ?>
</div>
<div class="form-item form-item--price">
<h6> <?php esc_html_e( 'Price', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php if ( opalestate_is_enable_price_field() ) : ?>
<div class="form-item form-item--price">
<h6> <?php esc_html_e( 'Price', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<div class="form-item form-item--area">
<h6> <?php esc_html_e( 'Area', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php if ( opalestate_is_enable_areasize_field() ) : ?>
<div class="form-item form-item--area">
<h6> <?php esc_html_e( 'Area', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
<?php
if ( $display_more_options ) {
echo opalestate_load_template_path( 'search-box/fields/more-options' );
}
?>
<?php
if ( $display_more_options ) {
echo opalestate_load_template_path( 'search-box/fields/more-options' );
}
?>
<?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?>
<div class="form-item form-item--submit">