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_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'] ) : ''; $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; $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; $paged = isset( $request['page'] ) && $request['page'] ? $request['page'] : 1;
if ( isset( $request['paged'] ) && intval( $request['paged'] ) > 0 ) { if ( isset( $request['paged'] ) && intval( $request['paged'] ) > 0 ) {

View File

@ -1169,7 +1169,7 @@ function opalestate_get_property_statuses() {
* @param $key * @param $key
*/ */
function opalestate_get_property_meta_icon( $key ) { function opalestate_get_property_meta_icon( $key ) {
$classes = ''; $classes = '';
$classes .= 'icon-property-' . esc_attr( $key ); $classes .= 'icon-property-' . esc_attr( $key );
switch ( $key ) { switch ( $key ) {
@ -1214,3 +1214,21 @@ function opalestate_get_property_meta_icon( $key ) {
return $classes; 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' ); ?> <?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?>
<div class="col-lg-3 col-md-3 col-sm-3"> <?php if ( opalestate_is_enable_price_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?> <div class="col-lg-3 col-md-3 col-sm-3">
</div> <?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 if ( opalestate_is_enable_areasize_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?> <div class="col-lg-3 col-md-3 col-sm-3">
</div> <?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
</div> </div>
<?php <?php

View File

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

View File

@ -51,12 +51,12 @@ $form_classes = [
</div> </div>
<div class="searchbox-field searchbox-field--categories"> <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>
<div class="searchbox-field searchbox-field--collapse"> <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 ); ?>"> <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> </button>
</div> </div>
@ -71,13 +71,17 @@ $form_classes = [
<div class="opal-row"> <div class="opal-row">
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?> <?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 if ( opalestate_is_enable_price_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
</div> <?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 if ( opalestate_is_enable_areasize_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
</div> <?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
</div> </div>
<?php <?php

View File

@ -7,7 +7,7 @@
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
$unique_id = esc_attr( wp_unique_id() ); $unique_id = esc_attr( wp_unique_id() );
$GLOBALS['group-info-column'] = 4; $GLOBALS['group-info-column'] = 4;
if ( isset( $nobutton ) && $nobutton ) { 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"> <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 ); ?>"> <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> </button>
</div> </div>
@ -67,20 +67,24 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?> <?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 if ( opalestate_is_enable_price_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
</div> <?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 if ( opalestate_is_enable_areasize_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
</div> <?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
</div> </div>
<?php <?php
if ( $display_more_options ) { if ( $display_more_options ) {
echo opalestate_load_template_path( 'search-box/fields/more-options' ); echo opalestate_load_template_path( 'search-box/fields/more-options' );
} }
?> ?>
</div> </div>
<?php do_action( 'opalestate_after_search_properties_form' ); ?> <?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"> <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 ); ?>"> <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> </button>
</div> </div>
@ -89,13 +89,17 @@ $form_classes = [
<?php echo opalestate_load_template_path( 'search-box/fields/group-info' ); ?> <?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 if ( opalestate_is_enable_price_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
</div> <?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 if ( opalestate_is_enable_areasize_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
</div> <?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
</div> </div>
<?php <?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 <?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_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 ); $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' ); ?> <?php echo opalestate_load_template_path( 'search-box/fields/types' ); ?>
</div> </div>
<div class="col-lg-3 col-md-3 col-sm-12"> <?php if ( opalestate_is_enable_price_field() ) : ?>
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?> <div class="col-lg-3 col-md-3 col-sm-12">
</div> <?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 ) : ?> <?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?>
<div class="col-lg-3 col-md-3 col-sm-12"> <div class="col-lg-3 col-md-3 col-sm-12">
<?php echo opalestate_load_template_path( 'search-box/fields/submit-button' ); ?> <?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/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 <?php
if ( $display_more_options ) { 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"> <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="opal-form-content">
<div class="form-item form-item--location-text"> <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>
<div class="form-item form-item--types"> <div class="form-item form-item--types">
<h6> <?php esc_html_e( 'Types', 'opalestate-pro' );?></h6> <h6> <?php esc_html_e( 'Types', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/types' , array( 'ismultiple' => true ) ); ?> <?php echo opalestate_load_template_path( 'search-box/fields/types', [ 'ismultiple' => true ] ); ?>
</div> </div>
<div class="form-item form-item--information"> <div class="form-item form-item--information">
<h6> <?php esc_html_e( 'Information', 'opalestate-pro' );?></h6> <h6> <?php esc_html_e( 'Information', 'opalestate-pro' ); ?></h6>
<?php echo opalestate_load_template_path( 'search-box/fields/group-info', array( 'type' => 'input' ) ); ?> <?php echo opalestate_load_template_path( 'search-box/fields/group-info', [ 'type' => 'input' ] ); ?>
</div> </div>
<div class="form-item form-item--price"> <?php if ( opalestate_is_enable_price_field() ) : ?>
<h6> <?php esc_html_e( 'Price', 'opalestate-pro' );?></h6> <div class="form-item form-item--price">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?> <h6> <?php esc_html_e( 'Price', 'opalestate-pro' ); ?></h6>
</div> <?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
<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' ); ?>
</div> </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> </div>
<?php do_action( 'opalestate_after_search_properties_form' ); ?> <?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' ] ); ?> <?php echo opalestate_load_template_path( 'search-box/fields/group-info', [ 'type' => 'input' ] ); ?>
</div> </div>
<div class="form-item form-item--price"> <?php if ( opalestate_is_enable_price_field() ) : ?>
<h6> <?php esc_html_e( 'Price', 'opalestate-pro' ); ?></h6> <div class="form-item form-item--price">
<?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?> <h6> <?php esc_html_e( 'Price', 'opalestate-pro' ); ?></h6>
</div> <?php echo opalestate_load_template_path( 'search-box/fields/price' ); ?>
</div>
<?php endif; ?>
<div class="form-item form-item--area"> <?php if ( opalestate_is_enable_areasize_field() ) : ?>
<h6> <?php esc_html_e( 'Area', 'opalestate-pro' ); ?></h6> <div class="form-item form-item--area">
<?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?> <h6> <?php esc_html_e( 'Area', 'opalestate-pro' ); ?></h6>
</div> <?php echo opalestate_load_template_path( 'search-box/fields/areasize' ); ?>
</div>
<?php endif; ?>
<?php <?php
if ( $display_more_options ) { if ( $display_more_options ) {
echo opalestate_load_template_path( 'search-box/fields/more-options' ); echo opalestate_load_template_path( 'search-box/fields/more-options' );
} }
?> ?>
<?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?> <?php if ( ! isset( $nobutton ) || ! $nobutton ) : ?>
<div class="form-item form-item--submit"> <div class="form-item form-item--submit">