diff --git a/inc/api/v1/agency.php b/inc/api/v1/agency.php
index 22f7f36c..fe8d9cde 100755
--- a/inc/api/v1/agency.php
+++ b/inc/api/v1/agency.php
@@ -188,11 +188,18 @@ class Opalestate_Agency_Api extends Opalestate_Base_API {
$ouput['featured'] = $agency->is_featured();
$ouput['trusted'] = $agency->get_trusted();
$ouput['email'] = $agency->get_meta( 'email' );
+ $ouput['website'] = $agency->get_meta( 'website' );
+ $ouput['phone'] = $agency->get_meta( 'phone' );
+ $ouput['mobile'] = $agency->get_meta( 'mobile' );
+ $ouput['fax'] = $agency->get_meta( 'fax' );
$ouput['address'] = $agency->get_meta( 'address' );
$ouput['map'] = $agency->get_meta( 'map' );
$terms = wp_get_post_terms( $agency_info->ID, 'opalestate_agency_location' );
$ouput['location'] = $terms && ! is_wp_error( $terms ) ? $terms : [];
$ouput['socials'] = $agency->get_socials();
+ $properties = $this->get_properties( $agency_info->ID );
+ $ouput['listing_count'] = count( $properties );
+ $ouput['listings'] = $properties;
return apply_filters( 'opalestate_api_agencies', $ouput );
}
@@ -283,4 +290,67 @@ class Opalestate_Agency_Api extends Opalestate_Base_API {
return $params;
}
+
+ /**
+ * Get agent listings.
+ *
+ * @param int $id Agency ID.
+ * @return array
+ */
+ public function get_properties( $id ) {
+ $properties = [];
+ if ( $id > 0 ) {
+ $post = get_post( $id );
+ if ( $post && $this->post_type == get_post_type( $id ) ) {
+ $user_id = get_post_meta( $id, OPALESTATE_AGENCY_PREFIX . 'user_id', true );
+ $agents = get_post_meta( $id, OPALESTATE_AGENCY_PREFIX . 'team', true );
+
+ if ( $user_id ) {
+ $author = [ $user_id ];
+ $agents = get_post_meta( $id, OPALESTATE_AGENCY_PREFIX . 'team', true );
+
+ if ( is_array( $agents ) ) {
+ $author = array_merge( $author, $agents );
+ }
+
+ $args = [
+ 'post_type' => 'opalestate_property',
+ 'author__in' => $author,
+ 'posts_per_page' => -1,
+ ];
+ } else {
+ $args = [
+ 'post_type' => 'opalestate_property',
+ 'posts_per_page' => -1,
+ ];
+ $args['meta_query'] = [ 'relation' => 'OR' ];
+ array_push( $args['meta_query'], [
+ 'key' => OPALESTATE_PROPERTY_PREFIX . 'agency',
+ 'value' => $id,
+ 'compare' => '=',
+ ] );
+
+ if ( $agents ) {
+ array_push( $args['meta_query'], [
+ 'key' => OPALESTATE_PROPERTY_PREFIX . 'agent',
+ 'value' => $agents,
+ ] );
+ }
+ }
+
+ $property_list = get_posts( $args );
+
+ if ( $property_list ) {
+ $i = 0;
+ foreach ( $property_list as $property_info ) {
+ $properties[ $i ] = opalestate_api_get_property_data( $property_info );
+ $i++;
+ }
+ }
+
+ }
+ }
+
+ return $properties;
+ }
}
diff --git a/inc/api/v1/agent.php b/inc/api/v1/agent.php
index f7fd33b7..a574133e 100755
--- a/inc/api/v1/agent.php
+++ b/inc/api/v1/agent.php
@@ -246,13 +246,22 @@ class Opalestate_Agent_Api extends Opalestate_Base_API {
$ouput['featured'] = $agent->is_featured();
$ouput['trusted'] = $agent->get_trusted();
$ouput['email'] = $agent->get_meta( 'email' );
+ $ouput['website'] = $agent->get_meta( 'website' );
+ $ouput['phone'] = $agent->get_meta( 'phone' );
+ $ouput['mobile'] = $agent->get_meta( 'mobile' );
+ $ouput['fax'] = $agent->get_meta( 'fax' );
+ $ouput['job'] = $agent->get_meta( 'job' );
+ $ouput['company'] = $agent->get_meta( 'company' );
$ouput['address'] = $agent->get_meta( 'address' );
$ouput['map'] = $agent->get_meta( 'map' );
- $terms = wp_get_post_terms( $agent_info->ID, 'opalestate_agent_location' );
- $ouput['location'] = $terms && ! is_wp_error( $terms ) ? $terms : [];
- $ouput['socials'] = $agent->get_socials();
- $ouput['levels'] = wp_get_post_terms( $agent_info->ID, 'opalestate_agent_level' );
+ $terms = wp_get_post_terms( $agent_info->ID, 'opalestate_agent_location' );
+ $ouput['location'] = $terms && ! is_wp_error( $terms ) ? $terms : [];
+ $ouput['socials'] = $agent->get_socials();
+ $ouput['levels'] = wp_get_post_terms( $agent_info->ID, 'opalestate_agent_level' );
+ $properties = $this->get_properties( $agent_info->ID );
+ $ouput['listing_count'] = count( $properties );
+ $ouput['listing'] = $properties;
return apply_filters( 'opalestate_api_agents', $ouput );
}
@@ -267,4 +276,52 @@ class Opalestate_Agent_Api extends Opalestate_Base_API {
return $params;
}
+
+ /**
+ * Get agent listings.
+ *
+ * @param int $id Agent ID
+ * @return array
+ */
+ public function get_properties( $id ) {
+ $properties = [];
+ if ( $id > 0 ) {
+ $post = get_post( $id );
+ if ( $post && $this->post_type == get_post_type( $id ) ) {
+
+ $user_id = get_post_meta( $id, OPALESTATE_AGENT_PREFIX . 'user_id', true );
+
+ $args = [
+ 'post_type' => 'opalestate_property',
+ 'posts_per_page' => -1,
+ 'post__not_in' => [ $id ],
+ 'post_status' => 'publish',
+ ];
+
+ $args['meta_query'] = [ 'relation' => 'AND' ];
+
+ if ( $user_id ) {
+ $args['author'] = $user_id;
+ } else {
+ array_push( $args['meta_query'], [
+ 'key' => OPALESTATE_PROPERTY_PREFIX . 'agent',
+ 'value' => $id,
+ 'compare' => '=',
+ ] );
+ }
+
+ $property_list = get_posts( $args );
+
+ if ( $property_list ) {
+ $i = 0;
+ foreach ( $property_list as $property_info ) {
+ $properties[ $i ] = opalestate_api_get_property_data( $property_info );
+ $i++;
+ }
+ }
+ }
+ }
+
+ return $properties;
+ }
}
diff --git a/inc/function-search-fields.php b/inc/function-search-fields.php
index 6e7577e3..e39f9875 100755
--- a/inc/function-search-fields.php
+++ b/inc/function-search-fields.php
@@ -119,10 +119,15 @@ function opalestate_property_render_field_template( $field, $label, $type = 'sel
function opalestate_property_areasize_field_template( $template = '' ) {
$search_min = isset( $_GET['min_area'] ) ? sanitize_text_field( $_GET['min_area'] ) : opalestate_options( 'search_min_area', 0 );
$search_max = isset( $_GET['max_area'] ) ? sanitize_text_field( $_GET['max_area'] ) : opalestate_options( 'search_max_area', 1000 );
+ $measurement_units = opalestate_get_measurement_units();
+ $unit = opalestate_options( 'measurement_unit', 'sqft' );
+ if ( isset( $measurement_units[ $unit ] ) ) {
+ $unit = $measurement_units[ $unit ];
+ }
$data = [
'id' => 'area',
- 'unit' => opalestate_options( 'measurement_unit', 'sq ft' ) . ' ',
+ 'unit' => $unit . ' ',
'ranger_min' => opalestate_options( 'search_min_area', 0 ),
'ranger_max' => opalestate_options( 'search_max_area', 1000 ),
'input_min' => $search_min,
diff --git a/inc/mixes-functions.php b/inc/mixes-functions.php
index 86f1cf71..54940a46 100755
--- a/inc/mixes-functions.php
+++ b/inc/mixes-functions.php
@@ -40,7 +40,7 @@ function opalestate_output_msg_json( $result = false, $message = '', $args = [],
* Process upload images for properties
*/
function opalesate_upload_image( $submitted_file, $parent_id = 0 ) {
- require_once ABSPATH . 'wp-admin/includes/image.php';
+ require_once ABSPATH . 'wp-admin/includes/image.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/media.php';
@@ -1062,7 +1062,13 @@ function opalestate_price( $price, $args = [] ) {
*/
function opalestate_areasize_unit_format( $value = '' ) {
- return $value . ' ' . '' . opalestate_options( 'measurement_unit', 'sq ft' ) . '';
+ $measurement_units = opalestate_get_measurement_units();
+ $unit = opalestate_options( 'measurement_unit', 'sqft' );
+ if ( isset( $measurement_units[ $unit ] ) ) {
+ $unit = $measurement_units[ $unit ];
+ }
+
+ return sprintf( _x( '%1$s %2$s', 'areasize info','opalestate-pro' ), $value, $unit );
}
add_filter( 'opalestate_areasize_unit_format', 'opalestate_areasize_unit_format' );
diff --git a/opal-estate-pro.php b/opal-estate-pro.php
index b2f7a415..bc7d06e2 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.2
+ * Version: 1.1.9.3
* 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.2' );
+ _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.1.9.3' );
}
/**
@@ -160,7 +160,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
public function setup_constants() {
// Plugin version
if ( ! defined( 'OPALESTATE_VERSION' ) ) {
- define( 'OPALESTATE_VERSION', '1.1.9.2' );
+ define( 'OPALESTATE_VERSION', '1.1.9.3' );
}
// Plugin Folder Path
diff --git a/readme.txt b/readme.txt
index 910d80cb..bf44ff1e 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.2
+Stable tag: 1.1.9.3
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.3 - 2019-11-27 =
+* Fixes - Measurement Unit translation.
+
= 1.1.9.2 - 2019-11-18 =
* Added - Fix API.
* Fixes - Search query.