PluginProbe
Send Users Email – Email Subscribers, Email Marketing Newsletter / trunk
Send Users Email – Email Subscribers, Email Marketing Newsletter vtrunk
2.0.3 2.0.2 2.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 All 51 releases
send-users-email / includes / class-external-list-schema.php

class-external-list-schema.php in Send Users Email – Email Subscribers, Email Marketing Newsletter trunk, at includes/class-external-list-schema.php

107 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Summary of External_Lists_Schema
4 * Use this class to create database tables for External Lists feature.
5 */
6 class External_Lists_Schema
7 {
8 /**
9 * Summary of init
10 * Initializes the database schema for external lists.
11 * @return void
12 */
13 public static function init()
14 {
15 // Initialization code if needed
16 self::create_table_external_list();
17 self::create_table_external_list_meta();
18 }
19
20 /**
21 * Summary of get_external_list_table_name
22 * Get the name of the external list table.
23 * @return string
24 */
25 public static function get_external_list_table_name()
26 {
27 global $wpdb;
28 return $wpdb->prefix . 'sue_external_lists';
29 }
30
31 /**
32 * Summary of get_external_list_meta_table_name
33 * Get the name of the external list meta table.
34 * @return string
35 */
36 public static function get_external_list_meta_table_name()
37 {
38 global $wpdb;
39 return $wpdb->prefix . 'sue_external_list_meta';
40 }
41
42 /**
43 * Summary of create_table_external_list
44 * Creates the database table for storing external list entries.
45 * @return void
46 */
47 private static function create_table_external_list()
48 {
49 global $wpdb;
50 $table_name = self::get_external_list_table_name();
51
52 $charset_collate = $wpdb->get_charset_collate();
53
54 // Table for CSV rows
55 $sql_rows = "CREATE TABLE $table_name (
56 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
57 list_id VARCHAR(50) NOT NULL,
58 user_id BIGINT UNSIGNED NOT NULL,
59 email VARCHAR(255) NOT NULL,
60 first_name VARCHAR(100) DEFAULT '',
61 last_name VARCHAR(100) DEFAULT '',
62 title VARCHAR(100) DEFAULT '',
63 salutation VARCHAR(50) DEFAULT '',
64 field_01 VARCHAR(255) DEFAULT '',
65 field_02 VARCHAR(255) DEFAULT '',
66 field_03 VARCHAR(255) DEFAULT '',
67 field_04 VARCHAR(255) DEFAULT '',
68 field_05 VARCHAR(255) DEFAULT '',
69 subscribed TINYINT(1) DEFAULT 1,
70 created_at DATETIME NOT NULL,
71 PRIMARY KEY (id),
72 KEY email (email),
73 KEY list_id (list_id)
74 ) $charset_collate;";
75
76 dbDelta($sql_rows);
77 }
78
79 /**
80 * Summary of create_table_external_list_meta
81 * Create table for the list_meta.
82 * @return void
83 */
84 private static function create_table_external_list_meta()
85 {
86 global $wpdb;
87 $table_name = self::get_external_list_meta_table_name();
88
89 $charset_collate = $wpdb->get_charset_collate();
90
91 // Table for CSV metadata
92
93 $sql_meta = "CREATE TABLE $table_name (
94 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
95 list_id VARCHAR(50) NOT NULL,
96 list_name VARCHAR(255) NOT NULL,
97 user_id BIGINT UNSIGNED NOT NULL,
98 created_at DATETIME NOT NULL,
99 count INT UNSIGNED DEFAULT 0,
100 PRIMARY KEY (id),
101 KEY list_id (list_id)
102 ) $charset_collate;";
103
104
105 dbDelta($sql_meta);
106 }
107 }