From ae4264c59656ccca04d142ba3b09d8d45852b20e Mon Sep 17 00:00:00 2001 From: lainvineyard Date: Wed, 26 Oct 2022 16:51:20 -0700 Subject: [PATCH 1/4] remove ?disclaimers=true from the query used to retrieve listing information from the api when importing listings the idx-api.php client_properties() function adds ?disclaimers=true to all requests made through it, so including ?disclaimers=true in the initial request results in our API not including the disclaimer when it returns results --- add-ons/listings/includes/class-listing-import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/add-ons/listings/includes/class-listing-import.php b/add-ons/listings/includes/class-listing-import.php index a202fb39d..01ca4bc77 100755 --- a/add-ons/listings/includes/class-listing-import.php +++ b/add-ons/listings/includes/class-listing-import.php @@ -68,7 +68,7 @@ public static function wp_listings_idx_create_post( $listings ) { // Load IDX Broker API Class and retrieve featured properties. $_idx_api = new \IDX\Idx_Api(); - $properties = $_idx_api->client_properties( 'featured?disclaimers=true' ); + $properties = $_idx_api->client_properties( 'featured' ); // Load WP options. $wpl_import_options = get_option( 'wp_listings_idx_featured_listing_wp_options' ); @@ -179,7 +179,7 @@ public static function wp_listings_update_post() { // Load IDX Broker API Class and retrieve featured properties. $_idx_api = new \IDX\Idx_Api(); - $properties = $_idx_api->client_properties( 'featured?disclaimers=true' ); + $properties = $_idx_api->client_properties( 'featured' ); // Load WP options $idx_featured_listing_wp_options = get_option( 'wp_listings_idx_featured_listing_wp_options' ); From 6532a47b1326cb8129a1f51068f0972805d10319 Mon Sep 17 00:00:00 2001 From: lainvineyard Date: Wed, 26 Oct 2022 16:51:42 -0700 Subject: [PATCH 2/4] add comment explaining that client_properties() appends ?disclaimers=true --- idx/idx-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idx/idx-api.php b/idx/idx-api.php index 30210f936..fdd331f57 100755 --- a/idx/idx-api.php +++ b/idx/idx-api.php @@ -608,7 +608,7 @@ public function saved_link_properties_count( $saved_link_id ) { /** * Client_properties function. * Expected $type posibilities: featured, soldpending, supplemental. - * + * Note that ?disclaimers=true will be added to the end of the request, so there's no need to include it in $type * @access public * @param string $type * @return array From 103bb6ac4bc9fe8a43a920362f28889bcf32b49e Mon Sep 17 00:00:00 2001 From: lainvineyard Date: Wed, 26 Oct 2022 16:52:24 -0700 Subject: [PATCH 3/4] remove esc_html when displaying disclaimer since this data originates from our API and is never modified by the user, it should be fine to output it directly to the page --- add-ons/listings/includes/views/single-listing.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/add-ons/listings/includes/views/single-listing.php b/add-ons/listings/includes/views/single-listing.php index 6f542e88d..8d2b95122 100755 --- a/add-ons/listings/includes/views/single-listing.php +++ b/add-ons/listings/includes/views/single-listing.php @@ -123,9 +123,9 @@ function single_listing_post_content() { echo ( get_post_meta( $post->ID, '_listing_featured_on', true ) ) ? '' : ''; if ( get_post_meta( $post->ID, '_listing_disclaimer', true ) ) { - echo '

' . esc_html( get_post_meta( $post->ID, '_listing_disclaimer', true ) ) . '

'; + echo '

' . get_post_meta( $post->ID, '_listing_disclaimer', true ) . '

'; } elseif ( ! empty( $options['wp_listings_global_disclaimer'] ) ) { - echo '

' . esc_html( $options['wp_listings_global_disclaimer'] ) . '

'; + echo '

' . $options['wp_listings_global_disclaimer'] . '

'; } if ( class_exists( 'Idx_Broker_Plugin' ) && ! empty( $options['wp_listings_display_idx_link'] ) && get_post_meta( $post->ID, '_listing_details_url', true ) ) { From bc8993b216fc92beb3ded5ee76a680e5b510085c Mon Sep 17 00:00:00 2001 From: lainvineyard Date: Mon, 7 Nov 2022 15:51:18 -0800 Subject: [PATCH 4/4] add &disclaimers=true to subsequent queries through client_properties when there are more than 50 featured listings on an account the next value returned by the api does not include disclaimers=true even if it's included in the initial request, so it needs to be added back if a subsequent query needs to be made to fetch all the listings. --- idx/idx-api.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/idx/idx-api.php b/idx/idx-api.php index fdd331f57..836ced393 100755 --- a/idx/idx-api.php +++ b/idx/idx-api.php @@ -650,7 +650,8 @@ public function client_properties( $type ) { continue; } // Explode $listing_data['next'] on '/clients/', index 1 of the resulting array will have the fragment needed to make the next API request. - $listing_data = $this->idx_api( explode( '/clients/', $listing_data['next'] )[1], IDX_API_DEFAULT_VERSION, 'clients', array(), 7200, 'GET', true ); + // Also add &disclaimers=true to the end of the query as it's not included on the next or prev values + $listing_data = $this->idx_api( explode( '/clients/', $listing_data['next'] )[1] . '&disclaimers=true', IDX_API_DEFAULT_VERSION, 'clients', array(), 7200, 'GET', true ); // If $listing_data['data'] is an array, merge it with the existing listings/properties array. if ( ! is_wp_error( $listing_data ) && isset( $listing_data['data'] ) && is_array( $listing_data['data'] ) ) { $properties = array_merge( $properties, $listing_data['data'] );