PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 0.0.1
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v0.0.1
1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
suredonation / inc / database / register.php

register.php in SureDonation – Donation Forms, Fundraising Campaigns & Donor Management 0.0.1, at inc/database/register.php

61 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * SureDonation Database Tables Register Class.
4 *
5 * @package SureDonation
6 */
7
8 namespace SureDonation\Inc\Database;
9
10 use SureDonation\Inc\Database\Tables\Donations;
11 use SureDonation\Inc\Database\Tables\Donors;
12
13 // Exit if accessed directly.
14 defined( 'ABSPATH' ) || exit;
15
16 /**
17 * SureDonation Database Tables Register Class
18 *
19 * @since 0.0.1
20 */
21 class Register {
22 /**
23 * Init database registration.
24 *
25 * @return void
26 * @since 0.0.1
27 */
28 public static function init() {
29 /*
30 * ### Here, order is important. ###
31 * 1. Start the DB upgrade which also manages the internal versioning of each tables.
32 * 2. Init create method, which create the table if the table does not exists.
33 * 3. Finally, stop the DB upgrade and update the current version in option table.
34 */
35 foreach ( static::get_db_tables() as $instance ) {
36 $instance->start_db_upgrade();
37
38 if ( $instance->is_db_upgradable() ) {
39 // Only execute below methods if DB is upgradable.
40 $instance->create( $instance->get_columns_definition() );
41 }
42
43 // Stop the upgrade process of current table and move to next.
44 $instance->stop_db_upgrade();
45 }
46 }
47
48 /**
49 * Returns an array of instances/objects of our custom tables.
50 *
51 * @return array<string,\SureDonation\Inc\Database\Base>
52 * @since 0.0.1
53 */
54 public static function get_db_tables() {
55 return [
56 'donations' => Donations::get_instance(),
57 'donors' => Donors::get_instance(),
58 ];
59 }
60 }
61