PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.3.1
Subscriptions for WooCommerce with Stripe Recurring Payments v1.3.1
2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / subscription.php

subscription.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.3.1, at subscription.php

250 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Subscription for WooCommerce
4 Plugin URI: https://wordpress.org/plugins/subscription
5 Description: Enable WooCommerce Subscriptions and Start Recurring Revenue in Minutes.
6 Plugin URI: https://wpsubscription.co/
7
8 Author: shamsbd71
9 Author URI: https://wpsubscription.co/
10
11 Version: 1.3.1
12 Requires Plugins: woocommerce
13 License: GPLv2
14 License URI: https://www.gnu.org/licenses/gpl-2.0.html
15 Text Domain: sdevs_subscrpt
16 Domain Path: /languages
17 */
18
19 // don't call the file directly.
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 require_once __DIR__ . '/vendor/autoload.php';
25
26 /**
27 * Sdevs_Subscription class
28 *
29 * @class Sdevs_Subscription The class that holds the entire plugin
30 */
31 final class Sdevs_Subscription {
32
33
34 /**
35 * Plugin version
36 *
37 * @var string
38 */
39 const version = '1.3.1';
40
41 /**
42 * Holds various class instances
43 *
44 * @var array
45 */
46 private $container = array();
47
48 /**
49 * Constructor for the Sdevs_Wc_Subscription class
50 *
51 * Sets up all the appropriate hooks and actions
52 * within our plugin.
53 */
54 private function __construct() {
55 $this->define_constants();
56
57 register_activation_hook( __FILE__, array( $this, 'activate' ) );
58 register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
59
60 add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
61 }
62
63 /**
64 * Initializes the Sdevs_Wc_Subscription() class
65 *
66 * Checks for an existing Sdevs_Wc_Subscription() instance
67 * and if it doesn't find one, creates it.
68 *
69 * @return Sdevs_Subscription|bool
70 */
71 public static function init() {
72 static $instance = false;
73
74 if ( ! $instance ) {
75 $instance = new Sdevs_Subscription();
76 }
77
78 return $instance;
79 }
80
81 /**
82 * Magic getter to bypass referencing plugin.
83 *
84 * @param mixed $prop Prop.
85 *
86 * @return mixed
87 */
88 public function __get( $prop ) {
89 if ( array_key_exists( $prop, $this->container ) ) {
90 return $this->container[ $prop ];
91 }
92
93 return $this->{$prop};
94 }
95
96 /**
97 * Magic isset to bypass referencing plugin.
98 *
99 * @param mixed $prop Prop.
100 *
101 * @return bool
102 */
103 public function __isset( $prop ) {
104 return isset( $this->{$prop} ) || isset( $this->container[ $prop ] );
105 }
106
107 /**
108 * Define the constants
109 *
110 * @return void
111 */
112 public function define_constants() {
113 define( 'SUBSCRPT_VERSION', self::version );
114 define( 'SUBSCRPT_FILE', __FILE__ );
115 define( 'SUBSCRPT_PATH', dirname( SUBSCRPT_FILE ) );
116 define( 'SUBSCRPT_INCLUDES', SUBSCRPT_PATH . '/includes' );
117 define( 'SUBSCRPT_TEMPLATES', SUBSCRPT_PATH . '/templates/' );
118 define( 'SUBSCRPT_URL', plugins_url( '', SUBSCRPT_FILE ) );
119 define( 'SUBSCRPT_ASSETS', SUBSCRPT_URL . '/assets' );
120 }
121
122 /**
123 * Load the plugin after all plugins are loaded
124 *
125 * @return void
126 */
127 public function init_plugin() {
128 $this->includes();
129 $this->init_hooks();
130 }
131
132 /**
133 * Placeholder for activation function
134 */
135 public function activate() {
136 $installer = new SpringDevs\Subscription\Installer();
137 $installer->run();
138 }
139
140 /**
141 * Placeholder for deactivation function
142 *
143 * Nothing being called here yet.
144 */
145 public function deactivate() {
146 wp_clear_scheduled_hook( 'subscrpt_daily_cron' );
147 }
148
149 /**
150 * Include the required files
151 *
152 * @return void
153 */
154 public function includes() {
155 if ( $this->is_request( 'admin' ) ) {
156 $this->container['admin'] = new SpringDevs\Subscription\Admin();
157 }
158
159 if ( $this->is_request( 'frontend' ) ) {
160 $this->container['frontend'] = new SpringDevs\Subscription\Frontend();
161 }
162
163 $this->container['illuminate'] = new SpringDevs\Subscription\Illuminate();
164 }
165
166 /**
167 * Initialize the hooks
168 *
169 * @return void
170 */
171 public function init_hooks() {
172 add_action( 'init', array( $this, 'init_classes' ) );
173 add_action( 'init', array( $this, 'localization_setup' ) );
174 add_action( 'init', array( $this, 'run_update' ) );
175 }
176
177 /**
178 * Need to do some actions after update plugin
179 *
180 * @return void
181 */
182 public function run_update() {
183 $upgrade = new \SpringDevs\Subscription\Upgrade();
184 $upgrade->run();
185 }
186
187 /**
188 * Instantiate the required classes
189 *
190 * @return void
191 */
192 public function init_classes() {
193 if ( $this->is_request( 'ajax' ) ) {
194 $this->container['ajax'] = new SpringDevs\Subscription\Ajax();
195 }
196
197 $this->container['api'] = new SpringDevs\Subscription\Api();
198 $this->container['assets'] = new SpringDevs\Subscription\Assets();
199 }
200
201 /**
202 * Initialize plugin for localization
203 *
204 * @uses load_plugin_textdomain()
205 */
206 public function localization_setup() {
207 load_plugin_textdomain( 'sdevs_subscrpt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
208 }
209
210 /**
211 * What type of request is this?
212 *
213 * @param string $type admin, ajax, cron or frontend.
214 *
215 * @return bool
216 */
217 private function is_request( $type ) {
218 switch ( $type ) {
219 case 'admin':
220 return is_admin();
221
222 case 'ajax':
223 return defined( 'DOING_AJAX' );
224
225 case 'rest':
226 return defined( 'REST_REQUEST' );
227
228 case 'cron':
229 return defined( 'DOING_CRON' );
230
231 case 'frontend':
232 return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
233 }
234 }
235 } // Sdevs_Wc_Subscription
236
237 /**
238 * Initialize the main plugin
239 *
240 * @return Sdevs_Subscription|bool
241 */
242 function sdevs_subscription() {
243 return Sdevs_Subscription::init();
244 }
245
246 /**
247 * Kick-off the plugin
248 */
249 sdevs_subscription();
250