This commit is contained in:
Hoang Huu 2020-06-25 10:00:06 +07:00
parent ab00de6716
commit 6298197d8f
8 changed files with 117 additions and 33 deletions

View File

@ -1,3 +1,7 @@
= 1.6 - 2020-06-25 =
* Added - Related properties setting
* Added - Nearby properties setting
= 1.5.9 - 2020-06-22 =
* Added - Currency
* Fixes - Subscriber admin bar

View File

@ -371,6 +371,7 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab {
'id' => 'layout',
'type' => 'select',
'options' => apply_filters( 'opalestate_single_layout_templates', [ '' => esc_html__( 'Inherit', 'opalestate-pro' ) ] ),
'after_row' => '<hr>',
];
$fields[] = [
@ -379,6 +380,7 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab {
'id' => 'single_preview',
'type' => 'select',
'options' => opalestate_single_layout_preview(),
'after_row' => '<hr>',
];
$fields[] = [
@ -610,21 +612,88 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab {
'after_row' => '<hr>',
];
$fields[] = [
'name' => esc_html__( 'Show Related properties', 'opalestate-pro' ),
'desc' => esc_html__( 'Show Related properties the single property page.', 'opalestate-pro' ),
'id' => 'enable_single_related_properties',
'type' => 'switch',
'options' => [
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
],
'default' => 'on',
];
$fields[] = [
'name' => esc_html__( 'Related properties layout', 'opalestate-pro' ),
'desc' => esc_html__( 'Select a layout for related properties.', 'opalestate-pro' ),
'id' => 'single_related_properties_layout',
'type' => 'select',
'options' => opalestate_get_loop_property_layouts(),
];
$fields[] = [
'name' => esc_html__( 'Number of properties', 'opalestate-pro' ),
'id' => 'single_related_number',
'type' => 'text_small',
'attributes' => [
'type' => 'number',
'min' => 1,
],
'default' => 6,
'after_row' => '<hr>',
];
$fields[] = [
'name' => esc_html__( 'Show Nearby properties', 'opalestate-pro' ),
'desc' => esc_html__( 'Show Nearby properties in the single property page.', 'opalestate-pro' ),
'id' => 'enable_single_nearby_properties',
'type' => 'switch',
'options' => [
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
],
'default' => 'on',
];
$fields[] = [
'name' => esc_html__( 'Nearby properties layout', 'opalestate-pro' ),
'desc' => esc_html__( 'Select a layout for nearby properties.', 'opalestate-pro' ),
'id' => 'single_nearby_properties_layout',
'type' => 'select',
'options' => opalestate_get_loop_property_layouts(),
];
$fields[] = [
'name' => esc_html__( 'Nearby Radius', 'opalestate-pro' ),
'id' => 'single_nearby_radius',
'type' => 'text_small',
'attributes' => [
'type' => 'number',
'min' => 1,
],
'default' => 5,
];
$fields[] = [
'name' => esc_html__( 'Nearby Measure Unit', 'opalestate-pro' ),
'id' => 'single_nearby_measure_unit',
'type' => 'select',
'options' => [
'km' => esc_html__( 'km', 'opalestate-pro' ),
'miles' => esc_html__( 'miles', 'opalestate-pro' ),
],
];
$fields[] = [
'name' => esc_html__( 'Number of properties', 'opalestate-pro' ),
'id' => 'single_nearby_number',
'type' => 'text_small',
'attributes' => [
'type' => 'number',
'min' => 1,
],
'default' => 6,
'after_row' => '<hr>',
];

View File

@ -494,7 +494,7 @@ class Opalestate_Property_Api extends Opalestate_Base_API {
} elseif ( $request['geo_lat'] && $request['geo_long'] ) {
$radius_measure = isset( $request['radius_measure'] ) ? sanitize_text_field( $request['radius_measure'] ) : 'km';
$radius = isset( $request['geo_radius'] ) ? sanitize_text_field( $request['geo_radius'] ) : 10;
$post_ids = Opalestate_Query::filter_by_location( sanitize_text_field( $request['geo_lat'] ), sanitize_text_field( $request['geo_long'] ), $radius_measure, $radius );
$post_ids = Opalestate_Query::filter_by_location( sanitize_text_field( $request['geo_lat'] ), sanitize_text_field( $request['geo_long'] ), $radius, $radius_measure );
$args['post__in'] = $post_ids;
}
}

View File

@ -291,7 +291,7 @@ class OpalEstate_Search {
} elseif ( $_GET['geo_lat'] && $_GET['geo_long'] ) {
$radius_measure = isset( $_GET['radius_measure'] ) ? sanitize_text_field( $_GET['radius_measure'] ) : 'km';
$radius = isset( $_GET['geo_radius'] ) ? sanitize_text_field( $_GET['geo_radius'] ) : 10;
$post_ids = Opalestate_Query::filter_by_location( sanitize_text_field( $_GET['geo_lat'] ), sanitize_text_field( $_GET['geo_long'] ), $radius_measure, $radius );
$post_ids = Opalestate_Query::filter_by_location( sanitize_text_field( $_GET['geo_lat'] ), sanitize_text_field( $_GET['geo_long'] ), $radius, $radius_measure );
$args['post__in'] = $post_ids;
}
}

