PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 5.8.4
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v5.8.4
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 6.0.5 All 36 releases
mlsimport / enviroment / ResidenceClass.php

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

285 lines 8.4 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 mlsimportSaasSetExtraMeta( $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 if(isset($field_values) && is_array($field_values)){
133 foreach ( $field_values as $value ) {
134 if ( ! empty( $value ) ) {
135 $processed_field_values[] = $value;
136 }
137 }
138 }
139
140 // Bulk update terms if array is not empty
141 if ( ! empty( $processed_field_values ) ) {
142
143 }
144
145
146
147
148
149
150 $meta_value = null;
151
152 endforeach;
153
154 $answer['property_history'] = implode( '</br>', $property_history );
155 $answer['extra_meta_log'] = implode( PHP_EOL, $extra_meta_log );
156 }
157
158 $property_history = null;
159 $extra_meta_log = null;
160 $options = null;
161 $permited_meta = null;
162 return $answer;
163 }
164
165
166
167
168
169 /**
170 * set hardcode fields after updated
171 *
172 * @since 1.0.0
173 * @access protected
174 * @var string $plugin_name
175 */
176 public function correlationUpdateAfter( $is_insert, $property_id, $global_extra_fields, $new_agent ) {
177 if ( 'yes' === $is_insert ) {
178 update_post_meta( $property_id, 'prop_featured', 0 );
179 update_post_meta( $property_id, 'page_custom_zoom', 16 );
180 update_post_meta( $property_id, 'property_country', 'United States' );
181
182 update_post_meta( $property_id, 'property_agent', $new_agent );
183 update_post_meta( $property_id, 'property_page_desing_local', '' );
184 update_post_meta( $property_id, 'header_transparent', 'global' );
185 update_post_meta( $property_id, 'page_show_adv_search', 'global' );
186 update_post_meta( $property_id, 'page_show_adv_search', 'global' );
187 update_post_meta( $property_id, 'header_type', 0 );
188 update_post_meta( $property_id, 'sidebar_agent_option', 'global' );
189 update_post_meta( $property_id, 'local_pgpr_slider_type', 'global' );
190 update_post_meta( $property_id, 'local_pgpr_content_type', 'global' );
191 update_post_meta( $property_id, 'sidebar_select', 'global' );
192 update_post_meta( $property_id, 'sidebar_option', 'global' );
193
194 if ( function_exists( 'wpestate_update_hiddent_address_single' ) ) {
195 wpestate_update_hiddent_address_single( $property_id );
196 }
197 }
198 }
199
200
201
202
203 /**
204 * save custom fields per environment
205 *
206 * @since 1.0.0
207 * @access protected
208 * @var string $plugin_name
209 */
210 public function enviroment_custom_fields( $option_name ) {
211
212 $theme_options = get_option( 'wpresidence_admin' );
213 $custom_fields = '';
214 if ( isset( $theme_options['wpestate_custom_fields_list'] ) ) {
215 $custom_fields = $theme_options['wpestate_custom_fields_list'];
216 }
217
218 if ( ! is_array( $custom_fields ) ) {
219 $custom_fields = array();
220 }
221
222 $custom_field_no = 100;
223
224 $options = get_option( $option_name . '_admin_fields_select' );
225
226
227 $test = 0;
228 foreach ( $options['mls-fields'] as $key => $value ) {
229 ++$test;
230
231 if ( 1 === intval($value) && 0 === intval($options['mls-fields-admin'][ $key ]) ) {
232 if ( isset( $custom_fields['add_field_name'] ) && is_array( $custom_fields['add_field_name'] ) && ! in_array( $key, $custom_fields['add_field_name'] ) && '' !== $key ) {
233 ++$custom_field_no;
234 if ( ! is_array( $custom_fields['add_field_name'] ) ) {
235 $custom_fields['add_field_name'] = array();
236 $custom_fields['add_field_label'] = array();
237 $custom_fields['add_field_type'] = array();
238 $custom_fields['add_field_order'] = array();
239 $custom_fields['add_dropdown_order'] = array();
240 }
241
242 $custom_fields['add_field_name'][] = $key;
243 $custom_fields['add_field_label'][] = $options['mls-fields-label'][ $key ];
244 $custom_fields['add_field_type'][] = 'short text';
245 $custom_fields['add_field_order'][] = $custom_field_no;
246 $custom_fields['add_dropdown_order'][] = '';
247 } elseif ( isset( $custom_fields['add_field_name'] ) ) {
248 $to_replace_key = array_search( $key, $custom_fields['add_field_name'] );
249 $custom_fields['add_field_label'][ $to_replace_key ] = $options['mls-fields-label'][ $key ];
250 }
251 } else {
252 // remove item from custom fields
253 $key_remove = array_search( $key, $custom_fields['add_field_name'] );
254 if ( '' !== $key_remove && isset( $custom_fields['add_field_name'][ $key_remove ] ) ) {
255 unset( $custom_fields['add_field_name'][ $key_remove ] );
256 unset( $custom_fields['add_field_label'][ $key_remove ] );
257 unset( $custom_fields['add_field_type'][ $key_remove ] );
258 unset( $custom_fields['add_field_order'][ $key_remove ] );
259 unset( $custom_fields['add_dropdown_order'][ $key_remove ] );
260 }
261 }
262 }
263
264 $theme_options['wpestate_custom_fields_list'] = $custom_fields;
265 update_option( 'wpresidence_admin', $theme_options );
266
267 }
268
269
270
271
272
273
274 /**
275 * return theme schema
276 *
277 * @since 1.0.0
278 * @access protected
279 * @var string $plugin_name
280 */
281 public function return_theme_schema() {
282 return;
283 }
284 }
285