From b244e8de6b0d7c72fbcdf6c966f75720606e6582 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Fri, 8 Nov 2019 08:41:22 +0700 Subject: [PATCH 1/5] Add hooks. --- inc/template-hook-functions.php | 28 +++--------------------- templates/content-single-property-v2.php | 8 +++++++ templates/content-single-property-v3.php | 8 +++++++ templates/content-single-property-v4.php | 8 +++++++ templates/content-single-property-v5.php | 8 +++++++ templates/content-single-property.php | 8 +++++++ 6 files changed, 43 insertions(+), 25 deletions(-) diff --git a/inc/template-hook-functions.php b/inc/template-hook-functions.php index 6d15ae61..6ec251a9 100755 --- a/inc/template-hook-functions.php +++ b/inc/template-hook-functions.php @@ -14,7 +14,6 @@ function opalestate_single_property_layout_default() { add_action( 'opalestate_single_property_summary', 'opalestate_property_facilities', 17 ); add_action( 'opalestate_single_property_summary', 'opalestate_property_attachments', 18 ); - add_action( 'opalestate_after_single_property_summary', 'opalestate_property_video', 20 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_virtual_tour', 25 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_map', 30 ); @@ -25,7 +24,6 @@ function opalestate_single_property_layout_default() { add_action( 'opalestate_after_single_property_summary', 'opalestate_property_apartments', 45 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_floor_plans', 45 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_views_statistics', 50 ); - // add_action( 'opalestate_after_single_property_summary', '', 55 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 ); if ( opalestate_property_reviews_enabled() ) { @@ -34,12 +32,9 @@ function opalestate_single_property_layout_default() { add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 ); - ////// sidebar //////// - add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 ); add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form', 6 ); - // add_action( 'opalestate_single_property_sidebar', 'opalestate_property_request_viewing_button', 7 ); if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); } @@ -57,11 +52,6 @@ function opalestate_single_property_layout_default() { function opalestate_single_property_layout_v2() { add_action( 'opalestate_single_property_summary', 'opalestate_get_single_short_meta', 10 ); add_action( 'opalestate_single_property_summary', 'opalestate_property_content', 12 ); - //add_action( 'opalestate_single_property_summary', 'opalestate_property_information', 15 ); - //add_action( 'opalestate_single_property_summary', 'opalestate_property_amenities', 16 ); - //add_action( 'opalestate_single_property_summary', 'opalestate_property_facilities', 17 ); - //add_action( 'opalestate_single_property_summary', 'opalestate_property_attachments', 18 ); - add_action( 'opalestate_after_single_property_summary', 'opalestate_property_video', 20 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_virtual_tour', 25 ); @@ -71,8 +61,6 @@ function opalestate_single_property_layout_v2() { add_action( 'opalestate_after_single_property_summary', 'opalestate_property_apartments', 45 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_views_statistics', 50 ); - // add_action( 'opalestate_after_single_property_summary', 'opalestate_property_author', 55 ); - add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 ); if ( opalestate_property_reviews_enabled() ) { @@ -81,14 +69,11 @@ function opalestate_single_property_layout_v2() { add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 ); - - /// /// sidebar //////// if ( opalestate_get_option( 'enable_single_mortgage', 'on' ) == 'on' ) { add_action( 'opalestate_single_property_sidebar', 'opalestate_property_mortgage', 9 ); } add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v3', 10 ); - // add_action( 'opalestate_single_property_sidebar', 'opalestate_property_equiry_form' , 12 ); } @@ -103,17 +88,14 @@ function opalestate_single_property_layout_v3() { add_action( 'opalestate_single_property_summary', 'opalestate_property_facilities', 17 ); add_action( 'opalestate_single_property_summary', 'opalestate_property_attachments', 18 ); - add_action( 'opalestate_after_single_property_summary', 'opalestate_property_video', 20 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_virtual_tour', 25 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_map', 30 ); - // add_action( 'opalestate_after_single_property_summary', 'opalestate_property_nearby', 35 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_walkscore', 40 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_apartments', 45 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_views_statistics', 50 ); - // add_action( 'opalestate_after_single_property_summary', 'opalestate_property_author', 55 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 ); if ( opalestate_property_reviews_enabled() ) { @@ -177,7 +159,6 @@ function opalestate_single_property_layout_v5() { add_action( 'opalestate_single_property_summary', 'opalestate_property_facilities', 17 ); add_action( 'opalestate_single_property_summary', 'opalestate_property_attachments', 18 ); - add_action( 'opalestate_after_single_property_summary', 'opalestate_property_video', 20 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_virtual_tour', 25 ); add_action( 'opalestate_after_single_property_summary', 'opalestate_property_map', 30 ); @@ -209,14 +190,10 @@ function opalestate_single_property_layout_v5() { } } - -/// add_action( 'opalestate_single_property_after_render', 'opalestate_properties_related', 5 ); add_action( 'opalestate_single_property_after_render', 'opalestate_properties_nearby', 6 ); - add_action( 'opalestate_single_property_preview', 'opalestate_property_preview', 15 ); - function opalestate_property_request_viewing_button( $islink = false ) { if ( 'on' != opalestate_get_option( 'enable_single_request_viewing', 'on' ) ) { return; @@ -236,7 +213,9 @@ function opalestate_property_request_viewing_button( $islink = false ) { } /** - * @param $layout + * Get single layout. + * + * @param string $layout Layout. */ function opalestate_single_property_layout( $layout ) { switch ( $layout ) { @@ -334,7 +313,6 @@ function opalestate_load_plugin_template( $template ) { } else { $template = OPALESTATE_PLUGIN_DIR . '/templates/fullwidth-page.php'; } - } if ( $template == '' ) { diff --git a/templates/content-single-property-v2.php b/templates/content-single-property-v2.php index 5a924489..54bb5fd1 100755 --- a/templates/content-single-property-v2.php +++ b/templates/content-single-property-v2.php @@ -14,10 +14,14 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
+ + ', '' ); ?> + +
@@ -88,6 +92,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
    + + get_sku() ) : ?>
  • @@ -103,6 +109,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
  • + +
diff --git a/templates/content-single-property-v3.php b/templates/content-single-property-v3.php index fd543e36..c345c7cc 100755 --- a/templates/content-single-property-v3.php +++ b/templates/content-single-property-v3.php @@ -13,6 +13,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
    + +
  • @@ -24,6 +26,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
  • + +
@@ -38,10 +42,14 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
+ + ', '' ); ?> + +
diff --git a/templates/content-single-property-v4.php b/templates/content-single-property-v4.php index 18fff383..9c65b6e1 100755 --- a/templates/content-single-property-v4.php +++ b/templates/content-single-property-v4.php @@ -11,10 +11,14 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
+ + ', '' ); ?> + +
@@ -58,6 +62,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
    + + get_sku() ) : ?>
  • @@ -73,6 +79,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
  • + +
