From 73fb75c3fdcce1971ca57ee73904e844a4f8f179 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Mon, 23 Mar 2020 11:13:53 +0700 Subject: [PATCH] Fix single agency properties --- assets/js/opalestate.js | 52 +++++++----- changelog.txt | 3 + inc/ajax-functions.php | 108 +++++++++++++++++-------- opal-estate-pro.php | 2 +- readme.txt | 5 +- templates/single-agency/properties.php | 30 +++---- templates/single-agent/properties.php | 2 +- 7 files changed, 132 insertions(+), 70 deletions(-) diff --git a/assets/js/opalestate.js b/assets/js/opalestate.js index d53447b3..a1366df1 100755 --- a/assets/js/opalestate.js +++ b/assets/js/opalestate.js @@ -195,7 +195,7 @@ jQuery( document ).ready( function ( $ ) { } ); $( 'body' ) - // Star ratings for comments + // Star ratings for comments .on( 'click', '.comment-form-rating p.opalestate-stars a', function () { var $star = $( this ), $rating = $( this ).closest( '.comment-form-rating' ).find( '.opalestate_rating' ), @@ -224,26 +224,26 @@ jQuery( document ).ready( function ( $ ) { var window_width = $( window ).width(); - if (window_width < 768) { - $(".opalestate-sticky-column").trigger("sticky_kit:detach"); + if ( window_width < 768 ) { + $( '.opalestate-sticky-column' ).trigger( 'sticky_kit:detach' ); } else { make_sticky(); } - $( window ).resize(function() { + $( window ).resize( function () { window_width = $( window ).width(); - if (window_width < 768) { - $(".opalestate-sticky-column").trigger("sticky_kit:detach"); + if ( window_width < 768 ) { + $( '.opalestate-sticky-column' ).trigger( 'sticky_kit:detach' ); } else { make_sticky(); } - }); + } ); function make_sticky() { - $(".opalestate-sticky-column").stick_in_parent(); + $( '.opalestate-sticky-column' ).stick_in_parent(); } //// @@ -577,17 +577,33 @@ jQuery( document ).ready( function ( $ ) { $( '.ajax-load-properties' ).delegate( '.pagination li', 'click', function () { var $content = $( this ).parents( '.ajax-load-properties' ); - $.ajax( { - type: 'POST', - url: opalesateJS.ajaxurl, - data: location.search.substr( 1 ) + '&action=get_agent_property&paged=' + $( this ).data( 'paged' ) + - '&id=' + $content.data( 'id' ), - success: function ( data ) { - if ( data ) { - $content.html( data ); + var type = $( this ).parents( '.ajax-load-properties' ).data( 'type' ); + if ( type === 'agent' ) { + $.ajax( { + type: 'POST', + url: opalesateJS.ajaxurl, + data: location.search.substr( 1 ) + '&action=get_agent_property&paged=' + $( this ).data( 'paged' ) + + '&id=' + $content.data( 'id' ), + success: function ( data ) { + if ( data ) { + $content.html( data ); + } } - } - } ); + } ); + } else if ( type === 'agency' ) { + $.ajax( { + type: 'POST', + url: opalesateJS.ajaxurl, + data: location.search.substr( 1 ) + '&action=get_agency_property&paged=' + $( this ).data( 'paged' ) + + '&id=' + $content.data( 'id' ), + success: function ( data ) { + if ( data ) { + $content.html( data ); + } + } + } ); + } + return false; } ); diff --git a/changelog.txt b/changelog.txt index fefbceb5..878f9e9e 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ += 1.3.9.1 - 2020-03-23 = +* Fixes - Single agency properties load more + = 1.3.9 - 2020-03-17 = * Fixes - Pending properties review * Fixes - Search form default value diff --git a/inc/ajax-functions.php b/inc/ajax-functions.php index 3892b379..2a7f0e1b 100755 --- a/inc/ajax-functions.php +++ b/inc/ajax-functions.php @@ -227,36 +227,36 @@ function opalestate_toggle_featured_property() { /** * load more properties by agency */ -add_action( 'wp_ajax_get_agency_property', 'opalestate_load_more_agency_property' ); -add_action( 'wp_ajax_nopriv_get_agency_property', 'opalestate_load_more_agency_property' ); - -function opalestate_load_more_agency_property() { - - - $post = [ - 'post_id' => 0, - 'paged' => 1, - 'user_id' => 13, - 'related' => '', - 'limit' => apply_filters( 'opalesate_agency_properties_limit', 5 ), - ]; - - $post = array_merge( $post, $_POST ); - extract( $post ); - - $user_id = get_post_meta( absint( $post_id ), OPALESTATE_AGENCY_PREFIX . 'user_id', true ); - $query = Opalestate_Query::get_agency_property( absint( $post_id ), absint( $user_id ), absint( $limit ), absint( $paged ) ); - - if ( $query->have_posts() ) : - while ( $query->have_posts() ) : $query->the_post(); ?> -
- -
- 0, +// 'paged' => 1, +// 'user_id' => 13, +// 'related' => '', +// 'limit' => apply_filters( 'opalesate_agency_properties_limit', 5 ), +// ]; +// +// $post = array_merge( $post, $_POST ); +// extract( $post ); +// +// $user_id = get_post_meta( absint( $post_id ), OPALESTATE_AGENCY_PREFIX . 'user_id', true ); +// $query = Opalestate_Query::get_agency_property( absint( $post_id ), absint( $user_id ), absint( $limit ), absint( $paged ) ); +// +// if ( $query->have_posts() ) : +// while ( $query->have_posts() ) : $query->the_post(); ?> + + + + 1, 'id' => 13, - 'limit' => apply_filters( 'opalesate_agent_properties_limit', 1 ), + 'limit' => apply_filters( 'opalesate_agent_properties_limit', 6 ), ]; $post = array_merge( $post, $_POST ); @@ -280,13 +280,57 @@ function opalestate_get_agent_property() { set_query_var( 'paged', $post['paged'] ); $query = Opalestate_Query::get_agent_property( null, absint( $post['id'] ), absint( $limit ) ); + $paged = absint( $post['paged'] ); + if ( $query->have_posts() ) : ?> +
+
+ have_posts() ) : $query->the_post(); ?> +
+ +
+ +
+
+ max_num_pages > 1 ): ?> +
max_num_pages ); ?>
+ + 0, + 'paged' => 1, + 'user_id' => 13, + 'related' => '', + 'limit' => apply_filters( 'opalesate_agency_properties_limit', 5 ), + ]; + + $post = array_merge( $post, $_POST ); + extract( $post ); + + $user_id = get_post_meta( absint( $id ), OPALESTATE_AGENCY_PREFIX . 'user_id', true ); + $user_id = $user_id ? $user_id : null; + $query = Opalestate_Query::get_agency_property( absint( $id ), absint( $user_id ), absint( $limit ), absint( $paged ) ); + $paged = absint( $post['paged'] ); if ( $query->have_posts() ) : ?>
have_posts() ) : $query->the_post(); ?>
- +
diff --git a/opal-estate-pro.php b/opal-estate-pro.php index 97a0d970..7c93c468 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.3.9 + * Version: 1.3.9.1 * Author: WPOPAL * Author URI: http://www.wpopal.com * Requires at least: 4.9 diff --git a/readme.txt b/readme.txt index 903d751a..3abf5093 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.9 Tested up to: 5.3.2 -Stable tag: 1.3.9 +Stable tag: 1.3.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.3.9.1 - 2020-03-23 = +* Fixes - Single agency properties load more + = 1.3.9 - 2020-03-17 = * Fixes - Pending properties review * Fixes - Search form default value diff --git a/templates/single-agency/properties.php b/templates/single-agency/properties.php index 6033f03f..c7aca2ba 100755 --- a/templates/single-agency/properties.php +++ b/templates/single-agency/properties.php @@ -13,28 +13,24 @@ if ( $query->have_posts() ) :

found_posts ); ?>

-
-
- have_posts() ) : $query->the_post(); ?> -
- -
- -
- max_num_pages > 1 ): ?> -
max_num_pages; // opalestate_pagination( $query->max_num_pages ); ?>
-
- +
+
+
+ have_posts() ) : $query->the_post(); ?> +
+ +
+
- - + max_num_pages > 1 ): ?> +
max_num_pages ); ?>
+ +
- +
diff --git a/templates/single-agent/properties.php b/templates/single-agent/properties.php index 3da1c2c2..19cdc986 100755 --- a/templates/single-agent/properties.php +++ b/templates/single-agent/properties.php @@ -1,7 +1,7 @@ have_posts() ) : ?>