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 +57 -8 6.3.77.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,8 +183,9 @@
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 190 // Load translations at `init` to ensure the locale is fully set.
166 191 // Loading earlier can trigger WordPress notices starting WP 6.7.
@@ -175,48 +200,59 @@
175 200 * @access private
176 201 */
177 202 private function define_admin_hooks() {
178 203
204 + // Instantiate the admin class (kept public via $this->admin) and configure it.
179 205 $this->admin = $plugin_admin = new Mlsimport_Admin( $this->get_plugin_name(), $this->get_version() );
180 206
207 + // Pass the current MLS provider and theme environment into the admin class.
181 208 $this->admin->admin_setup( $this->get_plugin_name(), $this->get_plugin_data( 'mls_enviroment' ), $this->get_plugin_data( 'theme_enviroment' ) );
182 209
210 + // Enqueue admin CSS/JS.
183 211 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_styles' );
184 212 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_scripts' );
185 213
214 + // Register the mlsimport_item custom post type late on init (priority 999).
186 215 $plugin_post_types = new Mlsimport_Item();
187 216 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
188 217
189 218 // save and render metaboxed
219 + // Import-task metaboxes: render on admin_init, persist on save_post.
190 220 $this->loader->add_action( 'admin_init', $plugin_admin, 'mlsimport_item_product_metaboxes' );
191 221 $this->loader->add_action( 'save_post', $plugin_admin, 'mlsimport_item_product_save_metaboxes', 1, 2 );
192 222
193 223 // Save/Update our plugin options
224 + // Persist settings, and react to changes of the field-selection option.
194 225 $this->loader->add_action( 'admin_init', $this->admin, 'options_update' );
195 226 $this->loader->add_action( 'update_option_' . $this->plugin_name . '_admin_fields_select', $this->admin, 'update_option_mlsimport_admin_fields_select' );
196 227 $this->loader->add_action( 'add_option_' . $this->plugin_name . '_admin_fields_select', $this->admin, 'update_option_mlsimport_admin_fields_select' );
197 228
198 - $this->loader->add_action( 'update_option_' . $this->plugin_name . '_administrative_options', $this->admin, 'update_option_mlsimport_administrative_options' );
199 -
200 229 // Add menu item
201 230 $this->loader->add_action( 'admin_menu', $this->admin, 'add_plugin_admin_menu' );
202 231
203 232 // Add Settings link to the plugin list
233 + // Build this plugin's basename to target the plugin-row action links filter.
204 234 $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' );
205 235 $this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $this->admin, 'add_action_links' );
206 236
237 + // Register additional metabox options on admin_init.
207 238 $this->loader->add_action( 'admin_init', $this->admin, 'mlsimport_meta_options' );
208 239
240 + // AJAX: per-item move/stop/metadata handlers.
209 241 $this->loader->add_action( 'wp_ajax_mlsimport_move_files_per_item', $this->admin, 'mlsimport_move_files_per_item' );
210 242 $this->loader->add_action( 'wp_ajax_mlsimport_stop_import_per_item', $this->admin, 'mlsimport_stop_import_per_item' );
211 243 $this->loader->add_action( 'wp_ajax_mlsimport_saas_get_metadata_function', $this->admin, 'mlsimport_saas_get_metadata_function' );
212 244
245 + // Background import processing actions (full run and initial batch).
213 246 $this->loader->add_action( 'mlsimport_background_process_per_item', $this->admin, 'mlsimport_background_process_per_item_function', 10, 1 );
214 247 $this->loader->add_action( 'mlsimport_background_process_per_item_inital_batch', $this->admin, 'mlsimport_background_process_per_item_inital_batch_function', 10, 1 );
215 248
249 + // AJAX: logging and file-move handlers.
216 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.
217 252 $this->loader->add_action( 'wp_ajax_mlsimport_move_files', $this->admin, 'mlsimport_move_files' );
218 253 $this->loader->add_action( 'wp_ajax_mlsimport_move_files_to_aws_logger', $this->admin, 'mlsimport_move_files_to_aws_logger' );
254 + // AJAX: stop-move, cache clear, field reset, property delete, term lookup, exit survey.
219 255 $this->loader->add_action( 'wp_ajax_mlsimport_stop_moving_files', $this->admin, 'mlsimport_stop_moving_files' );
220 256 $this->loader->add_action( 'wp_ajax_mlsimport_delete_cache', $this->admin, 'mlsimport_delete_cache' );
221 257 $this->loader->add_action( 'wp_ajax_mlsimport_clear_fields_data', $this->admin, 'mlsimport_clear_fields_data' );
222 258 $this->loader->add_action( 'wp_ajax_mlsimport_delete_properties', $this->admin, 'mlsimport_delete_properties' );
@@ -232,12 +268,15 @@
232 268 * @access private
233 269 */
234 270 private function define_public_hooks() {
235 271
272 + // Instantiate the public-facing class.
236 273 $plugin_public = new Mlsimport_Public( $this->get_plugin_name(), $this->get_version() );
237 274
275 + // Enqueue front-end CSS/JS.
238 276 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
239 277 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
278 + // Rewrite attachment URLs for remotely-hosted MLS images.
240 279 $this->loader->add_filter( 'wp_get_attachment_url', $plugin_public, 'mlsimport_wp_get_attachment_url', 99, 2 );
241 280
242 281
243 282 }
@@ -247,8 +286,9 @@
247 286 *
248 287 * @since 1.0.0
249 288 */
250 289 public function run() {
290 + // Hand all collected hooks over to WordPress.
251 291 $this->loader->run();
252 292 }
253 293
254 294 /**
@@ -258,8 +298,9 @@
258 298 * @since 1.0.0
259 299 * @return string The name of the plugin.
260 300 */
261 301 public function get_plugin_name() {
302 + // Return the stored plugin identifier.
262 303 return $this->plugin_name;
263 304 }
264 305
265 306 /**
@@ -268,8 +309,9 @@
268 309 * @since 1.0.0
269 310 * @return Mlsimport_Loader Orchestrates the hooks of the plugin.
270 311 */
271 312 public function get_loader() {
313 + // Return the hook loader instance.
272 314 return $this->loader;
273 315 }
274 316
275 317 /**
@@ -278,8 +320,9 @@
278 320 * @since 1.0.0
279 321 * @return string The version number of the plugin.
280 322 */
281 323 public function get_version() {
324 + // Return the resolved plugin version.
282 325 return $this->version;
283 326 }
284 327
285 328 /**
@@ -284,14 +327,18 @@
284 327
285 328 /**
286 329 * return plugin shema
287 330 *
331 + * Placeholder schema accessor; currently returns an empty string.
332 + *
288 333 * @since 1.0.0
289 334 * @access protected
290 335 * @var string $plugin_name
336 + * @return string Empty string (no schema).
291 337 */
292 338 public function return_plugin_schema() {
293 339
340 + // No schema defined at this level.
294 341 return '';
295 342 }
296 343
297 344 /**
@@ -296,20 +343,22 @@
296 343
297 344 /**
298 345 * return plugin data
299 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 + *
300 350 * @since 1.0.0
301 351 * @access protected
302 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.
303 355 */
304 356 public function get_plugin_data( $what ) {
357 + // Pull the (currently empty) plugin schema.
305 358 $plugin_data = $this->return_plugin_schema();
306 359
307 - if ( isset( $plugin_data['mls_enviroment'] ) && 'TresleReso' === $plugin_data['mls_enviroment'] && 'server_token' === $what ) {
308 - $tresle_token = $this->return_tresle_token();
309 - return $tresle_token;
310 - }
311 -
360 + // Return the requested key when present, else empty string.
312 361 if ( isset( $plugin_data[ $what ] ) ) {
313 362 return $plugin_data[ $what ];
314 363 } else {
315 364 return '';