View File

@ -787,8 +787,11 @@ function opalestate_get_property_walkscore_score( $property ) {
* Gets related properties template.
*/
function opalestate_properties_related() {
if ( 'on' !== opalestate_get_option( 'enable_single_related_properties', 'on' ) ) {
return;
}
$num = apply_filters( 'opalestate_related_properties_number', 6 );
$num = opalestate_get_option( 'single_related_number', 6 );
$args = [
'post_type' => 'opalestate_property',
'posts_per_page' => $num,
@ -819,7 +822,6 @@ function opalestate_properties_related() {
];
}
if ( $tax_query ) {
$args['tax_query'] = [ 'relation' => 'AND' ];
$args['tax_query'] = array_merge( $args['tax_query'], $tax_query );
@ -840,10 +842,14 @@ function opalestate_properties_related() {
* Gets nearby properties template.
*/
function opalestate_properties_nearby() {
if ( 'on' !== opalestate_get_option( 'enable_single_nearby_properties', 'on' ) ) {
return;
}
global $property;
$maps = $property->get_map();
$num = apply_filters( 'opalestate_nearby_properties_number', 6 );
$num = opalestate_get_option( 'single_nearby_number', 6 );
$post_id = get_the_ID();
$args = [
@ -858,8 +864,9 @@ function opalestate_properties_nearby() {
return;
}
$radius = 5;
$post_ids = Opalestate_Query::filter_by_location( $geo_lat, $geo_long, 'km', $radius );
$radius = opalestate_get_option( 'single_nearby_radius', 5 );
$measure_unit = opalestate_get_option( 'single_nearby_measure_unit', 'km' );
$post_ids = Opalestate_Query::filter_by_location( $geo_lat, $geo_long, $radius, $measure_unit );
if ( empty( $post_ids ) ) {
return;

View File

@ -178,7 +178,7 @@ class OpalEstate_User {
return false;
}
if ( in_array( 'subscriber', $roles ) && opalestate_is_user_management_page() ) {
if ( in_array( 'subscriber', $roles ) ) {
return false;
}
}

View File

@ -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.5.9
* Version: 1.6
* Author: WPOPAL
* Author URI: http://www.wpopal.com
* Requires at least: 4.9
@ -154,7 +154,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
*/
public function __clone() {
// Cloning instances of the class is forbidden
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'opalestate-pro' ), '1.5.9' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'opalestate-pro' ), '1.6' );
}
/**
@ -163,7 +163,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
public function setup_constants() {
// Plugin version
if ( ! defined( 'OPALESTATE_VERSION' ) ) {
define( 'OPALESTATE_VERSION', '1.5.9' );
define( 'OPALESTATE_VERSION', '1.6' );
}
// Plugin Folder Path

View File

@ -150,6 +150,10 @@ This section describes how to install the plugin and get it working.
* System tickets support 24/7 available : [free support](https://themelexus.ticksy.com/ "Visit the Plugin support Page")
== Changelog ==
= 1.6 - 2020-06-25 =
* Added - Related properties setting
* Added - Nearby properties setting
= 1.5.9 - 2020-06-22 =
* Added - Currency
* Fixes - Subscriber admin bar