PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.9.6
Subscriptions for WooCommerce with Stripe Recurring Payments v1.9.6
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.9.6, at includes/Installer.php

85 lines 1.8 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', SUBSCRPT_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_hourly_cron' ) ) {
45 wp_schedule_event( strtotime( 'tomorrow midnight' ), 'hourly', 'subscrpt_hourly_cron' );
46 }
47 }
48
49 /**
50 * Create necessary database tables
51 *
52 * @return void
53 */
54 public function create_tables() {
55 if ( ! function_exists( 'dbDelta' ) ) {
56 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
57 }
58
59 $this->create_histories_table();
60 }
61
62 /**
63 * Create histories table
64 *
65 * @return void
66 */
67 public function create_histories_table() {
68 global $wpdb;
69
70 $charset_collate = $wpdb->get_charset_collate();
71 $table_name = $wpdb->prefix . 'subscrpt_order_relation';
72
73 $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
74 `id` INT(255) NOT NULL AUTO_INCREMENT,
75 `subscription_id` INT(100) NOT NULL,
76 `order_id` INT(100) NOT NULL,
77 `order_item_id` INT(100) NOT NULL,
78 `type` VARCHAR(50) NOT NULL,
79 PRIMARY KEY (`id`)
80 ) $charset_collate";
81
82 dbDelta( $schema );
83 }
84 }
85