-
Notifications
You must be signed in to change notification settings - Fork 1
/
ship-to-ecourier.php
162 lines (141 loc) · 4.14 KB
/
ship-to-ecourier.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php // phpcs:ignore
/**
* Plugin Name: Ship To eCourier
* Plugin URI: https://github.com/simongomes/ship-to-ecourier
* Description: Ship To eCourier gives you ability to send your parcel request to eCourier directly from your WooCommerce dashboard, it enables booking automation from your WordPress website.
* Author: Simon Gomes
* Author URI: https://simongomes.dev
* Text Domain: ship-to-ecourier
* Domain Path: /languages
* Version: 1.1.0
* License: GPLv3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*
* @package ShipToEcourier
*/
/**
* Copyright (c) 2021 Simon Gomes (email: busy.s.simon@gmail.com). All rights reserved.
*
* Released under the GPL license
* https://www.gnu.org/licenses/gpl-3.0.html
*
* This is an add-on for WordPress
* http://wordpress.org/
*
* **********************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* **********************************************************************
*/
use ShipToEcourier\Appsero_Tracker;
// Block direct access to the file.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
if ( ! class_exists( 'Ship_To_Ecourier' ) ) {
/**
* Register the main plugin class.
*
* Class Ship_To_Ecourier
*/
final class Ship_To_Ecourier {
/**
* Plugin version
*
* @var string
*/
const VERSION = '1.1.0';
/**
* Ship_To_Ecourier constructor.
*
* @return void
*/
public function __construct() {
$this->define_constants();
register_activation_hook( __FILE__, array( $this, 'activate' ) );
add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
}
/**
* Initialize a singleton instance.
*
* @return \Ship_To_Ecourier
*/
public static function init() {
$instance = false;
if ( ! $instance ) {
$instance = new self();
}
return $instance;
}
/**
* Defines all necessary constants for the plugin.
*
* @return void
*/
public function define_constants() {
define( 'STE_VERSION', self::VERSION );
define( 'STE_FILE', __FILE__ );
define( 'STE_PATH', __DIR__ );
define( 'STE_URL', plugins_url( '', STE_FILE ) );
define( 'STE_ASSETS_URL', STE_URL . '/assets' );
define( 'STE_TABLE_PREFIX', 'ste_' );
define( 'STE_API_BASE_URL_STAGING', 'https://staging.ecourier.com.bd/api' );
define( 'STE_API_BASE_URL_LIVE', 'https://backoffice.ecourier.com.bd/api' );
}
/**
* Load plugin classes and initialize assets.
*
* @return void
*/
public function init_plugin() {
// Initialize the Appsero tracker for plugin analytics.
Appsero_Tracker::init_tracker();
// Call Assets class to load necessary assets for plugin ( JavaScript and CSS ).
new ShipToEcourier\Assets();
// Load Ajax request handler.
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
new ShipToEcourier\Ajax();
}
if ( is_admin() ) {
// Load admin classes.
new ShipToEcourier\Admin();
} else {
// Load Frontend classes.
new ShipToEcourier\Frontend();
}
}
/**
* Necessary setup on plugin activation.
*
* @return void
*/
public function activate() {
$installer = new ShipToEcourier\Installer();
$installer->run();
}
}
}
/**
* Initialize the main plugin.
*
* @return \Ship_To_Ecourier|bool
*/
function ship_to_ecourier() {
return Ship_To_Ecourier::init();
}
// Kick-off the plugin.
ship_to_ecourier();