diff --git a/templates/content-single-property-v5.php b/templates/content-single-property-v5.php index 60ac1a5d..e1ca823d 100755 --- a/templates/content-single-property-v5.php +++ b/templates/content-single-property-v5.php @@ -51,10 +51,14 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
+ + ', '' ); ?> + +
@@ -91,6 +95,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
    + + get_sku() ) : ?>
  • @@ -103,6 +109,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
  • + +
diff --git a/templates/content-single-property.php b/templates/content-single-property.php index efbe5f5c..f54ee9a6 100755 --- a/templates/content-single-property.php +++ b/templates/content-single-property.php @@ -9,10 +9,14 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
+ + ', '' ); ?> + +
@@ -63,6 +67,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
    + + get_sku() ) : ?>
  • @@ -78,6 +84,8 @@ $header = apply_filters( 'opalestate_single_show_heading', true );
  • + +
From 6ffab800930166d4655f46c17d52972767ff454e Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Fri, 8 Nov 2019 09:16:13 +0700 Subject: [PATCH 2/5] Add body classes. --- inc/template-functions.php | 27 +++++++++++++++++++++++++++ inc/template-hook-functions.php | 5 +++++ 2 files changed, 32 insertions(+) diff --git a/inc/template-functions.php b/inc/template-functions.php index 3a6a6ea9..a43d73e8 100755 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -10,6 +10,33 @@ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } +/** + * Add body classes for Opalestate pages. + * + * @param array $classes Body Classes. + * @return array + */ +function opalestate_body_class( $classes ) { + $classes = (array) $classes; + + $classes[] = 'opalestate-active'; + + if ( is_user_logged_in() ) { + $current_user = wp_get_current_user(); + + if ( $current_user ) { + $roles = $current_user->roles; + if ( $roles && is_array( $roles ) ) { + foreach ( $roles as $role ) { + $classes[] = 'opalestate-role-' . esc_attr( $role ); + } + } + } + } + + return array_unique( $classes ); +} + function opalestate_archive_search_block() { echo opalestate_load_template_path( 'parts/archive-search-block' ); } diff --git a/inc/template-hook-functions.php b/inc/template-hook-functions.php index 6ec251a9..697c64f4 100755 --- a/inc/template-hook-functions.php +++ b/inc/template-hook-functions.php @@ -1,4 +1,9 @@ Date: Fri, 8 Nov 2019 13:30:08 +0700 Subject: [PATCH 3/5] Update --- opal-estate-pro.php | 6 +++--- readme.txt | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/opal-estate-pro.php b/opal-estate-pro.php index 5695b791..6579b7c6 100755 --- a/opal-estate-pro.php +++ b/opal-estate-pro.php @@ -3,7 +3,7 @@ * Plugin Name: Opal Estate Pro * Plugin URI: https://wpdocs.gitbook.io/opal-estate/ * Description: Opal Real Estate Plugin is an ideal solution and brilliant choice for you to set up a professional estate website. - * Version: 1.1.9 + * Version: 1.1.9.1 * Author: WPOPAL * Author URI: http://www.wpopal.com * Requires at least: 4.6 @@ -151,7 +151,7 @@ if ( ! class_exists( 'OpalEstate' ) ) { */ public function __clone() { // Cloning instances of the class is forbidden - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.1.9' ); + _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.1.9.1' ); } /** @@ -160,7 +160,7 @@ if ( ! class_exists( 'OpalEstate' ) ) { public function setup_constants() { // Plugin version if ( ! defined( 'OPALESTATE_VERSION' ) ) { - define( 'OPALESTATE_VERSION', '1.1.9' ); + define( 'OPALESTATE_VERSION', '1.1.9.1' ); } // Plugin Folder Path diff --git a/readme.txt b/readme.txt index 55d56962..8395f41b 100755 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://wpdocs.gitbook.io/opal-estate/ Tags: estate, property, opalestate, house for rent, agency for lease, estate submission, agents estate property, property marketplace Requires at least: 4.6 Tested up to: 5.2.3 -Stable tag: 1.1.9 +Stable tag: 1.1.9.1 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -156,6 +156,9 @@ This section describes how to install the plugin and get it working. * System tickets support 24/7 available : [free support](https://wpopal.ticksy.com/ "Visit the Plugin support Page") == Changelog == += 1.1.9 - 2019-11-08 = +* Added - Template hooks. + = 1.1.9 - 2019-11-07 = * Fixes - Dashboard page. * Added - Expired properties. From f171fe17f7ddf78bab644a8c1f834a40989d8f9c Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Mon, 11 Nov 2019 15:15:28 +0700 Subject: [PATCH 4/5] Update search --- inc/api/functions.php | 19 +++++++++++++++---- inc/property/class-opalestate-search.php | 3 +-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/inc/api/functions.php b/inc/api/functions.php index 84e996d5..ede19273 100644 --- a/inc/api/functions.php +++ b/inc/api/functions.php @@ -139,10 +139,21 @@ function opalestate_api_get_property_data( $property_info ) { $property['labels'] = $data->get_labels(); $property['locations'] = $data->get_locations(); $property['facilities'] = $data->get_facilities(); - $property['amenities'] = $data->get_amenities(); - $property['types'] = $data->get_types_tax(); - $property['author_type'] = $data->get_author_type(); - $property['author_data'] = $data->get_author_link_data(); + + $amenities = $data->get_amenities(); + $amenities_result = []; + if ( $amenities ) { + foreach ( $amenities as $amenity ) { + $value = has_term( $amenity->term_id, 'opalestate_amenities', $property_info->ID ); + $amenity->value = $value; + $amenities_result[] = $amenity; + } + } + + $property['amenities'] = $amenities_result; + $property['types'] = $data->get_types_tax(); + $property['author_type'] = $data->get_author_type(); + $property['author_data'] = $data->get_author_link_data(); $limit = opalestate_get_option( 'single_views_statistics_limit', 8 ); $stats = new Opalestate_View_Stats( $data->get_id(), $limit ); diff --git a/inc/property/class-opalestate-search.php b/inc/property/class-opalestate-search.php index 9f6365e5..46933060 100755 --- a/inc/property/class-opalestate-search.php +++ b/inc/property/class-opalestate-search.php @@ -114,7 +114,7 @@ class OpalEstate_Search { [ 'taxonomy' => 'opalestate_amenities', 'field' => 'slug', - 'terms' => sanitize_text_field( $_GET['amenities'] ), + 'terms' => ( $_GET['amenities'] ), ]; } @@ -153,7 +153,6 @@ class OpalEstate_Search { if ( $search_min_price != '' && $search_max_price != '' && is_numeric( $search_min_price ) && is_numeric( $search_max_price ) ) { if ( $search_min_price ) { - array_push( $args['meta_query'], [ 'key' => OPALESTATE_PROPERTY_PREFIX . 'price', 'value' => [ $search_min_price, $search_max_price ], From 23b5505a4278ee7f118223ce62c6f5b65b11a7ba Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Mon, 18 Nov 2019 11:27:56 +0700 Subject: [PATCH 5/5] Remove required price --- inc/api/v1/property.php | 75 ++++++++++++------- inc/property/class-metabox-property-admin.php | 1 - 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/inc/api/v1/property.php b/inc/api/v1/property.php index b9fc76e2..e7f8e8dd 100644 --- a/inc/api/v1/property.php +++ b/inc/api/v1/property.php @@ -366,7 +366,7 @@ class Opalestate_Property_Api extends Opalestate_Base_API { [ 'taxonomy' => 'opalestate_amenities', 'field' => 'slug', - 'terms' => sanitize_text_field( $request['amenities'] ), + 'terms' => ( $request['amenities'] ), ]; } @@ -376,29 +376,46 @@ class Opalestate_Property_Api extends Opalestate_Base_API { } $args['meta_query'] = [ 'relation' => 'AND' ]; - if ( isset( $request['info'] ) && is_array( $request['info'] ) ) { - $metaquery = []; - foreach ( $request['info'] as $key => $value ) { - if ( trim( $value ) ) { - if ( is_numeric( trim( $value ) ) ) { - $fieldquery = [ - 'key' => OPALESTATE_PROPERTY_PREFIX . $key, - 'value' => sanitize_text_field( trim( $value ) ), - 'compare' => apply_filters( 'opalestate_info_numeric_compare', '>=' ), - 'type' => 'NUMERIC', - ]; - } else { - $fieldquery = [ - 'key' => OPALESTATE_PROPERTY_PREFIX . $key, - 'value' => sanitize_text_field( trim( $value ) ), - 'compare' => 'LIKE', - ]; - } - $sarg = apply_filters( 'opalestate_search_field_query_' . $key, $fieldquery ); - $metaquery[] = $sarg; + + if ( isset( $request['info'] ) ) { + $info_array = []; + if ( is_array( $request['info'] ) ) { + $info_array = $request['info']; + } elseif ( is_string( $request['info'] ) ) { + $info = $request['info']; + $array = json_decode($info); + $array = json_decode(json_encode($array), true); + + if ( is_array( $array ) ) { + $info_array = $array; } } - $args['meta_query'] = array_merge( $args['meta_query'], $metaquery ); + + if ( $info_array && ! empty($info_array) ) { + $metaquery = []; + foreach ( $info_array as $key => $value ) { + if ( trim( $value ) ) { + if ( is_numeric( trim( $value ) ) ) { + $fieldquery = [ + 'key' => OPALESTATE_PROPERTY_PREFIX . $key, + 'value' => sanitize_text_field( trim( $value ) ), + 'compare' => apply_filters( 'opalestate_info_numeric_compare', '>=' ), + 'type' => 'NUMERIC', + ]; + } else { + $fieldquery = [ + 'key' => OPALESTATE_PROPERTY_PREFIX . $key, + 'value' => sanitize_text_field( trim( $value ) ), + 'compare' => 'LIKE', + ]; + } + $sarg = apply_filters( 'opalestate_search_field_query_' . $key, $fieldquery ); + $metaquery[] = $sarg; + } + } + + $args['meta_query'] = array_merge( $args['meta_query'], $metaquery ); + } } if ( $search_min_price != '' && $search_min_price != '' && is_numeric( $search_min_price ) && is_numeric( $search_max_price ) ) { @@ -637,13 +654,13 @@ class Opalestate_Property_Api extends Opalestate_Base_API { 'validate_callback' => 'rest_validate_request_arg', ]; - $params['info'] = [ - 'description' => __( 'Info', 'opalestate-pro' ), - 'type' => 'array', - // 'default' => '', - // 'sanitize_callback' => 'sanitize_text_field', - 'validate_callback' => 'rest_validate_request_arg', - ]; + // $params['info'] = [ + // 'description' => __( 'Info', 'opalestate-pro' ), + // 'type' => 'array', + // // 'default' => '', + // // 'sanitize_callback' => 'sanitize_text_field', + // 'validate_callback' => 'rest_validate_request_arg', + // ]; return $params; } diff --git a/inc/property/class-metabox-property-admin.php b/inc/property/class-metabox-property-admin.php index 1b38fa0a..4b929220 100755 --- a/inc/property/class-metabox-property-admin.php +++ b/inc/property/class-metabox-property-admin.php @@ -240,7 +240,6 @@ class Opalestate_Property_MetaBox { 'name' => esc_html__( 'Regular Price', 'opalestate-pro' ) . $currency, 'type' => 'text', 'description' => esc_html__( 'Enter amount without currency', 'opalestate-pro' ), - 'attributes' => [ 'required' => 'required' ], 'before_row' => '

' . ( is_admin() ? "" : esc_html__( 'Price', 'opalestate-pro' ) ) . '

', // callback ], [