PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 7.1.2
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v7.1.2
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-admin-options.php

mlsimport-admin-options.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 7.1.2, at admin/partials/mlsimport-admin-options.php

355 lines 13.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin partial: MLS/RESO API options (credentials form).
4 *
5 * The main connection screen. Renders the MLSImport account + MLS provider
6 * credential fields (username/password, MLS selector, and the various
7 * provider-specific tokens/IDs — Trestle, ConnectMLS, Rapattoni, Paragon,
8 * Realtor.ca, BrightMLS), plus a theme selector. Above the form it tests and
9 * reports both the MLSImport (SaaS) and MLS connection status. Fields are driven
10 * by the $settings_list config array.
11 *
12 * @package mlsimport
13 * @subpackage mlsimport/admin/partials
14 */
15
16 // Block direct access outside of WordPress.
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit; // Exit if accessed directly
19 }
20 ?>
21 <form method="post" name="cleanup_options" action="options.php">
22 <?php
23 // Register the settings-API fields/sections and load the saved credentials.
24 settings_fields( $this->plugin_name . '_admin_options' );
25 do_settings_sections( $this->plugin_name . '_admin_options' );
26 $options = get_option( $this->plugin_name . '_admin_options' );
27
28 global $mlsimport;
29
30
31
32
33
34
35 // Field catalog for the credentials form: each key is the option name, mapping to
36 // a display label ('name'), help text ('details'), and optional 'type' (e.g. select).
37 $settings_list = array(
38
39 'mlsimport_username' => array(
40 'name' => esc_html__( 'MLSImport.com Username (not your email)', 'mlsimport' ),
41 'details' => 'to be added',
42 ),
43 'mlsimport_password' => array(
44 'name' => esc_html__( 'MLSImport.com Password', 'mlsimport'),
45 'details' => 'to be added',
46 ),
47
48
49 'mlsimport_mls_name' => array(
50 'type' => 'select',
51 'name' => esc_html__( 'Your MLS', 'mlsimport'),
52 'details' => 'to be added',
53 ),
54
55 'mlsimport_mls_token' => array(
56 'name' => esc_html__( 'Your API Server token - provided by your MLS','mlsimport'),
57 'details' => 'to be added',
58 ),
59 'mlsimport_tresle_client_id' => array(
60 'name' => esc_html__( 'Your Trestle Client ID - provided by your MLS', 'mlsimport'),
61 'details' => 'to be added',
62 ),
63
64 'mlsimport_tresle_client_secret' => array(
65 'name' => esc_html__( 'Your Trestle Client Secret - provided by your MLS', 'mlsimport' ),
66 'details' => 'to be added',
67 ),
68
69 'mlsimport_connectmls_username' => array(
70 'name' => esc_html__( 'Your ConnectMLS Username - provided by your MLS', 'mlsimport' ),
71 'details' => 'to be added',
72 ),
73
74 'mlsimport_connectmls_password' => array(
75 'name' => esc_html__( 'Your ConnectMLS Password - provided by your MLS', 'mlsimport' ),
76 'details' => 'to be added',
77 ),
78
79 'mlsimport_rapattoni_client_id' => array(
80 'name' => esc_html__( 'MLSImport Rapattoni Client id', 'mlsimport' ),
81 'details' => 'to be added',
82 ),
83
84 'mlsimport_rapattoni_client_secret' => array(
85 'name' => esc_html__( 'MLSImport Rapattoni Client Secret', 'mlsimport' ),
86 'details' => 'to be added',
87 ),
88
89 'mlsimport_rapattoni_username' => array(
90 'name' => esc_html__( 'MLSImport Rapattoni Username', 'mlsimport' ),
91 'details' => 'to be added',
92 ),
93
94 'mlsimport_rapattoni_password' => array(
95 'name' => esc_html__( 'MLSImport Rapattoni Client Password','mlsimport' ),
96 'details' => 'to be added',
97 ),
98
99
100 'mlsimport_paragon_client_id' => array(
101 'name' => esc_html__( 'MLSImport Paragon Client id', 'mlsimport' ),
102 'details' => 'to be added',
103 ),
104
105 'mlsimport_paragon_client_secret' => array(
106 'name' => esc_html__( 'MLSImport Paragon Client Secret', 'mlsimport' ),
107 'details' => 'to be added',
108 ),
109
110 'mlsimport_realtorca_client_id' => array(
111 'name' => esc_html__( 'MLSImport Realtor.ca Client id', 'mlsimport' ),
112 'details' => 'to be added',
113 ),
114
115 'mlsimport_realtorca_client_secret' => array(
116 'name' => esc_html__( 'MLSImport Realtor.ca Client Secret', 'mlsimport' ),
117 'details' => 'to be added',
118 ),
119
120 'mlsimport_brightmls_client_id' => array(
121 'name' => esc_html__( 'Your BrightMLS Client ID - provided by your MLS', 'mlsimport' ),
122 'details' => 'to be added',
123 ),
124
125 'mlsimport_brightmls_client_secret' => array(
126 'name' => esc_html__( 'Your BrightMLS Client Secret - provided by your MLS', 'mlsimport' ),
127 'details' => 'to be added',
128 ),
129
130 'mlsimport_theme_used' => array(
131 'type' => 'select',
132 'name' => esc_html__( 'Your Wordpress Theme', 'mlsimport'),
133 'details' => 'to be added',
134 ),
135
136 );
137
138
139
140 ?>
141
142
143
144
145
146 <?php
147 // Cached SaaS API token (empty = not connected to the MlsImport account).
148 $token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient();
149
150 // Last known MLS connection result, then (re)initialise SaaS state.
151 $is_mls_connected = get_option( 'mlsimport_connection_test', '' );
152 $mlsimport->admin->mlsimport_saas_setting_up();
153
154
155
156 // Not yet confirmed connected — re-test the MLS connection and re-read the flag.
157 if ( 'yes' !== $is_mls_connected ) {
158 $mlsimport->admin->mlsimport_saas_check_mls_connection();
159 $is_mls_connected = get_option( 'mlsimport_connection_test', '' );
160 }
161
162
163
164
165
166
167 // No SaaS token — show the signup prompt and a "not connected" warning.
168 if ( trim( $token ) === '' ) {
169 mlsimport_show_signup();
170 ?>
171 <div class="mlsimport_warning">
172 <?php esc_html_e( 'You are not connected to MlsImport - Please check your Username and Password.', 'mlsimport' );?>
173 </div>
174 <?php
175 } else { ?>
176 <div class="mlsimport_warning mlsimport_validated">
177 <?php esc_html_e( 'You are connected to your MlsImport account!', 'mlsimport' );?>
178 </div>
179 <?php
180 }
181
182 // Separately report the MLS-side connection status.
183 if ( 'yes' === $is_mls_connected ) { ?>
184 <div class="mlsimport_warning mlsimport_validated">
185 <?php esc_html_e( 'You are connected to your MLS.', 'mlsimport' );?>
186 </div>
187 <?php
188 } else { ?>
189 <div class="mlsimport_warning">
190 <?php esc_html_e( 'The connection to your MLS was NOT succesful. Please check the authentication token is correct and check your MLS Data Access Application is approved. ', 'mlsimport' );?>
191 </div>
192 <?php
193 }
194
195 // Both connections confirmed and metadata never gathered: fire the Field
196 // Options metadata gather (mlsimport_saas_get_metadata AJAX) in the background
197 // now, so the import-field configuration is already saved before the user
198 // opens the Field Options tab. Emits nothing once metadata is populated;
199 // saving credentials/MLS clears that flag and re-arms the trigger.
200 echo mlsimport_metadata_autotrigger_markup(
201 $token,
202 $is_mls_connected,
203 get_option( 'mlsimport_mls_metadata_populated', '' ),
204 esc_attr( wp_create_nonce( 'mlsimport_saas_get_metadata' ) )
205 );
206
207
208 // Add before username fieldset
209 /*
210 global $mlsimport;
211 $current_token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient();
212 $token_expiry = get_option('mlsimport_token_expiry', 0);
213
214
215 $expiry_date = date('Y-m-d H:i:s', $token_expiry);
216 $is_expired = time() >= $token_expiry;
217 $status_color = $is_expired ? '#dc3545' : '#28a745';
218 $status_text = $is_expired ? 'EXPIRED' : 'VALID';
219
220 echo '<div style="background: #f9f9f9; padding: 15px; margin-bottom: 20px; border-radius: 5px;">';
221 echo '<h4>Current Token Status</h4>';
222 echo '<p><strong>Token:</strong> ' . esc_html(substr($current_token, 0, 20)) . '...</p>';
223 echo '<p><strong>Status:</strong> <span style="color: ' . $status_color . '; font-weight: bold;">' . $status_text . '</span></p>';
224 echo '<p><strong>Expires:</strong> ' . esc_html($expiry_date) . '</p>';
225 echo '</div>';
226 */
227
228
229 // Server-side provider visibility. Resolve the currently selected MLS to its
230 // provider family ONCE, before rendering, so every provider credential fieldset
231 // that does not belong to the selected family is emitted already hidden
232 // (inline display:none). Previously all fieldsets rendered visible and only the
233 // footer JavaScript hid the wrong ones at DOM-ready — on a slow load (or any JS
234 // error) the user saw Bridge, Trestle, Rapattoni, Paragon etc. inputs all at
235 // once. mlsimport_token_on_load() in mlsimport-admin.js applies the exact same
236 // rule when the user changes MLS without a page reload.
237 $selected_mls_id = ( is_array( $options ) && ! empty( $options['mlsimport_mls_name'] ) ) ? (string) $options['mlsimport_mls_name'] : '';
238 $provider_visibility = Mlsimport_Provider_Family::browser_config_for_ids(
239 '' !== $selected_mls_id ? array( $selected_mls_id ) : array(),
240 Mlsimport_Provider_Family::saved_type( $selected_mls_id ),
241 $selected_mls_id
242 );
243 // Full catalog of provider credential option keys (marks which fieldsets toggle).
244 $all_credential_fields = $provider_visibility['all_credential_fields'];
245 // Credential keys of the selected MLS's family; empty when no MLS is selected.
246 $active_credential_fields = isset( $provider_visibility['by_mls_id'][ $selected_mls_id ]['credential_fields'] )
247 ? $provider_visibility['by_mls_id'][ $selected_mls_id ]['credential_fields']
248 : array();
249
250 // Render one fieldset per credential field defined in $settings_list.
251 foreach ( $settings_list as $key => $setting ) {
252 // Current saved value for this field (escaped), or empty string if unset.
253 $value = ( isset( $options[ $key ] ) && ! empty( $options[ $key ] ) ) ? esc_attr( $options[ $key ] ) : '';
254 // A provider credential fieldset renders hidden unless it belongs to the
255 // selected MLS's provider family (shared fields always render visible).
256 $is_hidden_credential = in_array( $key, $all_credential_fields, true ) && ! in_array( $key, $active_credential_fields, true );
257 ?>
258 <fieldset class="mlsimport-fieldset <?php echo 'fieldset_' . esc_attr( $key ); ?>"<?php echo $is_hidden_credential ? ' style="display:none"' : ''; ?>>
259 <label class="mlsimport-label" for="<?php echo esc_attr($this->plugin_name ). '_admin_options'; ?>-<?php echo esc_attr($key); ?>" >
260 <?php echo esc_html( $setting['name'] ); ?>
261 </label>
262
263
264 <?php
265 // MLS selector: a searchable text box (front label) plus a hidden field for the
266 // resolved MLS id; the list of available MLSes is fetched from the SaaS.
267 if ( 'mlsimport_mls_name' === $key && isset( $setting['type'] ) and 'select' === $setting['type'] ) {
268 $mls_import_list = mlsimport_saas_request_list();
269
270 ?>
271
272 <div class="mls_explanations">
273 If your MLS is not on the list yet, requires manual activation, or if your credentials are not connecting, please <a href="https://mlsimport.com/contact-us/" target="_blank">contact us</a> for support.
274 </div>
275
276 <input type="text" class="mlsimport-input mlsimport-2025-input" id="mlsimport_mls_name_front" name="mlsimport_admin_options[mlsimport_mls_name_front]" placeholder="search your MLS" value="<?php
277 if ( ! empty( $options['mlsimport_mls_name_front'] ) ) {
278 echo esc_html($options['mlsimport_mls_name_front']);
279 }
280 ?>">
281
282
283 <input type="hidden" id="mlsimport_mls_name" name="mlsimport_admin_options[mlsimport_mls_name]" value="<?php
284 if ( ! empty( $value ) ) {
285 echo esc_html($value);
286 }
287 ?>">
288
289
290 <?php
291 // Theme selector: render a select list of supported themes (escaped via wp_kses).
292 } elseif ( 'mlsimport_theme_used' === $key && isset( $setting['type'] ) and 'select' === $setting['type'] ) {
293 $permited_tags = mlsimport_allowed_html_tags_content();
294 // Same rule as the wizard account step: the saved answer when there
295 // is one, the detected theme when there is not (#242).
296 $list = mlsiport_mls_select_list( $key, mlsimport_resolve_theme_id(), MLSIMPORT_THEME);
297 print wp_kses( $list ,$permited_tags );
298 } else {
299 // Default: a plain text input (password type for the password fields).
300 ?>
301
302 <input
303 <?php
304 if ( in_array( $key, array( 'mlsimport_password', 'mlsimport_connectmls_password' ), true ) ) { ?>
305 type="password"
306 <?php
307 } else { ?>
308 type="text"
309 <?php
310 }
311 ?>
312
313 class="mlsimport-input mlsimport-2025-input " autocomplete="off"
314 id="<?php echo esc_attr( $this->plugin_name . '_admin_options' ); ?>-<?php echo esc_attr( $key ); ?>"
315 name="<?php echo esc_attr( $this->plugin_name . '_admin_options' ); ?>[<?php echo esc_attr( $key ); ?>]"
316 value="<?php
317 if ( ! empty( $value ) ) {
318 echo trim( esc_html( ( $value ) ) );
319 } else {
320 echo '';
321 }
322 ?>"/>
323 <?php } ?>
324 </fieldset>
325 <?php } ?>
326
327
328 <input type="hidden" name="<?php echo esc_attr($this->plugin_name) . '_admin_options'; ?>[force_rand]" value="<?php echo esc_attr( wp_rand() ); ?>">
329
330 <?php
331 // Save button (with a custom data-style attribute for the plugin's button styling).
332 $attributes = array( 'data-style' => 'mlsimport_but' );
333 submit_button( __( 'Save Changes', 'mlsimport' ), 'mlsimport_button save_data', 'submit', true, $attributes );
334 ?>
335 </form>
336
337
338
339 <?php
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355 ?>