PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 6.0.7
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v6.0.7
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 6.0.7 All 35 releases
mlsimport / includes / class-mlsimport.php

class-mlsimport.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 6.0.7, at includes/class-mlsimport.php

317 lines 10.0 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
6 /**
7 * The file that defines the core plugin class
8 *
9 * A class definition that includes attributes and functions used across both the
10 * public-facing side of the site and the admin area.
11 *
12 * @link http://mlsimport.com/
13 * @since 1.0.0
14 *
15 * @package Mlsimport
16 * @subpackage Mlsimport/includes
17 */
18
19 /**
20 * The core plugin class.
21 *
22 * This is used to define internationalization, admin-specific hooks, and
23 * public-facing site hooks.
24 *
25 * Also maintains the unique identifier of this plugin as well as the current
26 * version of the plugin.
27 *
28 * @since 1.0.0
29 * @package Mlsimport
30 * @subpackage Mlsimport/includes
31 * @author MlsImport <office@mlsimport.com>
32 */
33 class Mlsimport {
34
35 /**
36 * The loader that's responsible for maintaining and registering all hooks that power
37 * the plugin.
38 *
39 * @since 1.0.0
40 * @access protected
41 * @var Mlsimport_Loader $loader Maintains and registers all hooks for the plugin.
42 */
43 protected $loader;
44
45 /**
46 * The unique identifier of this plugin.
47 *
48 * @since 1.0.0
49 * @access protected
50 * @var string $plugin_name The string used to uniquely identify this plugin.
51 */
52 protected $plugin_name;
53
54 /**
55 * The current version of the plugin.
56 *
57 * @since 1.0.0
58 * @access protected
59 * @var string $version The current version of the plugin.
60 */
61 protected $version;
62
63 /**
64 * Define the core functionality of the plugin.
65 *
66 * Set the plugin name and the plugin version that can be used throughout the plugin.
67 * Load the dependencies, define the locale, and set the hooks for the admin area and
68 * the public-facing side of the site.
69 *
70 * @since 1.0.0
71 */
72
73 /**
74 * Store plugin admin class to allow public access.
75 *
76 * @since 20180622
77 * @var object The admin class.
78 */
79 public $admin;
80
81 /**
82 * Store plugin public class to allow public access.
83 *
84 * @since 20180622
85 * @var object The admin class.
86 */
87 public $public;
88
89 public function __construct() {
90 if ( defined( 'MLSIMPORT_VERSION' ) ) {
91 $this->version = MLSIMPORT_VERSION;
92 } else {
93 $this->version = '1.0.0';
94 }
95 $this->plugin_name = 'mlsimport';
96
97 $this->load_dependencies();
98 $this->set_locale();
99 $this->define_admin_hooks();
100 $this->define_public_hooks();
101 }
102
103 /**
104 * Load the required dependencies for this plugin.
105 *
106 * Include the following files that make up the plugin:
107 *
108 * - Mlsimport_Loader. Orchestrates the hooks of the plugin.
109 * - Mlsimport_i18n. Defines internationalization functionality.
110 * - Mlsimport_Admin. Defines all hooks for the admin area.
111 * - Mlsimport_Public. Defines all hooks for the public side of the site.
112 *
113 * Create an instance of the loader which will be used to register the hooks
114 * with WordPress.
115 *
116 * @since 1.0.0
117 * @access private
118 */
119 private function load_dependencies() {
120
121 /**
122 * The class responsible for orchestrating the actions and filters of the
123 * core plugin.
124 */
125 require_once plugin_dir_path( __DIR__ ) . 'includes/class-mlsimport-loader.php';
126
127 /**
128 * The class responsible for defining internationalization functionality
129 * of the plugin.
130 */
131 require_once plugin_dir_path( __DIR__ ) . 'includes/class-mlsimport-i18n.php';
132
133 /**
134 * The class responsible for defining all actions that occur in the admin area.
135 */
136 require_once plugin_dir_path( __DIR__ ) . 'admin/class-mlsimport-admin.php';
137
138 /**
139 * The class responsible for custom post type
140 */
141 require_once plugin_dir_path( __DIR__ ) . 'includes/class-mlsimport-item.php';
142
143 /**
144 * The class responsible for defining all actions that occur in the public-facing
145 * side of the site.
146 */
147 require_once plugin_dir_path( __DIR__ ) . 'public/class-mlsimport-public.php';
148
149 $this->loader = new Mlsimport_Loader();
150 }
151
152 /**
153 * Define the locale for this plugin for internationalization.
154 *
155 * Uses the Mlsimport_i18n class in order to set the domain and to register the hook
156 * with WordPress.
157 *
158 * @since 1.0.0
159 * @access private
160 */
161 private function set_locale() {
162
163 $plugin_i18n = new Mlsimport_i18n();
164
165 // Load translations at `init` to ensure the locale is fully set.
166 // Loading earlier can trigger WordPress notices starting WP 6.7.
167 $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' );
168 }
169
170 /**
171 * Register all of the hooks related to the admin area functionality
172 * of the plugin.
173 *
174 * @since 1.0.0
175 * @access private
176 */
177 private function define_admin_hooks() {
178
179 $this->admin = $plugin_admin = new Mlsimport_Admin( $this->get_plugin_name(), $this->get_version() );
180
181 $this->admin->admin_setup( $this->get_plugin_name(), $this->get_plugin_data( 'mls_enviroment' ), $this->get_plugin_data( 'theme_enviroment' ) );
182
183 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_styles' );
184 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_scripts' );
185
186 $plugin_post_types = new Mlsimport_Item();
187 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
188
189 // save and render metaboxed
190 $this->loader->add_action( 'admin_init', $plugin_admin, 'mlsimport_item_product_metaboxes' );
191 $this->loader->add_action( 'save_post', $plugin_admin, 'mlsimport_item_product_save_metaboxes', 1, 2 );
192
193 // Save/Update our plugin options
194 $this->loader->add_action( 'admin_init', $this->admin, 'options_update' );
195 $this->loader->add_action( 'update_option_' . $this->plugin_name . '_admin_fields_select', $this->admin, 'update_option_mlsimport_admin_fields_select' );
196 $this->loader->add_action( 'add_option_' . $this->plugin_name . '_admin_fields_select', $this->admin, 'update_option_mlsimport_admin_fields_select' );
197
198 $this->loader->add_action( 'update_option_' . $this->plugin_name . '_administrative_options', $this->admin, 'update_option_mlsimport_administrative_options' );
199
200 // Add menu item
201 $this->loader->add_action( 'admin_menu', $this->admin, 'add_plugin_admin_menu' );
202
203 // Add Settings link to the plugin list
204 $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' );
205 $this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $this->admin, 'add_action_links' );
206
207 $this->loader->add_action( 'admin_init', $this->admin, 'mlsimport_meta_options' );
208
209 $this->loader->add_action( 'wp_ajax_mlsimport_move_files_per_item', $this->admin, 'mlsimport_move_files_per_item' );
210 $this->loader->add_action( 'wp_ajax_mlsimport_stop_import_per_item', $this->admin, 'mlsimport_stop_import_per_item' );
211 $this->loader->add_action( 'wp_ajax_mlsimport_saas_get_metadata_function', $this->admin, 'mlsimport_saas_get_metadata_function' );
212
213 $this->loader->add_action( 'mlsimport_background_process_per_item', $this->admin, 'mlsimport_background_process_per_item_function', 10, 1 );
214 $this->loader->add_action( 'mlsimport_background_process_per_item_inital_batch', $this->admin, 'mlsimport_background_process_per_item_inital_batch_function', 10, 1 );
215
216 $this->loader->add_action( 'wp_ajax_mlsimport_logger_per_item', $this->admin, 'mlsimport_logger_per_item' );
217 $this->loader->add_action( 'wp_ajax_mlsimport_move_files', $this->admin, 'mlsimport_move_files' );
218 $this->loader->add_action( 'wp_ajax_mlsimport_move_files_to_aws_logger', $this->admin, 'mlsimport_move_files_to_aws_logger' );
219 $this->loader->add_action( 'wp_ajax_mlsimport_stop_moving_files', $this->admin, 'mlsimport_stop_moving_files' );
220 $this->loader->add_action( 'wp_ajax_mlsimport_delete_cache', $this->admin, 'mlsimport_delete_cache' );
221 $this->loader->add_action( 'wp_ajax_mlsimport_clear_fields_data', $this->admin, 'mlsimport_clear_fields_data' );
222 $this->loader->add_action( 'wp_ajax_mlsimport_delete_properties', $this->admin, 'mlsimport_delete_properties' );
223 }
224
225 /**
226 * Register all of the hooks related to the public-facing functionality
227 * of the plugin.
228 *
229 * @since 1.0.0
230 * @access private
231 */
232 private function define_public_hooks() {
233
234 $plugin_public = new Mlsimport_Public( $this->get_plugin_name(), $this->get_version() );
235
236 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
237 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
238 $this->loader->add_filter( 'wp_get_attachment_url', $plugin_public, 'mlsimport_wp_get_attachment_url', 99, 2 );
239
240
241 }
242
243 /**
244 * Run the loader to execute all of the hooks with WordPress.
245 *
246 * @since 1.0.0
247 */
248 public function run() {
249 $this->loader->run();
250 }
251
252 /**
253 * The name of the plugin used to uniquely identify it within the context of
254 * WordPress and to define internationalization functionality.
255 *
256 * @since 1.0.0
257 * @return string The name of the plugin.
258 */
259 public function get_plugin_name() {
260 return $this->plugin_name;
261 }
262
263 /**
264 * The reference to the class that orchestrates the hooks with the plugin.
265 *
266 * @since 1.0.0
267 * @return Mlsimport_Loader Orchestrates the hooks of the plugin.
268 */
269 public function get_loader() {
270 return $this->loader;
271 }
272
273 /**
274 * Retrieve the version number of the plugin.
275 *
276 * @since 1.0.0
277 * @return string The version number of the plugin.
278 */
279 public function get_version() {
280 return $this->version;
281 }
282
283 /**
284 * return plugin shema
285 *
286 * @since 1.0.0
287 * @access protected
288 * @var string $plugin_name
289 */
290 public function return_plugin_schema() {
291
292 return '';
293 }
294
295 /**
296 * return plugin data
297 *
298 * @since 1.0.0
299 * @access protected
300 * @var string $plugin_name
301 */
302 public function get_plugin_data( $what ) {
303 $plugin_data = $this->return_plugin_schema();
304
305 if ( isset( $plugin_data['mls_enviroment'] ) && 'TresleReso' === $plugin_data['mls_enviroment'] && 'server_token' === $what ) {
306 $tresle_token = $this->return_tresle_token();
307 return $tresle_token;
308 }
309
310 if ( isset( $plugin_data[ $what ] ) ) {
311 return $plugin_data[ $what ];
312 } else {
313 return '';
314 }
315 }
316 }
317