PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 5.8.3
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v5.8.3
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 5.8.3, at includes/class-mlsimport.php

312 lines 9.6 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 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
166 }
167
168 /**
169 * Register all of the hooks related to the admin area functionality
170 * of the plugin.
171 *
172 * @since 1.0.0
173 * @access private
174 */
175 private function define_admin_hooks() {
176
177 $this->admin = $plugin_admin = new Mlsimport_Admin( $this->get_plugin_name(), $this->get_version() );
178
179 $this->admin->admin_setup( $this->get_plugin_name(), $this->get_plugin_data( 'mls_enviroment' ), $this->get_plugin_data( 'theme_enviroment' ) );
180
181 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_styles' );
182 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_scripts' );
183
184 $plugin_post_types = new Mlsimport_Item();
185 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
186
187 // save and render metaboxed
188 $this->loader->add_action( 'admin_init', $plugin_admin, 'mlsimport_item_product_metaboxes' );
189 $this->loader->add_action( 'save_post', $plugin_admin, 'mlsimport_item_product_save_metaboxes', 1, 2 );
190
191 // Save/Update our plugin options
192 $this->loader->add_action( 'admin_init', $this->admin, 'options_update' );
193 $this->loader->add_action( 'update_option_' . $this->plugin_name . '_admin_fields_select', $this->admin, 'update_option_mlsimport_admin_fields_select' );
194 $this->loader->add_action( 'add_option_' . $this->plugin_name . '_admin_fields_select', $this->admin, 'update_option_mlsimport_admin_fields_select' );
195
196 $this->loader->add_action( 'update_option_' . $this->plugin_name . '_administrative_options', $this->admin, 'update_option_mlsimport_administrative_options' );
197
198 // Add menu item
199 $this->loader->add_action( 'admin_menu', $this->admin, 'add_plugin_admin_menu' );
200
201 // Add Settings link to the plugin list
202 $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' );
203 $this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $this->admin, 'add_action_links' );
204
205 $this->loader->add_action( 'admin_init', $this->admin, 'mlsimport_meta_options' );
206
207 $this->loader->add_action( 'wp_ajax_mlsimport_move_files_per_item', $this->admin, 'mlsimport_move_files_per_item' );
208 $this->loader->add_action( 'wp_ajax_mlsimport_stop_import_per_item', $this->admin, 'mlsimport_stop_import_per_item' );
209 $this->loader->add_action( 'wp_ajax_mlsimport_saas_get_metadata_function', $this->admin, 'mlsimport_saas_get_metadata_function' );
210
211 $this->loader->add_action( 'mlsimport_background_process_per_item', $this->admin, 'mlsimport_background_process_per_item_function', 10, 1 );
212 $this->loader->add_action( 'mlsimport_background_process_per_item_inital_batch', $this->admin, 'mlsimport_background_process_per_item_inital_batch_function', 10, 1 );
213
214 $this->loader->add_action( 'wp_ajax_mlsimport_logger_per_item', $this->admin, 'mlsimport_logger_per_item' );
215 $this->loader->add_action( 'wp_ajax_mlsimport_move_files', $this->admin, 'mlsimport_move_files' );
216 $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 }
221
222 /**
223 * Register all of the hooks related to the public-facing functionality
224 * of the plugin.
225 *
226 * @since 1.0.0
227 * @access private
228 */
229 private function define_public_hooks() {
230
231 $plugin_public = new Mlsimport_Public( $this->get_plugin_name(), $this->get_version() );
232
233 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
234 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
235 $this->loader->add_filter( 'wp_get_attachment_url', $plugin_public, 'mlsimport_wp_get_attachment_url', 99, 2 );
236 }
237
238 /**
239 * Run the loader to execute all of the hooks with WordPress.
240 *
241 * @since 1.0.0
242 */
243 public function run() {
244 $this->loader->run();
245 }
246
247 /**
248 * The name of the plugin used to uniquely identify it within the context of
249 * WordPress and to define internationalization functionality.
250 *
251 * @since 1.0.0
252 * @return string The name of the plugin.
253 */
254 public function get_plugin_name() {
255 return $this->plugin_name;
256 }
257
258 /**
259 * The reference to the class that orchestrates the hooks with the plugin.
260 *
261 * @since 1.0.0
262 * @return Mlsimport_Loader Orchestrates the hooks of the plugin.
263 */
264 public function get_loader() {
265 return $this->loader;
266 }
267
268 /**
269 * Retrieve the version number of the plugin.
270 *
271 * @since 1.0.0
272 * @return string The version number of the plugin.
273 */
274 public function get_version() {
275 return $this->version;
276 }
277
278 /**
279 * return plugin shema
280 *
281 * @since 1.0.0
282 * @access protected
283 * @var string $plugin_name
284 */
285 public function return_plugin_schema() {
286
287 return '';
288 }
289
290 /**
291 * return plugin data
292 *
293 * @since 1.0.0
294 * @access protected
295 * @var string $plugin_name
296 */
297 public function get_plugin_data( $what ) {
298 $plugin_data = $this->return_plugin_schema();
299
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
305 if ( isset( $plugin_data[ $what ] ) ) {
306 return $plugin_data[ $what ];
307 } else {
308 return '';
309 }
310 }
311 }
312