PluginProbe
Route ‑ Shipping Protection / 2.4.9
Route ‑ Shipping Protection v2.4.9
2.4.17 2.4.16 2.4.15 2.4.14 2.4.13 2.4.12 2.4.11 2.4.10 2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.2.4 2.2.5 2.2.6 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 All 151 releases
routeapp / includes / class-routeapp.php

class-routeapp.php in Route ‑ Shipping Protection 2.4.9, at includes/class-routeapp.php

463 lines 15.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link https://route.com/
10 * @since 1.0.0
11 *
12 * @package Routeapp
13 * @subpackage Routeapp/includes
14 */
15
16 /**
17 * The core plugin class.
18 *
19 * This is used to define internationalization, admin-specific hooks, and
20 * public-facing site hooks.
21 *
22 * Also maintains the unique identifier of this plugin as well as the current
23 * version of the plugin.
24 *
25 * @since 1.0.0
26 * @package Routeapp
27 * @subpackage Routeapp/includes
28 * @author Route App <support@route.com>
29 */
30 class Routeapp {
31
32 /**
33 * The loader that's responsible for maintaining and registering all hooks that power
34 * the plugin.
35 *
36 * @since 1.0.0
37 * @access protected
38 * @var Routeapp_Loader $loader Maintains and registers all hooks for the plugin.
39 */
40 protected $loader;
41
42 /**
43 * The unique identifier of this plugin.
44 *
45 * @since 1.0.0
46 * @access protected
47 * @var string $plugin_name The string used to uniquely identify this plugin.
48 */
49 protected $plugin_name;
50
51 /**
52 * The current version of the plugin.
53 *
54 * @since 1.0.0
55 * @access protected
56 * @var string $version The current version of the plugin.
57 */
58 protected $version;
59
60 /**
61 * Define the core functionality of the plugin.
62 *
63 * Set the plugin name and the plugin version that can be used throughout the plugin.
64 * Load the dependencies, define the locale, and set the hooks for the admin area and
65 * the public-facing side of the site.
66 *
67 * @since 1.0.0
68 */
69 public function __construct() {
70 if ( defined( 'ROUTEAPP_VERSION' ) ) {
71 $this->version = ROUTEAPP_VERSION;
72 if ($version = get_option('_routeapp_version')) {
73 if ($version!=$this->version) {
74 update_option( '_routeapp_version', $this->version, 'yes' );
75 if (get_option('_routeapp_last_install_date')) {
76 update_option( '_routeapp_last_install_date', date("Y-m-d"), 'yes' );
77 } else {
78 add_option('_routeapp_last_install_date', date("Y-m-d"));
79 }
80 //clear old scheduled cronjobs
81 $this->clear_old_scheduled_cronjobs();
82 }
83 } else {
84 add_option('_routeapp_version', $this->version);
85 add_option('_routeapp_last_install_date', date("Y-m-d"));
86 }
87 } else {
88 $this->version = '1.0.0';
89 }
90 $this->plugin_name = 'routeapp';
91
92 $this->load_dependencies();
93 $this->set_locale();
94 $this->define_admin_hooks();
95 $this->define_public_hooks();
96 $this->define_include_hooks();
97 if ( !$this->routeapp_is_woocommerce_active() ) {
98 add_action( 'admin_notices', array($this,'routeapp_admin_notice__error') );
99 }
100 }
101
102 private function clear_old_scheduled_cronjobs() {
103 if ( function_exists( 'wp_unschedule_hook' ) ) {
104 wp_unschedule_hook('routeapp_check_for_missing_shippings');
105 wp_unschedule_hook('routeapp_check_for_reconcile112version');
106 wp_unschedule_hook('routeapp_check_for_failed_orders');
107 wp_unschedule_hook('routeapp_check_for_weekly_missing_shippings');
108 }
109 }
110
111 /**
112 * Load the required dependencies for this plugin.
113 *
114 * Include the following files that make up the plugin:
115 *
116 * - Routeapp_Loader. Orchestrates the hooks of the plugin.
117 * - Routeapp_i18n. Defines internationalization functionality.
118 * - Routeapp_Admin. Defines all hooks for the admin area.
119 * - Routeapp_Public. Defines all hooks for the public side of the site.
120 *
121 * Create an instance of the loader which will be used to register the hooks
122 * with WordPress.
123 *
124 * @since 1.0.0
125 * @access private
126 */
127 private function load_dependencies() {
128
129 /**
130 * Check dependency of woocommerce
131 */
132 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc-dependencies.php';
133
134 /**
135 * The class responsible for orchestrating the actions and filters of the
136 * core plugin.
137 */
138 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-loader.php';
139
140 /**
141 * The class responsible for defining API calls functionality
142 * of the plugin.
143 */
144 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-api-client.php';
145
146 /**
147 * The class responsible for defining API calls functionality
148 * of the plugin.
149 */
150 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-api-compatibility.php';
151
152 /**
153 * The class responsible for defining internationalization functionality
154 * of the plugin.
155 */
156 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-i18n.php';
157
158 /**
159 * The class responsible for defining all admin notice messages
160 */
161 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-routeapp-notice.php';
162
163 /**
164 * The class responsible for defining all actions that occur in the admin area.
165 */
166 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-routeapp-admin.php';
167
168 /**
169 * The class responsible for handling webhook upserts.
170 */
171 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-routeapp-webhooks.php';
172
173 /**
174 * The class responsible for defining all the plugin integrations
175 */
176 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-integrations.php';
177
178 /**
179 * The class responsible for defining all the supported tracking plugins
180 */
181 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-tracking.php';
182
183 /**
184 * The class responsible for sending logs to Sentry
185 */
186 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-logger-sentry.php';
187
188 /**
189 * The class responsible for defining the interface for the shipment tracking plugins
190 */
191 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-interface-tracking-providers.php';
192
193 /**
194 * The class that has common functions for shipment tracking plugins
195 */
196 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-common-tracking-providers.php';
197
198 /**
199 * The class responsible for integrate the WooCommerce Shipment Tracking plugin
200 */
201 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-woocommerce-shipment-tracking.php';
202
203 /**
204 * The class responsible for integrate the Blazing Shipment Tracking plugin
205 */
206 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-blazing-shipment-tracking.php';
207
208 /**
209 * The class responsible for integrate the Mimo Shipment Tracking plugin
210 */
211 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-mimo-shipment-tracking.php';
212
213 /**
214 * The class responsible for integrate the Woo Orders Tracking plugin
215 */
216 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-woo-orders-tracking.php';
217
218 /**
219 * The class responsible for integrate the Woo Orders Tracking plugin
220 */
221 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-woocommerce-orders-tracking.php';
222
223
224 /**
225 * The class responsible for integrate the Aftership Shipment Tracking plugin
226 */
227 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-aftership-shipment-tracking.php';
228
229 /**
230 * The class responsible for integrate the YiTH WooCommerce Tracking Order plugin
231 */
232 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-yith-woocommerce-tracking-order.php';
233
234 /**
235 * The class responsible for integrate the Woocommerce Advanced Shipment Tracking plugin
236 */
237 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-astracker-shipment-tracking.php';
238
239 /**
240 * The class responsible for integrate the Shipping Details Tracking plugin
241 */
242 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-wooshippinginfo-tracking.php';
243
244 /**
245 * The class responsible for integrate the WooCommerce Shipment Tracking Pro plugin
246 */
247 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-woocommerce-shipment-tracking-pro.php';
248
249 /**
250 * The class responsible for integrate the Elex USPS Shipping plugin
251 */
252 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-usps-woocommerce-shipping.php';
253
254 /**
255 * The class responsible for integrate the Jetpack plugin
256 */
257 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-jetpack.php';
258
259 /**
260 * The class responsible for integrate the ShippingEasy plugin
261 */
262 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-shippingeasy.php';
263
264 /**
265 * The class responsible for integrate the ShippingEasy Custom plugin
266 */
267 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-shippingeasycustom.php';
268
269 /**
270 * The class responsible for integrate the ShipStation plugin
271 */
272 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-shipstation.php';
273
274 /**
275 * The class responsible for integrate the Shipworks plugin
276 */
277 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-shipworks.php';
278
279 /**
280 * The class responsible for integrate the Pirate Ship external provider
281 */
282 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-pirate-ship.php';
283
284 /**
285 * The class responsible for integrate the WooCommerce UPS Shipping Method plugin
286 */
287 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-ups-shipping.php';
288
289 /**
290 * The class responsible for defining Woocommerce cron jobs functionality
291 * of the plugin.
292 */
293 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-cron-schedules.php';
294
295 /**
296 * The class responsible for defining Woocommerce core functionality
297 * of the plugin.
298 */
299 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-woocommerce.php';
300
301 /**
302 * The class responsible for adding or removing Route Fee on Dashboard
303 * of the plugin.
304 */
305 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-admin-route-fee.php';
306
307 /**
308 * The class responsible for defining all actions that occur in the public-facing
309 * side of the site.
310 */
311 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-routeapp-public.php';
312
313 /**
314 * This class is responsible to create user and merchant account if it's not defined
315 */
316 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-setup.php';
317 Route_Setup::init_ownership_routing();
318
319 /**
320 * The class responsible for defining Woocommerce ajax functionality
321 * of the plugin.
322 */
323 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-routeapp-order-recover.php';
324
325 $this->loader = new Routeapp_Loader();
326
327 }
328
329 /**
330 * Define the locale for this plugin for internationalization.
331 *
332 * Uses the Routeapp_i18n class in order to set the domain and to register the hook
333 * with WordPress.
334 *
335 * @since 1.0.0
336 * @access private
337 */
338 private function set_locale() {
339
340 $plugin_i18n = new Routeapp_i18n();
341
342 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
343
344 }
345
346 /**
347 * Register all of the hooks related to the admin area functionality
348 * of the plugin.
349 *
350 * @since 1.0.0
351 * @access private
352 */
353 private function define_admin_hooks() {
354
355 $routeapp_admin = new Routeapp_Admin( $this->get_plugin_name(), $this->get_version() );
356
357 $this->loader->add_action( 'admin_enqueue_scripts', $routeapp_admin, 'enqueue_styles' );
358 $this->loader->add_action( 'admin_enqueue_scripts', $routeapp_admin, 'enqueue_scripts' );
359 $this->loader->add_action( 'admin_notices', $routeapp_admin, 'display_admin_notices' );
360
361 $classes = array(
362 'Routeapp_Notice',
363 );
364
365 foreach ($classes as $class) {
366 new $class();
367 }
368
369 }
370
371 /**
372 * Register all of the hooks related to the public-facing functionality
373 * of the plugin.
374 *
375 * @since 1.0.0
376 * @access private
377 */
378 private function define_public_hooks() {
379
380 global $routeapp_public;
381 $routeapp_public = new Routeapp_Public( $this->get_plugin_name(), $this->get_version() );
382 }
383
384 /**
385 * [routeapp_admin_notice__error description]
386 * @return [type] [description]
387 */
388 public function routeapp_admin_notice__error() {
389 $class = 'notice notice-error';
390 $message = __( 'Routeapp is enabled but not effective. It requires WooCommerce in order to work.', 'routeapp' );
391
392 printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
393 }
394
395 /**
396 * Register all of the hooks related to the includes facing funcionality
397 * of the plugin.
398 *
399 * @since 1.0.1
400 */
401 public function define_include_hooks() {
402 $classes = array(
403 'Routeapp_Woocommerce',
404 'Routeapp_Cron_Schedules',
405 'Routeapp_Plugin_Integrations',
406 'Routeapp_Order_Recover'
407 );
408
409 foreach ($classes as $class) {
410 new $class();
411 }
412 }
413
414 /**
415 * [routeapp_is_woocommerce_active description]
416 * @return [type] [description]
417 */
418 private function routeapp_is_woocommerce_active() {
419 return WC_GST_Dependencies::fn_woocommerce_active_check();
420 }
421
422 /**
423 * Run the loader to execute all of the hooks with WordPress.
424 *
425 * @since 1.0.0
426 */
427 public function run() {
428 $this->loader->run();
429 }
430
431 /**
432 * The name of the plugin used to uniquely identify it within the context of
433 * WordPress and to define internationalization functionality.
434 *
435 * @since 1.0.0
436 * @return string The name of the plugin.
437 */
438 public function get_plugin_name() {
439 return $this->plugin_name;
440 }
441
442 /**
443 * The reference to the class that orchestrates the hooks with the plugin.
444 *
445 * @since 1.0.0
446 * @return Routeapp_Loader Orchestrates the hooks of the plugin.
447 */
448 public function get_loader() {
449 return $this->loader;
450 }
451
452 /**
453 * Retrieve the version number of the plugin.
454 *
455 * @since 1.0.0
456 * @return string The version number of the plugin.
457 */
458 public function get_version() {
459 return $this->version;
460 }
461
462 }
463