PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v1.4.0
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 / includes / Installer.php

Installer.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.4.0, at includes/Installer.php

89 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SpringDevs\Subscription;
4
5 /**
6 * Class Installer
7 *
8 * @package SpringDevs\Subscription
9 */
10 class Installer {
11
12 /**
13 * Run the installer
14 *
15 * @return void
16 */
17 public function run() {
18 $this->add_version();
19 $this->register_schedules();
20 $this->create_tables();
21 }
22
23 /**
24 * Add time and version on DB
25 */
26 public function add_version() {
27 $installed = get_option( 'subscrpt_installed' );
28
29 if ( ! $installed ) {
30 update_option( 'subscrpt_installed', time() );
31 }
32
33 update_option( 'subscrpt_version', WP_SUBSCRIPTION_VERSION );
34
35 update_option( 'subscrpt_manual_renew_cart_notice', 'Subscriptional product added to cart. Please complete the checkout to renew subscription.' );
36 }
37
38 /**
39 * Register cron events.
40 *
41 * @return void
42 */
43 public function register_schedules() {
44 if ( ! wp_next_scheduled( 'subscrpt_daily_cron' ) ) {
45 wp_schedule_event( time(), 'daily', 'subscrpt_daily_cron' );
46 }
47
48 if ( ! wp_next_scheduled( 'subscrpt_renew_reminder_cron' ) ) {
49 wp_schedule_event( time(), 'daily', 'subscrpt_renew_reminder_cron' );
50 }
51 }
52
53 /**
54 * Create necessary database tables
55 *
56 * @return void
57 */
58 public function create_tables() {
59 if ( ! function_exists( 'dbDelta' ) ) {
60 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
61 }
62
63 $this->create_histories_table();
64 }
65
66 /**
67 * Create histories table
68 *
69 * @return void
70 */
71 public function create_histories_table() {
72 global $wpdb;
73
74 $charset_collate = $wpdb->get_charset_collate();
75 $table_name = $wpdb->prefix . 'subscrpt_order_relation';
76
77 $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
78 `id` INT(255) NOT NULL AUTO_INCREMENT,
79 `subscription_id` INT(100) NOT NULL,
80 `order_id` INT(100) NOT NULL,
81 `order_item_id` INT(100) NOT NULL,
82 `type` VARCHAR(50) NOT NULL,
83 PRIMARY KEY (`id`)
84 ) $charset_collate";
85
86 dbDelta( $schema );
87 }
88 }
89