PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.2.2
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.2.2
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 All 66 releases
better-payment / includes / Installer.php

Installer.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.2.2, at includes/Installer.php

88 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite;
4
5 /**
6 * Exit if accessed directly
7 */
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 /**
13 * Installer class
14 *
15 * @since 0.0.1
16 */
17
18 class Installer extends Controller {
19
20 /**
21 * Run the installer
22 *
23 * @return void
24 * @since 0.0.1
25 */
26 public function run() {
27 $this->create_tables();
28 self::enable_setup_wizard();
29 }
30
31 /**
32 * Table creation schema
33 *
34 * @since 0.0.1
35 */
36 private function get_schema() {
37 global $wpdb;
38 return [
39 "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}better_payment(
40 id bigint(20) NOT NULL AUTO_INCREMENT,
41 order_id varchar(50) NOT NULL,
42 transaction_id varchar(50) DEFAULT '',
43 amount decimal(10,2) NOT NULL,
44 status varchar(50) DEFAULT NULL,
45 source varchar(50) NOT NULL,
46 payment_date datetime DEFAULT NULL,
47 email varchar(50) NOT NULL DEFAULT '',
48 customer_info longtext,
49 form_fields_info longtext,
50 currency varchar(11) NOT NULL DEFAULT '',
51 referer varchar(64) DEFAULT NULL,
52 obj_id text,
53 PRIMARY KEY (id),
54 KEY order_id (order_id),
55 KEY status (status)
56 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ",
57 ];
58 }
59
60 /**
61 * Create necessary database tables
62 *
63 * @return void
64 * @since 0.0.1
65 */
66 public function create_tables() {
67 global $wpdb;
68 $wpdb->hide_errors();
69 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
70 $tables = $this->get_schema();
71 foreach ( $tables as $table ) {
72 dbDelta( $table );
73 }
74 }
75
76 /**
77 * Save setup wizard data
78 *
79 * @since 0.0.2
80 */
81 public function enable_setup_wizard()
82 {
83 if ( !get_option( 'better_payment_setup_wizard' ) ) {
84 update_option( 'better_payment_setup_wizard', 'redirect' );
85 }
86 }
87 }
88