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

439 lines 14.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 Aftership Shipment Tracking plugin
220 */
221 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-aftership-shipment-tracking.php';
222
223 /**
224 * The class responsible for integrate the YiTH WooCommerce Tracking Order plugin
225 */
226 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-yith-woocommerce-tracking-order.php';
227
228 /**
229 * The class responsible for integrate the Woocommerce Advanced Shipment Tracking plugin
230 */
231 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-astracker-shipment-tracking.php';
232
233 /**
234 * The class responsible for integrate the Shipping Details Tracking plugin
235 */
236 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-wooshippinginfo-tracking.php';
237
238 /**
239 * The class responsible for integrate the WooCommerce Shipment Tracking Pro plugin
240 */
241 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-woocommerce-shipment-tracking-pro.php';
242
243 /**
244 * The class responsible for integrate the Elex USPS Shipping plugin
245 */
246 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-usps-woocommerce-shipping.php';
247
248 /**
249 * The class responsible for integrate the Jetpack plugin
250 */
251 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-jetpack.php';
252
253 /**
254 * The class responsible for integrate the ShippingEasy plugin
255 */
256 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-shippingeasy.php';
257
258 /**
259 * The class responsible for integrate the ShippingEasy Custom plugin
260 */
261 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-shippingeasycustom.php';
262
263 /**
264 * The class responsible for integrate the ShipStation plugin
265 */
266 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-shipstation.php';
267
268 /**
269 * The class responsible for integrate the Shipworks plugin
270 */
271 require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/tracking-providers/class-routeapp-shipworks.php';
272
273 /**
274 * The class responsible for defining Woocommerce cron jobs functionality
275 * of the plugin.
276 */
277 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-cron-schedules.php';
278
279 /**
280 * The class responsible for defining Woocommerce core functionality
281 * of the plugin.
282 */
283 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-woocommerce.php';
284
285 /**
286 * The class responsible for adding or removing Route Fee on Dashboard
287 * of the plugin.
288 */
289 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-admin-route-fee.php';
290
291 /**
292 * The class responsible for defining all actions that occur in the public-facing
293 * side of the site.
294 */
295 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-routeapp-public.php';
296
297 /**
298 * This class is responsible to create user and merchant account if it's not defined
299 */
300 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-routeapp-setup.php';
301
302 $this->loader = new Routeapp_Loader();
303
304 }
305
306 /**
307 * Define the locale for this plugin for internationalization.
308 *
309 * Uses the Routeapp_i18n class in order to set the domain and to register the hook
310 * with WordPress.
311 *
312 * @since 1.0.0
313 * @access private
314 */
315 private function set_locale() {
316
317 $plugin_i18n = new Routeapp_i18n();
318
319 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
320
321 }
322
323 /**
324 * Register all of the hooks related to the admin area functionality
325 * of the plugin.
326 *
327 * @since 1.0.0
328 * @access private
329 */
330 private function define_admin_hooks() {
331
332 $routeapp_admin = new Routeapp_Admin( $this->get_plugin_name(), $this->get_version() );
333
334 $this->loader->add_action( 'admin_enqueue_scripts', $routeapp_admin, 'enqueue_styles' );
335 $this->loader->add_action( 'admin_enqueue_scripts', $routeapp_admin, 'enqueue_scripts' );
336 $this->loader->add_action( 'admin_notices', $routeapp_admin, 'display_admin_notices' );
337
338 $classes = array(
339 'Routeapp_Notice',
340 );
341
342 foreach ($classes as $class) {
343 new $class();
344 }
345
346 }
347
348 /**
349 * Register all of the hooks related to the public-facing functionality
350 * of the plugin.
351 *
352 * @since 1.0.0
353 * @access private
354 */
355 private function define_public_hooks() {
356
357 global $routeapp_public;
358 $routeapp_public = new Routeapp_Public( $this->get_plugin_name(), $this->get_version() );
359 }
360
361 /**
362 * [routeapp_admin_notice__error description]
363 * @return [type] [description]
364 */
365 public function routeapp_admin_notice__error() {
366 $class = 'notice notice-error';
367 $message = __( 'Routeapp is enabled but not effective. It requires WooCommerce in order to work.', 'routeapp' );
368
369 printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
370 }
371
372 /**
373 * Register all of the hooks related to the includes facing funcionality
374 * of the plugin.
375 *
376 * @since 1.0.1
377 */
378 public function define_include_hooks() {
379 $classes = array(
380 'Routeapp_Woocommerce',
381 'Routeapp_Cron_Schedules',
382 'Routeapp_Plugin_Integrations'
383 );
384
385 foreach ($classes as $class) {
386 new $class();
387 }
388 }
389
390 /**
391 * [routeapp_is_woocommerce_active description]
392 * @return [type] [description]
393 */
394 private function routeapp_is_woocommerce_active() {
395 return WC_GST_Dependencies::fn_woocommerce_active_check();
396 }
397
398 /**
399 * Run the loader to execute all of the hooks with WordPress.
400 *
401 * @since 1.0.0
402 */
403 public function run() {
404 $this->loader->run();
405 }
406
407 /**
408 * The name of the plugin used to uniquely identify it within the context of
409 * WordPress and to define internationalization functionality.
410 *
411 * @since 1.0.0
412 * @return string The name of the plugin.
413 */
414 public function get_plugin_name() {
415 return $this->plugin_name;
416 }
417
418 /**
419 * The reference to the class that orchestrates the hooks with the plugin.
420 *
421 * @since 1.0.0
422 * @return Routeapp_Loader Orchestrates the hooks of the plugin.
423 */
424 public function get_loader() {
425 return $this->loader;
426 }
427
428 /**
429 * Retrieve the version number of the plugin.
430 *
431 * @since 1.0.0
432 * @return string The version number of the plugin.
433 */
434 public function get_version() {
435 return $this->version;
436 }
437
438 }
439