Merge pull request #18 from wpopal/develop

Develop
This commit is contained in:
wpopal 2019-11-27 10:29:39 +07:00 committed by GitHub
commit 5c8025aff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 152 additions and 11 deletions

View File

@ -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;
}
}

View File

@ -246,6 +246,12 @@ 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' );
@ -253,6 +259,9 @@ class Opalestate_Agent_Api extends Opalestate_Base_API {
$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;
}
}

View File

@ -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,

View File

@ -1062,7 +1062,13 @@ function opalestate_price( $price, $args = [] ) {
*/
function opalestate_areasize_unit_format( $value = '' ) {
return $value . ' ' . '<span>' . opalestate_options( 'measurement_unit', 'sq ft' ) . '</span>';
$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 <span>%2$s</span>', 'areasize info','opalestate-pro' ), $value, $unit );
}
add_filter( 'opalestate_areasize_unit_format', 'opalestate_areasize_unit_format' );

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.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&#8217; huh?', 'opalestate-pro' ), '1.1.9.2' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; 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

View File

@ -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.