PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 6.3.8
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v6.3.8
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 / admin / partials / mlsimport-onboarding-steps / step-import-config.php

step-import-config.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 6.3.8, at admin/partials/mlsimport-onboarding-steps/step-import-config.php

371 lines 12.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template for the Import Configuration step of the MLSImport onboarding wizard
4 *
5 * @link https://mlsimport.com/
6 * @since 6.1.0
7 *
8 * @package Mlsimport
9 * @subpackage Mlsimport/admin/partials/mlsimport-onboarding-steps
10 */
11
12 // If this file is called directly, abort.
13 if (!defined('WPINC')) {
14 die;
15 }
16
17 // Get saved data
18 $import_data = mlsimport_get_onboarding_step_data('import-config');
19
20 // Set default values
21 $import_title = isset($import_data['import_title']) ? $import_data['import_title'] : __('Initial MLS Import', 'mlsimport');
22 $property_status = isset($import_data['property_status']) ? $import_data['property_status'] : 'publish';
23 $agent_id = isset($import_data['agent_id']) ? $import_data['agent_id'] : '';
24 $property_user = isset($import_data['property_user']) ? $import_data['property_user'] : get_current_user_id();
25 $min_price = isset($import_data['min_price']) && $import_data['min_price'] !== ''
26 ? $import_data['min_price']
27 : '0';
28 $max_price = isset($import_data['max_price']) && $import_data['max_price'] !== ''
29 ? $import_data['max_price']
30 : '10000000';
31 $property_cities = isset($import_data['property_cities']) ? $import_data['property_cities'] : array();
32 $property_types = isset($import_data['property_types']) ? $import_data['property_types'] : array();
33 $auto_update = isset($import_data['auto_update']) ? $import_data['auto_update'] : 1;
34
35 // Get MLS metadata
36 global $mlsimport;
37 $mls_metadata = get_option('mlsimport_mls_metadata_mls_enums', '');
38 $enums_data = json_decode($mls_metadata, true);
39
40 // Get property types
41 $property_type_options = array();
42 if (isset($enums_data['global_array']['PropertyEnums']['PropertyType'])) {
43 $property_type_options = $enums_data['global_array']['PropertyEnums']['PropertyType'];
44 } else {
45 // Default property types if metadata not available
46 $property_type_options = array(
47 'Residential' => 'Residential',
48 'Commercial' => 'Commercial',
49 'Land' => 'Land',
50 'MultiFamily' => 'Multi-Family',
51 'Condo/Townhome/Row Home/Co-Op' => 'Condo/Townhouse',
52 );
53 }
54
55 // Get cities
56 $city_options = array();
57 if (isset($enums_data['global_array']['PropertyEnums']['City'])) {
58 $city_options = $enums_data['global_array']['PropertyEnums']['City'];
59 }
60
61 // Get status options
62 $status_options = array(
63 'publish' => __('Published', 'mlsimport'),
64 'draft' => __('Draft', 'mlsimport'),
65 'pending' => __('Pending Review', 'mlsimport'),
66 );
67
68 // Get agents
69 $agents = array();
70 if (method_exists($mlsimport->admin->env_data, 'get_agent_post_type')) {
71 $agent_post_type = $mlsimport->admin->env_data->get_agent_post_type();
72
73 $args = array(
74 'post_type' => $agent_post_type,
75 'post_status' => 'publish',
76 'posts_per_page' => 100,
77 );
78
79 $agent_query = new WP_Query($args);
80
81 if ($agent_query->have_posts()) {
82 while ($agent_query->have_posts()) {
83 $agent_query->the_post();
84 $agents[get_the_ID()] = get_the_title();
85 }
86 wp_reset_postdata();
87 }
88 }
89
90 // Get users
91 $users = array();
92 $blogusers = get_users(array('role__in' => array('administrator', 'editor', 'author'), 'orderby' => 'display_name'));
93 foreach ($blogusers as $user) {
94 $users[$user->ID] = $user->display_name . ' (' . $user->user_login . ')';
95 }
96
97 // Get current theme
98 $current_theme = wp_get_theme();
99 $theme_name = $current_theme->get('Name');
100
101 // Detect supported theme
102 $supported_themes = array(
103 'WpResidence' => 'WP Residence',
104 'houzez' => 'Houzez',
105 'RealHomes' => 'Real Homes',
106 'Wpestate' => 'WP Estate',
107 );
108
109 $detected_theme = false;
110 foreach ($supported_themes as $theme_key => $theme_label) {
111 if (strtolower($theme_name) === strtolower($theme_key) || strpos(strtolower($theme_name), strtolower($theme_key)) !== false) {
112 $detected_theme = $theme_label;
113 break;
114 }
115 }
116 ?>
117
118 <div class="mlsimport-import-config-content">
119 <div class="mlsimport-section">
120 <p class="mlsimport-config-intro">
121 <?php _e('Configure your first property import settings. These settings will create an import job that you can run and modify later.', 'mlsimport'); ?>
122 </p>
123
124 <div class="mlsimport-section-inner">
125 <h3><?php _e('Basic Settings', 'mlsimport'); ?></h3>
126
127 <div class="mlsimport-wizard-field-group">
128 <label for="mlsimport_import_title" class="mlsimport-wizard-field-label">
129 <?php _e('Import Name', 'mlsimport'); ?>
130 </label>
131 <input type="text" id="mlsimport_import_title" name="mlsimport_import_title" value="<?php echo esc_attr($import_title); ?>">
132 <p class="mlsimport-wizard-field-help">
133 <?php _e('A descriptive name to identify this import configuration', 'mlsimport'); ?>
134 </p>
135 </div>
136
137
138
139
140
141 </div>
142
143 <div class="mlsimport-section-inner">
144 <h3><?php _e('Property Filters', 'mlsimport'); ?></h3>
145 <p><?php _e('Set criteria to determine which properties to import:', 'mlsimport'); ?></p>
146
147 <div class="mlsimport-filter-group">
148 <div class="mlsimport-wizard-field-group mlsimport-price-range">
149 <label class="mlsimport-wizard-field-label">
150 <?php _e('Price Range', 'mlsimport'); ?>
151 </label>
152 <div class="mlsimport-price-fields">
153 <div class="mlsimport-min-price">
154 <span class="mlsimport-price-label"><?php _e('Min', 'mlsimport'); ?>:</span>
155 <input type="text" id="mlsimport_min_price" name="mlsimport_min_price" value="<?php echo esc_attr($min_price); ?>" placeholder="0">
156 </div>
157 <div class="mlsimport-max-price">
158 <span class="mlsimport-price-label"><?php _e('Max', 'mlsimport'); ?>:</span>
159 <input type="text" id="mlsimport_max_price" name="mlsimport_max_price" value="<?php echo esc_attr($max_price); ?>" placeholder="10000000">
160 </div>
161 </div>
162 <p class="mlsimport-wizard-field-help">
163 <?php _e('Limit properties by price range (leave blank for no limit)', 'mlsimport'); ?>
164 </p>
165 </div>
166
167 <?php if (!empty($property_type_options)) : ?>
168 <div class="mlsimport-wizard-field-group">
169 <label for="mlsimport_property_types" class="mlsimport-wizard-field-label">
170 <?php _e('Property Types', 'mlsimport'); ?>
171 </label>
172
173 <select id="mlsimport_property_types" name="mlsimport_property_types[]" multiple="multiple" size="5">
174 <?php foreach ($property_type_options as $value => $label) : ?>
175 <option value="<?php echo esc_attr($value); ?>" <?php selected(in_array($value, $property_types), true); ?>>
176 <?php echo esc_html($value); ?>
177 </option>
178 <?php endforeach; ?>
179 </select>
180 <p class="mlsimport-wizard-field-help">
181 <?php _e('Select property types to import (hold Ctrl/Cmd for multiple selections, leave blank for all types)', 'mlsimport'); ?>
182 </p>
183 </div>
184 <?php endif; ?>
185
186 <?php if (!empty($city_options)) : ?>
187 <div class="mlsimport-wizard-field-group">
188 <label for="mlsimport_property_cities" class="mlsimport-wizard-field-label">
189 <?php _e('Cities', 'mlsimport'); ?>
190 </label>
191 <select id="mlsimport_property_cities" name="mlsimport_property_cities[]" multiple="multiple" size="5" class="mlsimport-city-select">
192 <?php foreach ($city_options as $value => $label) : ?>
193 <option value="<?php echo esc_attr($value); ?>" <?php selected(in_array($value, $property_cities), true); ?>>
194 <?php echo esc_html($value); ?>
195 </option>
196 <?php endforeach; ?>
197 </select>
198 <p class="mlsimport-wizard-field-help">
199 <?php _e('Select cities to import from (hold Ctrl/Cmd for multiple selections, leave blank for all cities)', 'mlsimport'); ?>
200 </p>
201 </div>
202 <?php endif; ?>
203 </div>
204 </div>
205
206 <div class="mlsimport-config-note">
207 <p>
208 <strong><?php _e('Note:', 'mlsimport'); ?></strong>
209 <?php echo sprintf(__('After initial setup, you can create additional import configurations with different filters to organize listings by city, price range, or property type. Each configuration creates a separate import job in %s.', 'mlsimport'), $detected_theme ? $detected_theme : 'your theme'); ?>
210 </p>
211 </div>
212 </div>
213 </div>
214
215 <script>
216 jQuery(document).ready(function($) {
217
218 // Ensure number fields only accept numbers
219 $('#mlsimport_min_price, #mlsimport_max_price').on('input', function() {
220 this.value = this.value.replace(/[^0-9]/g, '');
221 });
222 });
223 </script>
224
225 <style>
226
227 .mlsimport-config-intro {
228 font-size: 15px;
229 margin-bottom: 25px;
230 }
231
232 .mlsimport-section-inner {
233 margin-bottom: 40px;
234 }
235
236 .mlsimport-section-inner h3 {
237 margin-top: 0;
238 border-bottom: 1px solid #f0f0f0;
239 padding-bottom: 10px;
240 margin-bottom: 15px;
241 }
242
243 /* Price Range Field */
244 .mlsimport-price-fields {
245 display: flex;
246 gap: 20px;
247 }
248
249 .mlsimport-min-price,
250 .mlsimport-max-price {
251 flex: 1;
252 display: flex;
253 align-items: center;
254 }
255
256 .mlsimport-price-label {
257 margin-right: 8px;
258 font-weight: 500;
259 }
260
261 /* Auto Update Toggle Switch */
262 .mlsimport-auto-update-field {
263 display: flex;
264 align-items: center;
265 flex-wrap: wrap;
266 }
267
268 .mlsimport-auto-update-field .mlsimport-wizard-field-label {
269 margin-bottom: 10px;
270 width: 100%;
271 }
272
273 .mlsimport-auto-update-field .mlsimport-wizard-field-help {
274 flex: 0 0 100%;
275 margin-top: 5px;
276 }
277
278 .mlsimport-switch {
279 position: relative;
280 display: inline-block;
281 width: 50px;
282 height: 24px;
283 margin-right: 10px;
284 }
285
286 .mlsimport-switch input {
287 opacity: 0;
288 width: 0;
289 height: 0;
290 }
291
292 .mlsimport-slider {
293 position: absolute;
294 cursor: pointer;
295 top: 0;
296 left: 0;
297 right: 0;
298 bottom: 0;
299 background-color: #ccc;
300 transition: .4s;
301 }
302
303 .mlsimport-slider:before {
304 position: absolute;
305 content: "";
306 height: 16px;
307 width: 16px;
308 left: 4px;
309 bottom: 4px;
310 background-color: white;
311 transition: .4s;
312 }
313
314 input:checked + .mlsimport-slider {
315 background-color: #4f46e5;
316 }
317
318 input:focus + .mlsimport-slider {
319 box-shadow: 0 0 1px #4f46e5;
320 }
321
322 input:checked + .mlsimport-slider:before {
323 transform: translateX(26px);
324 }
325
326 .mlsimport-slider.round {
327 border-radius: 24px;
328 }
329
330 .mlsimport-slider.round:before {
331 border-radius: 50%;
332 }
333
334 /* Filter styling */
335 .mlsimport-filter-group {
336 padding: 15px;
337 background-color: #f9f9f9;
338 border-radius: 4px;
339 margin-bottom: 20px;
340 }
341
342 .mlsimport-filter-group .mlsimport-wizard-field-group:last-child {
343 margin-bottom: 0;
344 }
345
346 /* Note styling */
347 .mlsimport-config-note {
348 background-color: #f9f9f9;
349 border-left: 4px solid #00a0d2;
350 padding: 15px;
351 margin-top: 20px;
352 }
353
354 .mlsimport-config-note p {
355 margin: 0;
356 }
357
358 /* Fix for multiselect */
359 .mlsimport-city-select {
360 width: 100%;
361 }
362
363 /* Select2 customizations if used */
364 .select2-container--default .select2-selection--multiple {
365 border-color: #ddd;
366 }
367
368 .select2-container--default.select2-container--focus .select2-selection--multiple {
369 border-color: #4f46e5;
370 }
371 </style>