LegalConsents.php
62 lines
| 1 | <?php |
| 2 | /** |
| 3 | * GDPR legal consents table. |
| 4 | * |
| 5 | * @package Tutor\GDPR\DB |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 4.0.0 |
| 9 | */ |
| 10 | |
| 11 | namespace Tutor\GDPR\DB; |
| 12 | |
| 13 | defined( 'ABSPATH' ) || exit; |
| 14 | |
| 15 | /** |
| 16 | * Legal consents table class. |
| 17 | */ |
| 18 | class LegalConsents extends DB { |
| 19 | |
| 20 | /** |
| 21 | * Get table name. |
| 22 | * |
| 23 | * @since 4.0.0 |
| 24 | * |
| 25 | * @return string |
| 26 | */ |
| 27 | public static function get_table_name() { |
| 28 | global $wpdb; |
| 29 | return $wpdb->prefix . 'tutor_legal_consents'; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get create table schema. |
| 34 | * |
| 35 | * @since 4.0.0 |
| 36 | * |
| 37 | * @return string |
| 38 | */ |
| 39 | public static function get_schema() { |
| 40 | global $wpdb; |
| 41 | |
| 42 | $table_name = static::get_table_name(); |
| 43 | $charset_collate = $wpdb->get_charset_collate(); |
| 44 | |
| 45 | return "CREATE TABLE {$table_name} ( |
| 46 | id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, |
| 47 | consent_title VARCHAR(255) NOT NULL, |
| 48 | display_on TEXT NOT NULL, -- comma separate value for multiple scopes |
| 49 | consent_message TEXT NOT NULL, |
| 50 | consent_map JSON, -- JSON map [terms_conditions => 1] |
| 51 | version VARCHAR(20) NOT NULL, |
| 52 | consent_method VARCHAR(255) NOT NULL, |
| 53 | is_active TINYINT(1) DEFAULT 1, |
| 54 | settings JSON, |
| 55 | created_at_gmt DATETIME NOT NULL, |
| 56 | updated_at_gmt DATETIME, |
| 57 | INDEX (consent_title), |
| 58 | INDEX (is_active) |
| 59 | ) {$charset_collate};"; |
| 60 | } |
| 61 | } |
| 62 |