PluginProbe
Route ‑ Shipping Protection / 2.3.3
Route ‑ Shipping Protection v2.3.3
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.3.3, at includes/class-routeapp.php

452 lines 14.5 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 defining Woocommerce cron jobs functionality
281 * of the plugin.
282 */
283 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-cron-schedules.php';
284
285 /**
286 * The class responsible for defining Woocommerce core functionality
287 * of the plugin.
288 */
289 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-woocommerce.php';
290
291 /**
292 * The class responsible for adding or removing Route Fee on Dashboard
293 * of the plugin.
294 */
295 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-admin-route-fee.php';
296
297 /**
298 * The class responsible for defining all actions that occur in the public-facing
299 * side of the site.
300 */
301 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-routeapp-public.php';
302
303 /**
304 * This class is responsible to create user and merchant account if it's not defined
305 */
306 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-setup.php';
307
308 /**
309 * The class responsible for defining Woocommerce ajax functionality
310 * of the plugin.
311 */
312 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-routeapp-order-recover.php';
313
314 $this->loader = new Routeapp_Loader();
315
316 }
317
318 /**
319 * Define the locale for this plugin for internationalization.
320 *
321 * Uses the Routeapp_i18n class in order to set the domain and to register the hook
322 * with WordPress.
323 *
324 * @since 1.0.0
325 * @access private
326 */
327 private function set_locale() {
328
329 $plugin_i18n = new Routeapp_i18n();
330
331 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
332
333 }
334
335 /**
336 * Register all of the hooks related to the admin area functionality
337 * of the plugin.
338 *
339 * @since 1.0.0
340 * @access private
341 */
342 private function define_admin_hooks() {
343
344 $routeapp_admin = new Routeapp_Admin( $this->get_plugin_name(), $this->get_version() );
345
346 $this->loader->add_action( 'admin_enqueue_scripts', $routeapp_admin, 'enqueue_styles' );
347 $this->loader->add_action( 'admin_enqueue_scripts', $routeapp_admin, 'enqueue_scripts' );
348 $this->loader->add_action( 'admin_notices', $routeapp_admin, 'display_admin_notices' );
349
350 $classes = array(
351 'Routeapp_Notice',
352 );
353
354 foreach ($classes as $class) {
355 new $class();
356 }
357
358 }
359
360 /**
361 * Register all of the hooks related to the public-facing functionality
362 * of the plugin.
363 *
364 * @since 1.0.0
365 * @access private
366 */
367 private function define_public_hooks() {
368
369 global $routeapp_public;
370 $routeapp_public = new Routeapp_Public( $this->get_plugin_name(), $this->get_version() );
371 }
372
373 /**
374 * [routeapp_admin_notice__error description]
375 * @return [type] [description]
376 */
377 public function routeapp_admin_notice__error() {
378 $class = 'notice notice-error';
379 $message = __( 'Routeapp is enabled but not effective. It requires WooCommerce in order to work.', 'routeapp' );
380
381 printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
382 }
383
384 /**
385 * Register all of the hooks related to the includes facing funcionality
386 * of the plugin.
387 *
388 * @since 1.0.1
389 */
390 public function define_include_hooks() {
391 $classes = array(
392 'Routeapp_Woocommerce',
393 'Routeapp_Cron_Schedules',
394 'Routeapp_Plugin_Integrations',
395 'Routeapp_Order_Recover'
396 );
397
398 foreach ($classes as $class) {
399 new $class();
400 }
401 }
402
403 /**
404 * [routeapp_is_woocommerce_active description]
405 * @return [type] [description]
406 */
407 private function routeapp_is_woocommerce_active() {
408 return WC_GST_Dependencies::fn_woocommerce_active_check();
409 }
410
411 /**
412 * Run the loader to execute all of the hooks with WordPress.
413 *
414 * @since 1.0.0
415 */
416 public function run() {
417 $this->loader->run();
418 }
419
420 /**
421 * The name of the plugin used to uniquely identify it within the context of
422 * WordPress and to define internationalization functionality.
423 *
424 * @since 1.0.0
425 * @return string The name of the plugin.
426 */
427 public function get_plugin_name() {
428 return $this->plugin_name;
429 }
430
431 /**
432 * The reference to the class that orchestrates the hooks with the plugin.
433 *
434 * @since 1.0.0
435 * @return Routeapp_Loader Orchestrates the hooks of the plugin.
436 */
437 public function get_loader() {
438 return $this->loader;
439 }
440
441 /**
442 * Retrieve the version number of the plugin.
443 *
444 * @since 1.0.0
445 * @return string The version number of the plugin.
446 */
447 public function get_version() {
448 return $this->version;
449 }
450
451 }
452