| 1 |
<?php |
| 2 |
|
| 3 |
namespace forge12\contactform7\CF7DoubleOptIn; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* Create the table to store the opt ins. |
| 11 |
* |
| 12 |
* @return void |
| 13 |
*/ |
| 14 |
function createTableOptIn() { |
| 15 |
global $wpdb; |
| 16 |
|
| 17 |
$tableName = 'f12_cf7_doubleoptin'; |
| 18 |
$wpTableName = $wpdb->prefix . $tableName; |
| 19 |
|
| 20 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 21 |
|
| 22 |
$sql = "CREATE TABLE " . $wpTableName . " ( |
| 23 |
id int(11) NOT NULL auto_increment, |
| 24 |
cf_form_id int(11) NOT NULL, |
| 25 |
doubleoptin int(2), |
| 26 |
content LONGTEXT, |
| 27 |
files LONGTEXT, |
| 28 |
hash VARCHAR(255), |
| 29 |
ipaddr_register varchar(255) NOT NULL DEFAULT '', |
| 30 |
ipaddr_confirmation varchar(255) NOT NULL DEFAULT '', |
| 31 |
ipaddr_optout varchar(255) NOT NULL DEFAULT '', |
| 32 |
createtime varchar(255) DEFAULT '', |
| 33 |
updatetime varchar(255) DEFAULT '', |
| 34 |
optouttime varchar(255) DEFAULT '', |
| 35 |
category int(11), |
| 36 |
email varchar(255), |
| 37 |
form LONGTEXT, |
| 38 |
mail_optin LONGTEXT, |
| 39 |
PRIMARY KEY (id) |
| 40 |
)"; |
| 41 |
dbDelta( $sql ); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Create the table for the categories |
| 46 |
* |
| 47 |
* @return void |
| 48 |
*/ |
| 49 |
function createTableOptinCategories() { |
| 50 |
global $wpdb; |
| 51 |
|
| 52 |
$tableName = 'f12_cf7_doubleoptin_categories'; |
| 53 |
$wpTableName = $wpdb->prefix . $tableName; |
| 54 |
|
| 55 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 56 |
|
| 57 |
$sql = "CREATE TABLE " . $wpTableName . " ( |
| 58 |
id int(11) NOT NULL auto_increment, |
| 59 |
name varchar(255), |
| 60 |
createtime varchar(255) DEFAULT '', |
| 61 |
updatetime varchar(255) DEFAULT '', |
| 62 |
PRIMARY KEY (id) |
| 63 |
)"; |
| 64 |
dbDelta( $sql ); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* On Activation create the custom table to store the required information |
| 69 |
* for the double opt in system. |
| 70 |
*/ |
| 71 |
function onActivation() { |
| 72 |
createTableOptin(); |
| 73 |
createTableOptinCategories(); |
| 74 |
|
| 75 |
// Add cron |
| 76 |
if ( ! wp_next_scheduled( 'dailyOptinClear' ) ) { |
| 77 |
wp_schedule_event( time(), 'daily', 'dailyOptinClear' ); |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
register_activation_hook( plugin_dir_path(__FILE__).'CF7DoubleOptIn.class.php', '\forge12\contactform7\CF7DoubleOptIn\onActivation' ); |