PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 7.2.1
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v7.2.1
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
← All changes | includes/class-mlsimport.php +69 -13 5.8.37.2.1 View file →
@@ -1,5 +1,17 @@
1 -<?php
1 +<?php
2 +/**
3 + * Core plugin bootstrap class.
4 + *
5 + * Defines Mlsimport, the orchestrator instantiated from mlsimport.php. It loads the
6 + * plugin's dependencies (loader, i18n, admin, custom post type, public), then registers
7 + * every WordPress hook — admin enqueues, option-save handlers, admin menu, AJAX handlers,
8 + * background-import actions, and the public-facing filters — through the Mlsimport_Loader.
9 + * Calling run() finally hands the collected hooks to WordPress.
10 + *
11 + * @package MLSImport
12 + */
13 +// Abort if the file is accessed directly outside of WordPress.
2 14 if ( ! defined( 'ABSPATH' ) ) {
3 15 exit; // Exit if accessed directly
4 16 }
5 17
@@ -85,16 +97,22 @@
85 97 * @var object The admin class.
86 98 */
87 99 public $public;
88 100
101 + /**
102 + * Set the plugin name/version and wire up all dependencies and hooks.
103 + */
89 104 public function __construct() {
105 + // Use the defined plugin version constant, else fall back to 1.0.0.
90 106 if ( defined( 'MLSIMPORT_VERSION' ) ) {
91 107 $this->version = MLSIMPORT_VERSION;
92 108 } else {
93 109 $this->version = '1.0.0';
94 110 }
111 + // Unique plugin identifier used for option keys and hook names.
95 112 $this->plugin_name = 'mlsimport';
96 113
114 + // Load classes, set translations, then register admin + public hooks.
97 115 $this->load_dependencies();
98 116 $this->set_locale();
99 117 $this->define_admin_hooks();
100 118 $this->define_public_hooks();
@@ -121,8 +139,9 @@
121 139 /**
122 140 * The class responsible for orchestrating the actions and filters of the
123 141 * core plugin.
124 142 */
143 + // Hook loader/registry.
125 144 require_once plugin_dir_path( __DIR__ ) . 'includes/class-mlsimport-loader.php';
126 145
127 146 /**
128 147 * The class responsible for defining internationalization functionality
@@ -127,18 +146,21 @@
127 146 /**
128 147 * The class responsible for defining internationalization functionality
129 148 * of the plugin.
130 149 */
150 + // Translation loading.
131 151 require_once plugin_dir_path( __DIR__ ) . 'includes/class-mlsimport-i18n.php';
132 152
133 153 /**
134 154 * The class responsible for defining all actions that occur in the admin area.
135 155 */
156 + // Admin monolith (settings, AJAX, imports).
136 157 require_once plugin_dir_path( __DIR__ ) . 'admin/class-mlsimport-admin.php';
137 158
138 159 /**
139 160 * The class responsible for custom post type
140 161 */
162 + // mlsimport_item custom post type.
141 163 require_once plugin_dir_path( __DIR__ ) . 'includes/class-mlsimport-item.php';
142 164
143 165 /**
144 166 * The class responsible for defining all actions that occur in the public-facing
@@ -143,10 +165,12 @@
143 165 /**
144 166 * The class responsible for defining all actions that occur in the public-facing
145 167 * side of the site.
146 168 */
169 + // Public-facing side of the plugin.
147 170 require_once plugin_dir_path( __DIR__ ) . 'public/class-mlsimport-public.php';
148 171
172 + // Instantiate the loader that collects all hook registrations.
149 173 $this->loader = new Mlsimport_Loader();
150 174 }
151 175
152 176 /**
@@ -159,11 +183,14 @@
159 183 * @access private
160 184 */
161 185 private function set_locale() {
162 186
187 + // The i18n helper that loads the plugin's text domain.
163 188 $plugin_i18n = new Mlsimport_i18n();
164 189
165 - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
190 + // Load translations at `init` to ensure the locale is fully set.
191 + // Loading earlier can trigger WordPress notices starting WP 6.7.
192 + $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' );
166 193 }
167 194
168 195 /**
169 196 * Register all of the hooks related to the admin area functionality
@@ -173,52 +200,66 @@
173 200 * @access private
174 201 */
175 202 private function define_admin_hooks() {
176 203
204 + // Instantiate the admin class (kept public via $this->admin) and configure it.
177 205 $this->admin = $plugin_admin = new Mlsimport_Admin( $this->get_plugin_name(), $this->get_version() );
178 206
207 + // Pass the current MLS provider and theme environment into the admin class.
179 208 $this->admin->admin_setup( $this->get_plugin_name(), $this->get_plugin_data( 'mls_enviroment' ), $this->get_plugin_data( 'theme_enviroment' ) );
180 209
210 + // Enqueue admin CSS/JS.
181 211 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_styles' );
182 212 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_scripts' );
183 213
214 + // Register the mlsimport_item custom post type late on init (priority 999).
184 215 $plugin_post_types = new Mlsimport_Item();
185 216 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
186 217
187 218 // save and render metaboxed
219 + // Import-task metaboxes: render on admin_init, persist on save_post.
188 220 $this->loader->add_action( 'admin_init', $plugin_admin, 'mlsimport_item_product_metaboxes' );
189 221 $this->loader->add_action( 'save_post', $plugin_admin, 'mlsimport_item_product_save_metaboxes', 1, 2 );
190 222
191 223 // Save/Update our plugin options
224 + // Persist settings, and react to changes of the field-selection option.
192 225 $this->loader->add_action( 'admin_init', $this->admin, 'options_update' );
193 226 $this->loader->add_action( 'update_option_' . $this->plugin_name . '_admin_fields_select', $this->admin, 'update_option_mlsimport_admin_fields_select' );
194 227 $this->loader->add_action( 'add_option_' . $this->plugin_name . '_admin_fields_select', $this->admin, 'update_option_mlsimport_admin_fields_select' );
195 228
196 - $this->loader->add_action( 'update_option_' . $this->plugin_name . '_administrative_options', $this->admin, 'update_option_mlsimport_administrative_options' );
197 -
198 229 // Add menu item
199 230 $this->loader->add_action( 'admin_menu', $this->admin, 'add_plugin_admin_menu' );
200 231
201 232 // Add Settings link to the plugin list
233 + // Build this plugin's basename to target the plugin-row action links filter.
202 234 $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' );
203 235 $this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $this->admin, 'add_action_links' );
204 236
237 + // Register additional metabox options on admin_init.
205 238 $this->loader->add_action( 'admin_init', $this->admin, 'mlsimport_meta_options' );
206 239
240 + // AJAX: per-item move/stop/metadata handlers.
207 241 $this->loader->add_action( 'wp_ajax_mlsimport_move_files_per_item', $this->admin, 'mlsimport_move_files_per_item' );
208 242 $this->loader->add_action( 'wp_ajax_mlsimport_stop_import_per_item', $this->admin, 'mlsimport_stop_import_per_item' );
209 243 $this->loader->add_action( 'wp_ajax_mlsimport_saas_get_metadata_function', $this->admin, 'mlsimport_saas_get_metadata_function' );
210 244
245 + // Background import processing actions (full run and initial batch).
211 246 $this->loader->add_action( 'mlsimport_background_process_per_item', $this->admin, 'mlsimport_background_process_per_item_function', 10, 1 );
212 247 $this->loader->add_action( 'mlsimport_background_process_per_item_inital_batch', $this->admin, 'mlsimport_background_process_per_item_inital_batch_function', 10, 1 );
213 248
249 + // AJAX: logging and file-move handlers.
214 250 $this->loader->add_action( 'wp_ajax_mlsimport_logger_per_item', $this->admin, 'mlsimport_logger_per_item' );
251 + // AJAX: file-move and AWS log-move handlers.
215 252 $this->loader->add_action( 'wp_ajax_mlsimport_move_files', $this->admin, 'mlsimport_move_files' );
216 253 $this->loader->add_action( 'wp_ajax_mlsimport_move_files_to_aws_logger', $this->admin, 'mlsimport_move_files_to_aws_logger' );
217 - $this->loader->add_action( 'wp_ajax_mlsimport_stop_moving_files', $this->admin, 'mlsimport_stop_moving_files' );
218 - $this->loader->add_action( 'wp_ajax_mlsimport_delete_cache', $this->admin, 'mlsimport_delete_cache' );
219 - $this->loader->add_action( 'wp_ajax_mlsimport_delete_properties', $this->admin, 'mlsimport_delete_properties' );
220 - }
254 + // AJAX: stop-move, cache clear, field reset, property delete, term lookup, exit survey.
255 + $this->loader->add_action( 'wp_ajax_mlsimport_stop_moving_files', $this->admin, 'mlsimport_stop_moving_files' );
256 + $this->loader->add_action( 'wp_ajax_mlsimport_delete_cache', $this->admin, 'mlsimport_delete_cache' );
257 + $this->loader->add_action( 'wp_ajax_mlsimport_clear_fields_data', $this->admin, 'mlsimport_clear_fields_data' );
258 + $this->loader->add_action( 'wp_ajax_mlsimport_delete_properties', $this->admin, 'mlsimport_delete_properties' );
259 + $this->loader->add_action( 'wp_ajax_mlsimport_get_taxonomy_terms', $this->admin, 'mlsimport_get_taxonomy_terms' );
260 + $this->loader->add_action( 'wp_ajax_mlsimport_exit_survey_submit', $this->admin, 'mlsimport_exit_survey_submit' );
261 + }
221 262
222 263 /**
223 264 * Register all of the hooks related to the public-facing functionality
224 265 * of the plugin.
@@ -227,13 +268,18 @@
227 268 * @access private
228 269 */
229 270 private function define_public_hooks() {
230 271
272 + // Instantiate the public-facing class.
231 273 $plugin_public = new Mlsimport_Public( $this->get_plugin_name(), $this->get_version() );
232 274
275 + // Enqueue front-end CSS/JS.
233 276 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
234 277 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
278 + // Rewrite attachment URLs for remotely-hosted MLS images.
235 279 $this->loader->add_filter( 'wp_get_attachment_url', $plugin_public, 'mlsimport_wp_get_attachment_url', 99, 2 );
280 +
281 +
236 282 }
237 283
238 284 /**
239 285 * Run the loader to execute all of the hooks with WordPress.
@@ -240,8 +286,9 @@
240 286 *
241 287 * @since 1.0.0
242 288 */
243 289 public function run() {
290 + // Hand all collected hooks over to WordPress.
244 291 $this->loader->run();
245 292 }
246 293
247 294 /**
@@ -251,8 +298,9 @@
251 298 * @since 1.0.0
252 299 * @return string The name of the plugin.
253 300 */
254 301 public function get_plugin_name() {
302 + // Return the stored plugin identifier.
255 303 return $this->plugin_name;
256 304 }
257 305
258 306 /**
@@ -261,8 +309,9 @@
261 309 * @since 1.0.0
262 310 * @return Mlsimport_Loader Orchestrates the hooks of the plugin.
263 311 */
264 312 public function get_loader() {
313 + // Return the hook loader instance.
265 314 return $this->loader;
266 315 }
267 316
268 317 /**
@@ -271,8 +320,9 @@
271 320 * @since 1.0.0
272 321 * @return string The version number of the plugin.
273 322 */
274 323 public function get_version() {
324 + // Return the resolved plugin version.
275 325 return $this->version;
276 326 }
277 327
278 328 /**
@@ -277,14 +327,18 @@
277 327
278 328 /**
279 329 * return plugin shema
280 330 *
331 + * Placeholder schema accessor; currently returns an empty string.
332 + *
281 333 * @since 1.0.0
282 334 * @access protected
283 335 * @var string $plugin_name
336 + * @return string Empty string (no schema).
284 337 */
285 338 public function return_plugin_schema() {
286 339
340 + // No schema defined at this level.
287 341 return '';
288 342 }
289 343
290 344 /**
@@ -289,20 +343,22 @@
289 343
290 344 /**
291 345 * return plugin data
292 346 *
347 + * Reads a single value from the plugin schema. Provider behavior is resolved
348 + * by Mlsimport_Provider_Family and does not belong in this core accessor.
349 + *
293 350 * @since 1.0.0
294 351 * @access protected
295 352 * @var string $plugin_name
353 + * @param string $what The schema key to fetch (e.g. 'mls_enviroment').
354 + * @return mixed The requested value, or '' when unavailable.
296 355 */
297 356 public function get_plugin_data( $what ) {
357 + // Pull the (currently empty) plugin schema.
298 358 $plugin_data = $this->return_plugin_schema();
299 359
300 - if ( isset( $plugin_data['mls_enviroment'] ) && 'TresleReso' === $plugin_data['mls_enviroment'] && 'server_token' === $what ) {
301 - $tresle_token = $this->return_tresle_token();
302 - return $tresle_token;
303 - }
304 -
360 + // Return the requested key when present, else empty string.
305 361 if ( isset( $plugin_data[ $what ] ) ) {
306 362 return $plugin_data[ $what ];
307 363 } else {
308 364 return '';