PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 5.7.3
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v5.7.3
7.2.2 7.2.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 All 37 releases
mlsimport / enviroment / ResidenceClass.php

ResidenceClass.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 5.7.3, at enviroment/ResidenceClass.php

283 lines 8.3 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
7 /**
8 * Description of ResidenceClass
9 *
10 * @author mlsimport
11 */
12 class ResidenceClass {
13
14 public function __construct() {
15 }
16
17
18 /**
19 * return custom post field
20 *
21 * @since 1.0.0
22 * @access protected
23 * @var string $plugin_name
24 */
25 public function get_property_post_type() {
26 return 'estate_property';
27 }
28
29
30
31 /**
32 * return custom post field
33 *
34 * @since 1.0.0
35 * @access protected
36 * @var string $plugin_name
37 */
38 public function get_agent_post_type() {
39 return 'estate_agent';
40 }
41
42
43 /**
44 * image save
45 *
46 * @since 1.0.0
47 * @access protected
48 * @var string $plugin_name
49 */
50 public function enviroment_image_save( $property_id, $attach_id ) {
51 return;
52 }
53
54
55 /**
56 * Deal with extra meta
57 */
58 public function mlsimport_saas_set_extra_meta( $property_id, $property ) {
59 $property_history = array();
60 $extra_meta_log = array();
61 $answer = array();
62 $options = get_option( 'mlsimport_admin_fields_select' );
63 $permited_meta = $options['mls-fields'];
64
65 if ( isset( $property['extra_meta'] ) && is_array( $property['extra_meta'] ) ) {
66 $meta_properties = $property['extra_meta'];
67
68 foreach ( $meta_properties as $meta_name => $meta_value ) :
69 // check if extra meta is set to import
70 if ( ! isset( $permited_meta[ $meta_name ] ) ) {
71 // we do not have the extra meta
72 continue;
73 } elseif ( isset( $permited_meta[ $meta_name ] ) && intval( $permited_meta[ $meta_name ] ) === 0 ) {
74 // meta exists but is set to no
75 continue;
76 }
77 $orignal_meta_name = $meta_name;
78 $meta_name = strtolower( $meta_name );
79
80
81
82 if( isset( $options['mls-fields-map-postmeta'][ $orignal_meta_name ]) && $options['mls-fields-map-postmeta'][ $orignal_meta_name ]!=='' ){
83 $new_post_meta_key=$options['mls-fields-map-postmeta'][ $meta_name ];
84
85 if ( is_array( $meta_value ) ) {
86 $meta_value = implode( ',', $meta_value );
87 }
88
89 update_post_meta( $property_id, $new_post_meta_key, $meta_value );
90 $property_history[] = 'Updated CUSTOM post meta ' . $new_post_meta_key . ' original ' . $meta_name . ' and value ' . $meta_value;
91 }
92 else if( isset( $options['mls-fields-map-taxonomy'][ $orignal_meta_name ]) && $options['mls-fields-map-taxonomy'][ $orignal_meta_name ]!=='' ){
93 $new_taxonomy=$options['mls-fields-map-taxonomy'][ $orignal_meta_name ];
94
95 $custom_label=$options['mls-fields-label'][ $orignal_meta_name ];
96 if ($custom_label=='none'){
97 $custom_label='';
98 }
99
100
101 if(!is_array($meta_value)){
102 $meta_value_with_label = array( trim($custom_label.' '.$meta_value) );
103 }else{
104 $meta_value_with_label=array( trim( $custom_label.' '.implode(', ',$meta_value)) );
105 }
106
107 wp_set_object_terms( $property_id, $meta_value_with_label, $new_taxonomy, true );
108 clean_term_cache( $property_id, $new_taxonomy );
109
110
111 $property_history[] = 'Updated CUSTOM TAX: ' . $new_taxonomy . '<-- original '.$orignal_meta_name.'/' . $meta_name .'/'.$custom_label. ' and value ' . json_encode($meta_value_with_label);
112 }else{
113
114 if ( is_array( $meta_value ) ) {
115 $meta_value = implode( ',', $meta_value );
116 }
117
118 update_post_meta( $property_id, $meta_name, $meta_value );
119 $property_history[] = 'Updated EXTRA Meta ' . $meta_name . ' with meta_value ' . $meta_value;
120 $mem_usage = memory_get_usage( true );
121 $mem_usage_show = round( $mem_usage / 1048576, 2 );
122 $extra_meta_log[] = 'Memory:' . $mem_usage_show . ' Property with ID ' . $property_id . ' Updated EXTRA Meta ' . $meta_name . ' with value ' . $meta_value;
123
124
125 }
126
127
128
129
130 // Remove empty values and decode values in one pass
131 $processed_field_values = array();
132 foreach ( $field_values as $value ) {
133 if ( ! empty( $value ) ) {
134 $processed_field_values[] = $value;
135 }
136 }
137
138 // Bulk update terms if array is not empty
139 if ( ! empty( $processed_field_values ) ) {
140
141 }
142
143
144
145
146
147
148 $meta_value = null;
149
150 endforeach;
151
152 $answer['property_history'] = implode( '</br>', $property_history );
153 $answer['extra_meta_log'] = implode( PHP_EOL, $extra_meta_log );
154 }
155
156 $property_history = null;
157 $extra_meta_log = null;
158 $options = null;
159 $permited_meta = null;
160 return $answer;
161 }
162
163
164
165
166
167 /**
168 * set hardcode fields after updated
169 *
170 * @since 1.0.0
171 * @access protected
172 * @var string $plugin_name
173 */
174 public function correlation_update_after( $is_insert, $property_id, $global_extra_fields, $new_agent ) {
175 if ( 'yes' === $is_insert ) {
176 update_post_meta( $property_id, 'prop_featured', 0 );
177 update_post_meta( $property_id, 'page_custom_zoom', 16 );
178 update_post_meta( $property_id, 'property_country', 'United States' );
179
180 update_post_meta( $property_id, 'property_agent', $new_agent );
181 update_post_meta( $property_id, 'property_page_desing_local', '' );
182 update_post_meta( $property_id, 'header_transparent', 'global' );
183 update_post_meta( $property_id, 'page_show_adv_search', 'global' );
184 update_post_meta( $property_id, 'page_show_adv_search', 'global' );
185 update_post_meta( $property_id, 'header_type', 0 );
186 update_post_meta( $property_id, 'sidebar_agent_option', 'global' );
187 update_post_meta( $property_id, 'local_pgpr_slider_type', 'global' );
188 update_post_meta( $property_id, 'local_pgpr_content_type', 'global' );
189 update_post_meta( $property_id, 'sidebar_select', 'global' );
190 update_post_meta( $property_id, 'sidebar_option', 'global' );
191
192 if ( function_exists( 'wpestate_update_hiddent_address_single' ) ) {
193 wpestate_update_hiddent_address_single( $property_id );
194 }
195 }
196 }
197
198
199
200
201 /**
202 * save custom fields per environment
203 *
204 * @since 1.0.0
205 * @access protected
206 * @var string $plugin_name
207 */
208 public function enviroment_custom_fields( $option_name ) {
209
210 $theme_options = get_option( 'wpresidence_admin' );
211 $custom_fields = '';
212 if ( isset( $theme_options['wpestate_custom_fields_list'] ) ) {
213 $custom_fields = $theme_options['wpestate_custom_fields_list'];
214 }
215
216 if ( ! is_array( $custom_fields ) ) {
217 $custom_fields = array();
218 }
219
220 $custom_field_no = 100;
221
222 $options = get_option( $option_name . '_admin_fields_select' );
223
224
225 $test = 0;
226 foreach ( $options['mls-fields'] as $key => $value ) {
227 ++$test;
228
229 if ( 1 === intval($value) && 0 === intval($options['mls-fields-admin'][ $key ]) ) {
230 if ( isset( $custom_fields['add_field_name'] ) && is_array( $custom_fields['add_field_name'] ) && ! in_array( $key, $custom_fields['add_field_name'] ) && '' !== $key ) {
231 ++$custom_field_no;
232 if ( ! is_array( $custom_fields['add_field_name'] ) ) {
233 $custom_fields['add_field_name'] = array();
234 $custom_fields['add_field_label'] = array();
235 $custom_fields['add_field_type'] = array();
236 $custom_fields['add_field_order'] = array();
237 $custom_fields['add_dropdown_order'] = array();
238 }
239
240 $custom_fields['add_field_name'][] = $key;
241 $custom_fields['add_field_label'][] = $options['mls-fields-label'][ $key ];
242 $custom_fields['add_field_type'][] = 'short text';
243 $custom_fields['add_field_order'][] = $custom_field_no;
244 $custom_fields['add_dropdown_order'][] = '';
245 } elseif ( isset( $custom_fields['add_field_name'] ) ) {
246 $to_replace_key = array_search( $key, $custom_fields['add_field_name'] );
247 $custom_fields['add_field_label'][ $to_replace_key ] = $options['mls-fields-label'][ $key ];
248 }
249 } else {
250 // remove item from custom fields
251 $key_remove = array_search( $key, $custom_fields['add_field_name'] );
252 if ( '' !== $key_remove && isset( $custom_fields['add_field_name'][ $key_remove ] ) ) {
253 unset( $custom_fields['add_field_name'][ $key_remove ] );
254 unset( $custom_fields['add_field_label'][ $key_remove ] );
255 unset( $custom_fields['add_field_type'][ $key_remove ] );
256 unset( $custom_fields['add_field_order'][ $key_remove ] );
257 unset( $custom_fields['add_dropdown_order'][ $key_remove ] );
258 }
259 }
260 }
261
262 $theme_options['wpestate_custom_fields_list'] = $custom_fields;
263 update_option( 'wpresidence_admin', $theme_options );
264
265 }
266
267
268
269
270
271
272 /**
273 * return theme schema
274 *
275 * @since 1.0.0
276 * @access protected
277 * @var string $plugin_name
278 */
279 public function return_theme_schema() {
280 return;
281 }
282 }
283