PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 6.0.4
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v6.0.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 / admin / partials / mlsimport-admin-fields-select.php

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

175 lines 6.1 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 $theme_schema= mlsimport_hardocde_theme_schema();
6
7 $options = get_option( 'mlsimport_admin_options' );
8 $mlsimport_mls_metadata_populated = get_option( 'mlsimport_mls_metadata_populated', '' );
9 $permited_tags = mlsimport_allowed_html_tags_content();
10 $post_type = '';
11 if (method_exists($this->env_data, 'get_property_post_type')) {
12 $post_type = $this->env_data->get_property_post_type();
13 }
14
15 $available_taxonomies = mlsimport_get_custom_post_type_taxonomies($post_type);
16
17
18
19
20 if ( 'yes' === $mlsimport_mls_metadata_populated ) {
21 // We have MLS metadata, so we can show the field selection interface
22 ?>
23 <form method="post" class= "mlsimport-import-fields-form" name="cleanup_options" action="options.php">
24 <?php
25
26
27 global $mlsimport;
28 $mlsimport->admin->mlsimport_saas_setting_up();
29
30
31 // Add this to the beginning of the form processing
32 $options = get_option('mlsimport_admin_fields_select', array());
33
34
35 // Ensure all arrays are initialized
36 if (!is_array($options) ||
37 (is_array($options) && empty($options)) ) {
38
39 $mlsimport_mls_metadata_mls_data = get_option( 'mlsimport_mls_metadata_mls_data', '' );
40 $metadata_api_call_data_service_property = json_decode( $mlsimport_mls_metadata_mls_data, true );
41 $options = array();
42
43
44
45 if (!isset($options['mls-fields'])) {
46 $options['mls-fields'] = array();
47 }
48
49 if (!isset($options['mls-fields-admin'])) {
50 $options['mls-fields-admin'] = array();
51 }
52
53 if (!isset($options['mls-fields-label'])) {
54 $options['mls-fields-label'] = array();
55 }
56
57 if (!isset($options['mls-fields-map-postmeta'])) {
58 $options['mls-fields-map-postmeta'] = array();
59 }
60
61 if (!isset($options['mls-fields-map-taxonomy'])) {
62 $options['mls-fields-map-taxonomy'] = array();
63 }
64
65
66 $order_item=0;
67 if (!is_array($metadata_api_call_data_service_property)) {
68 $metadata_api_call_data_service_property = [];
69 }
70
71 ksort($metadata_api_call_data_service_property);
72
73 foreach ( $metadata_api_call_data_service_property as $key => $value ) {
74 $description = 'no description ';
75
76 $options['mls-fields'][ $key ]=0;
77 $options['field_order'][ $key ]=$order_item++;
78 $options['mls-fields-admin'][ $key ]=0 ;
79 $options['mls-fields-map-postmeta'][ $key ]='';
80
81 $options['mls-fields-label'][ $key ]='';
82
83 if ( array_key_exists( $key, $theme_schema ) ) {
84 $options['mls-fields'][ $key ]=1;
85
86 if( isset( $theme_schema[$key]['type']) && $theme_schema[$key]['type']=='taxonomy' ){
87 $options['mls-fields-map-taxonomy'][ $key ]=$theme_schema[$key]['name'];
88 }else{
89 $options['mls-fields-map-taxonomy'][ $key ]='';
90 }
91
92 }
93 }
94
95
96 }
97
98 ?>
99
100
101
102 <h3><?php esc_html_e( 'Select the extra fields you want to import', 'mlsimport' ); ?>:</h3>
103
104 <?php
105
106
107 // $options = get_option( 'mlsimport_admin_fields_select', array() );
108 // print_r($options);
109
110
111
112 // Get the current page and search parameters
113 $current_page = isset( $_GET['mlsimport_page'] ) ? intval( $_GET['mlsimport_page'] ) : 1;
114 $search_term = isset( $_GET['mlsimport_search'] ) ? sanitize_text_field( $_GET['mlsimport_search'] ) : '';
115 $import_filter = isset( $_GET['mlsimport_filter'] ) ? sanitize_text_field( $_GET['mlsimport_filter'] ) : 'all';
116 $alpha_filter = isset( $_GET['mlsimport_alpha'] ) ? sanitize_text_field( $_GET['mlsimport_alpha'] ) : '';
117
118 // Set up render parameters
119 $render_params = array(
120 'page' => $current_page,
121 'fields_per_page' => 99999, // Adjust as needed
122 'search_term' => $search_term,
123 'import_filter' => $import_filter,
124 'alpha_filter' => $alpha_filter,
125 'show_pagination' => true,
126 'show_filters' => true,
127 'show_stats' => true,
128 'enable_drag_drop' => true,
129 'form_action' => 'options.php',
130 'form_method' => 'post',
131 'form_name' => 'cleanup_options',
132 'nonce_field' => 'mlsimport_admin_fields_select',
133 'plugin_name' => 'mlsimport',
134 );
135
136
137
138
139
140
141
142
143 // Then in the admin page, update the function call:
144 echo render_mls_field_selection_interface(
145 $options,
146 $options,
147 $render_params,
148 $theme_schema
149 );
150 ?>
151
152 <input type="hidden" name="mlsimport_admin_fields_select[mls-fields-admin][force_rand]" value="<?php echo esc_attr( wp_rand() ); ?>">
153
154
155 <?php mlsimport_add_field_selector_nonce(); ?>
156 </form>
157 <?php
158 } else {
159 // We don't have MLS metadata yet, show waiting message
160 global $mlsimport;
161 $token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient();
162 if ( trim( $token ) !== '' ) {
163 ?>
164 <div class="mlsimport_warning mlsimport_validated">
165 <?php
166 esc_html_e( 'We need to gather some information about your MLS. Please Stand By! ', 'mlsimport' );
167 ?>
168 </div>
169 <?php
170 } else {
171 esc_html_e( 'You are not connected to MLS Import', 'mlsimport' );
172 }
173 }
174 ?>
175 <input type="hidden" id="mlsimport_saas_get_metadata" value="<?php echo esc_attr( wp_create_nonce( "mlsimport_saas_get_metadata" ) ); ?>" />