PluginProbe
Trakoo – Orders Tracking for WooCommerce / trunk
Trakoo – Orders Tracking for WooCommerce vtrunk
trunk 1.1.10 1.1.14 1.1.16 1.1.8.7 1.2.0
woo-orders-tracking / woo-orders-tracking.php

woo-orders-tracking.php in Trakoo – Orders Tracking for WooCommerce trunk, at woo-orders-tracking.php

138 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Trakoo - Orders Tracking for WooCommerce
4 * Plugin URI: https://villatheme.com/extensions/woocommerce-orders-tracking
5 * Description: Easily import/manage your tracking numbers, add tracking numbers to PayPal and send email notifications to customers.
6 * Version: 1.3.2
7 * Author: VillaTheme
8 * Author URI: https://villatheme.com
9 * License: GPL v2 or later
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: woo-orders-tracking
12 * Domain Path: /languages
13 * Copyright 2019-2026 VillaTheme.com. All rights reserved.
14 * Requires Plugins: woocommerce
15 * Tested up to: 7.1
16 * WC tested up to: 11.0
17 * Requires PHP: 7.0
18 **/
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit;
21 }
22 define( 'VI_WOO_ORDERS_TRACKING_VERSION', '1.3.2' );
23 define( 'VI_WOO_ORDERS_TRACKING_PATH_FILE', __FILE__ );
24 define( 'VI_WOO_ORDERS_TRACKING_DIR', WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'woo-orders-tracking' . DIRECTORY_SEPARATOR );
25 define( 'VI_WOO_ORDERS_TRACKING_INCLUDES', VI_WOO_ORDERS_TRACKING_DIR . 'includes' . DIRECTORY_SEPARATOR );
26 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
27 /*Required for register_activation_hook*/
28 if ( is_file( VI_WOO_ORDERS_TRACKING_INCLUDES . 'functions.php' ) ) {
29 require_once VI_WOO_ORDERS_TRACKING_INCLUDES . 'functions.php';
30 }
31 if ( is_file( VI_WOO_ORDERS_TRACKING_INCLUDES . 'data.php' ) ) {
32 require_once VI_WOO_ORDERS_TRACKING_INCLUDES . 'data.php';
33 }
34 if ( is_file( VI_WOO_ORDERS_TRACKING_INCLUDES . 'class-vi-woo-orders-tracking-trackingmore-table.php' ) ) {
35 require_once VI_WOO_ORDERS_TRACKING_INCLUDES . 'class-vi-woo-orders-tracking-trackingmore-table.php';
36 }
37
38 if ( is_file( VI_WOO_ORDERS_TRACKING_INCLUDES . 'class-vi-woo-orders-tracking-track-info-table.php' ) ) {
39 require_once VI_WOO_ORDERS_TRACKING_INCLUDES . 'class-vi-woo-orders-tracking-track-info-table.php';
40 }
41
42 if ( ! class_exists( 'VIWOT_WOO_ORDERS_TRACKING' ) ) {
43 class VIWOT_WOO_ORDERS_TRACKING {
44 protected $settings;
45
46 public function __construct() {
47 //compatible with 'High-Performance order storage (COT)'
48 add_action( 'before_woocommerce_init', array( $this, 'before_woocommerce_init' ) );
49 if ( is_plugin_active( 'woocommerce-orders-tracking/woocommerce-orders-tracking.php' ) ) {
50 return;
51 }
52 add_action( 'plugins_loaded', array( $this, 'init' ) );
53 add_action( 'activated_plugin', array( $this, 'install' ), 10, 2 );
54 }
55
56 public function init() {
57 $include_dir = plugin_dir_path( __FILE__ ) . 'includes/';
58 if ( ! class_exists( 'VillaTheme_Require_Environment' ) ) {
59 include_once $include_dir . 'support.php';
60 }
61
62 $environment = new VillaTheme_Require_Environment( [
63 'plugin_name' => 'Trakoo - Orders Tracking for WooCommerce',
64 'php_version' => '7.0',
65 'wp_version' => '5.0',
66 'require_plugins' => [
67 [
68 'slug' => 'woocommerce',
69 'name' => 'WooCommerce',
70 'defined_version' => 'WC_VERSION',
71 'version' => '7.0',
72 ]
73 ]
74 ]
75 );
76
77 if ( $environment->has_error() ) {
78 return;
79 }
80
81 $init_file = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . "woo-orders-tracking" . DIRECTORY_SEPARATOR . "includes" . DIRECTORY_SEPARATOR . "define.php";
82 require_once $init_file;
83 }
84
85 public function before_woocommerce_init() {
86 if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
87 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
88 }
89 }
90
91 public static function install( $plugin, $network_wide ) {
92 if ( $plugin !== plugin_basename( __FILE__ ) ) {
93 return;
94 }
95 /*Create custom table to store tracking data*/
96 global $wpdb;
97 if ( function_exists( 'is_multisite' ) && is_multisite() && $network_wide ) {
98 $current_blog = $wpdb->blogid;
99 $blogs = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery , WordPress.DB.DirectDatabaseQuery.NoCaching
100
101 //Multi site activate action
102 foreach ( $blogs as $blog ) {
103 switch_to_blog( $blog );
104 /*Create custom table to store tracking data*/
105 VI_WOO_ORDERS_TRACKING_TRACKINGMORE_TABLE::create_table();
106 VI_WOO_ORDERS_TRACKING_TRACK_INFO_TABLE::maybe_create_table();
107 }
108 switch_to_blog( $current_blog );
109 } else {
110 //Single site activate action
111 /*Create custom table to store tracking data*/
112 VI_WOO_ORDERS_TRACKING_TRACKINGMORE_TABLE::create_table();
113 VI_WOO_ORDERS_TRACKING_TRACK_INFO_TABLE::maybe_create_table();
114 }
115 /*create tracking page*/
116 if ( ! get_option( 'woo_orders_tracking_settings' ) ) {
117 $current_user = wp_get_current_user();
118 // create post object
119 $page = array(
120 'post_title' => esc_html__( 'Orders Tracking', 'woo-orders-tracking' ),
121 'post_status' => 'publish',
122 'post_author' => $current_user->ID,
123 'post_type' => 'page',
124 'post_name' => 'orders-tracking',
125 );
126 // insert the post into the database
127 $page_id = wp_insert_post( $page, true );
128 if ( ! is_wp_error( $page_id ) ) {
129 $settings = VI_WOO_ORDERS_TRACKING_DATA::get_instance();
130 $args = $settings->get_params();
131 $args['service_tracking_page'] = $page_id;
132 update_option( 'woo_orders_tracking_settings', $args );
133 }
134 }
135 }
136 }
137 }
138 new VIWOT_WOO_ORDERS_TRACKING();