PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 5.8.1
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v5.8.1
7.2 7.1.2 7.1.1 7.1 7.0.4 7.0.6 7.0.7 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 6.3.1 trunk 5.7.3 5.7.5 5.8.1 5.8.2 5.8.3 5.8.4 5.8.6 6.0.4 6.0.5 6.0.7 All 35 releases
mlsimport / includes / help_functions.php

help_functions.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 5.8.1, at includes/help_functions.php

355 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 function mlsimport_get_custom_post_type_taxonomies($post_type) {
7 // Get the taxonomies associated with the custom post type
8 $taxonomies = get_object_taxonomies($post_type , 'objects');
9
10 // Initialize an array to hold the slug => label pairs
11 $taxonomy_array = array();
12
13 // Loop through the taxonomies and fill the array
14 foreach ($taxonomies as $taxonomy_slug => $taxonomy) {
15 $taxonomy_array[$taxonomy_slug] = $taxonomy->label;
16 }
17
18 return $taxonomy_array;
19 }
20
21
22 /*
23 *
24 * Request list of ready to go MLS
25 *
26 *
27 */
28
29 function mlsimport_allowed_html_tags_content() {
30 // Define the allowable HTML tags and their attributes
31 $allowed_tags = array(
32 'a' => array(
33 'href' => array(),
34 'title' => array(),
35 'rel' => array(),
36 'target' => array(),
37 ),
38 'b' => array(),
39 'i' => array(),
40 'p' => array(),
41 'br' => array(),
42 'ul' => array(),
43 'ol' => array(),
44 'li' => array(),
45 'strong' => array(),
46 'em' => array(),
47 'blockquote' => array(),
48 'code' => array(),
49 'pre' => array(),
50 'select' => array( // Allow <select> and its attributes
51 'name' => array(),
52 'id' => array(),
53 'class' => array(),
54 'multiple' => array(),
55 'required' => array(),
56 ),
57 'option' => array( // Allow <option> and its attributes
58 'value' => array(),
59 'selected' => array(),
60 ),
61 'div' => array( // Allow <div> and its attributes
62 'id' => array(),
63 'class' => array(),
64 'style' => array(), // Use with caution, considering inline CSS security implications
65 ),
66 'h4' => array(
67 'id' => array(),
68 'class' => array(),
69
70 ),
71 'label' => array(
72 'id' => array(),
73 'class' => array(),
74
75 ),
76 'fieldset' => array(
77 'id' => array(),
78 'class' => array(),
79
80 ),
81 'input' => array(
82 'id' => array(),
83 'class' => array(),
84 'type' => array(),
85 'name' => array(),
86 'value' => array(),
87 'checked'=>array()
88
89
90 ),
91 );
92
93
94 return $allowed_tags;
95 }
96
97
98 /*
99 *
100 * Request list of ready to go MLS
101 *
102 *
103 */
104 function mlsimport_saas_request_list() {
105
106 $mls_data = get_transient( 'mlsimport_ready_to_go_mlsimport_data' );
107
108 if ( false === $mls_data ) {
109 $theme_Start = new ThemeImport();
110 $values = array();
111
112 $answer = $theme_Start::globalApiRequestSaas( 'mls', $values, 'GET' );
113
114 if ( isset( $answer['succes'] ) && true === $answer['succes'] ) {
115 $mls_data = $answer['mls_list'];
116 $mls_data['0'] = esc_html__( 'My MLS is not on this list', 'mlsimport' );
117
118 $autofill_array = array();
119 foreach ( $mls_data as $key => $value ) {
120 $temp_array = array(
121 'label' => $value,
122 'value' => $key,
123 );
124 $autofill_array[] = $temp_array;
125 }
126
127 $mls_data = wp_json_encode( $autofill_array );
128
129 set_transient( 'mlsimport_ready_to_go_mlsimport_data', $mls_data, 60 * 60 * 24 );
130 } else {
131 $mls_data = array();
132 $mls_data['0'] = esc_html__( 'We could not connect to MLSimport Api', 'mlsimport' );
133 }
134 }
135
136 return $mls_data;
137 }
138
139
140 /*
141 * sanitize multidimensional array
142 *
143 *
144 * */
145 function mlsimport_sanitize_multi_dimensional_array($data){
146 if ( is_array( $data ) ) {
147 foreach ( $data as $key => $value ) {
148 if ( is_array( $value ) ) {
149 $data[ $key ] = mlsimport_sanitize_multi_dimensional_array( $value );
150 } else {
151
152 $data[ $key ] = sanitize_text_field( wp_unslash( $value ));
153 }
154 }
155 } else {
156 $data = sanitize_text_field( wp_unslash( $data) );
157 }
158
159 return $data;
160 }
161
162
163 /*
164 * Lopp troght the listings and get Listing key
165 *
166 *
167 *
168 *
169 *
170 * */
171
172 function mlsimport_saas_reconciliation_event_function() {
173
174 global $mlsimport;
175 $token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient();
176 $options = get_option( 'mlsimport_admin_options' );
177
178 if ( isset( $options['mlsimport_mls_name'] ) && '' !== $options['mlsimport_mls_name'] ) {
179 $mlsimport->admin->mlsimport_saas_start_doing_reconciliation();
180 }
181 }
182
183 /*
184 * Admin extra columns for MlsImport Items
185 *
186 *
187 *
188 *
189 *
190 * */
191
192 add_filter( 'manage_edit-mlsimport_item_columns', 'mlsimport_items_columns_admin' );
193
194 if ( ! function_exists( 'mlsimport_items_columns_admin' ) ) :
195
196 function mlsimport_items_columns_admin( $columns ) {
197 $slice = array_slice( $columns, 2, 2 );
198 unset( $columns['comments'] );
199 unset( $slice['comments'] );
200 $splice = array_splice( $columns, 2 );
201
202 $columns['mlsimport_items_params'] = esc_html__( 'Import Parameters', 'mlsimport' );
203 $columns['mlsimport_last_action'] = esc_html__( 'Last action', 'mlsimport' );
204 $columns['mlsimport_autoupdates'] = esc_html__( 'Auto Update Enabled', 'mlsimport' );
205
206 return array_merge( $columns, array_reverse( $slice ) );
207 }
208
209 endif; // end wpestate_my_columns
210
211
212
213
214 /*
215 * Admin extra columns for MlsImport Items - Populate with data display value
216 *
217 *
218 *
219 *
220 *
221 * */
222 function mlsimport_populate_columns_params_display_value( $value ) {
223 $display_value = '';
224 if ( is_array( $value ) ) {
225 foreach ( $value as $key_item => $item_name ) :
226 $display_value .= $item_name . ',';
227 endforeach;
228 $display_value = rtrim( $display_value, ',' );
229 } else {
230 $display_value = $value;
231 }
232
233 return $display_value;
234 }
235 /*
236 * Admin extra columns for MlsImport Items - Populate with data
237 *
238 *
239 *
240 *
241 *
242 * */
243
244 function mlsimport_populate_columns_params_display( $postID ) {
245 global $mlsimport;
246 $field_import = $mlsimport->admin->mlsimport_saas_return_mls_fields();
247
248 $select_all_none = array(
249 'InternetAddressDisplayYN',
250 'InternetEntireListingDisplayYN',
251 'PostalCode',
252 'ListAgentKey',
253 'ListAgentMlsId',
254 'ListOfficeKey',
255 'ListOfficeMlsId',
256 'ListingID',
257 'StandardStatus',
258 'extraCity',
259 'extraCounty',
260 'Exclude_ListOfficeKey',
261 'Exclude_ListOfficeMlsId',
262 'Exclude_ListAgentKey',
263 'Exclude_ListAgentMlsId',
264
265 );
266 foreach ( $field_import as $key => $field ) :
267 $display_value = '';
268 $name_check = strtolower( 'mlsimport_item_' . $key . '_check' );
269 $name = strtolower( 'mlsimport_item_' . $key );
270
271 $value = get_post_meta( $postID, $name, true );
272 $value_check = get_post_meta( $postID, $name_check, true );
273
274 $is_checkbox_admin = 0;
275 if ( 1 === intval($value_check) ) {
276 $is_checkbox_admin = 1;
277 }
278
279 if ( ! in_array( $key, $select_all_none ) ) {
280 if ( 1 === intval($is_checkbox_admin) ) {
281 $display_value = esc_html__( 'ALL', 'mlsimport' );
282 } else {
283 $display_value = mlsimport_populate_columns_params_display_value( $value );
284 }
285 } else {
286 $display_value = mlsimport_populate_columns_params_display_value( $value );
287 }
288
289 if ( '' !== $display_value ) { ?>
290 <strong>
291 <?php
292 print esc_html( ucfirst( str_replace( 'Select ', '', $field['label'] ) ) );
293 ?>
294 :</strong>
295 <?php
296 print esc_html($display_value).'</br>';
297
298 }
299 endforeach;
300 }
301
302
303
304 add_action( 'manage_posts_custom_column', 'mlsimport_populate_columns' );
305 if ( ! function_exists( 'mlsimport_populate_columns' ) ) :
306
307 function mlsimport_populate_columns( $column ) {
308
309 global $post;
310
311 if ( 'mlsimport_items_params' === $column ) {
312 $mlsimport_item_min_price = floatval( get_post_meta( $post->ID, 'mlsimport_item_min_price', true ) );
313 $mlsimport_item_max_price = floatval( get_post_meta( $post->ID, 'mlsimport_item_max_price', true ) );
314 ?>
315
316
317 <!-- Strong tag for emphasizing the label -->
318 <strong>
319 <?php esc_html_e('Minimum price:', 'mlsimport'); ?>
320 </strong>
321
322 <?php echo esc_html($mlsimport_item_min_price); ?><br>
323
324 <strong>
325 <?php esc_html_e('Maximum price:', 'mlsimport'); ?>
326 </strong>
327
328 <?php echo esc_html($mlsimport_item_max_price); ?><br>
329 <?php
330
331 mlsimport_populate_columns_params_display( $post->ID );
332 } elseif ( 'mlsimport_last_action' === $column ) {
333 $last_date = get_post_meta( $post->ID, 'mlsimport_last_date', true );
334 if ( '' !== $last_date ) {
335 print esc_html($last_date) . ' </br>';
336 esc_html_e( 'On this date we found new or edited listings.', 'mlsimport' );
337 } else {
338 esc_html_e( 'Not available - sync option may be off.', 'mlsimport' );
339 }
340 } elseif ( 'mlsimport_autoupdates' === $column ) {
341 $mlsimport_item_stat_cron = esc_html( get_post_meta( $post->ID, 'mlsimport_item_stat_cron', true ) );
342
343 if ( intval( $mlsimport_item_stat_cron ) > 0 ) {
344 ?>
345 yes
346 <?php
347 } else {
348 ?>
349 no
350 <?php
351 }
352 }
353 }
354 endif;
355