Skip to content

Commit 669bae4

Browse files
Copilotkatsar0v
andcommitted
Add double opt-in workflow for form-based subscriber signups
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
1 parent 65cfd63 commit 669bae4

9 files changed

Lines changed: 912 additions & 38 deletions

includes/class-activator.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MSKD_Activator {
1919
/**
2020
* Database version for tracking schema updates
2121
*/
22-
const DB_VERSION = '1.3.0';
22+
const DB_VERSION = '1.4.0';
2323

2424
/**
2525
* Activate the plugin
@@ -106,6 +106,30 @@ private static function upgrade( $from_version ) {
106106
if ( version_compare( $from_version, '1.3.0', '<' ) ) {
107107
self::create_templates_table();
108108
}
109+
110+
// Upgrade from 1.3.0 to 1.4.0: Add opt_in_token column to subscribers table.
111+
if ( version_compare( $from_version, '1.4.0', '<' ) ) {
112+
$table_subscribers = $wpdb->prefix . 'mskd_subscribers';
113+
114+
// Check if column exists.
115+
$column_exists = $wpdb->get_results(
116+
$wpdb->prepare(
117+
"SHOW COLUMNS FROM {$table_subscribers} LIKE %s",
118+
'opt_in_token'
119+
)
120+
);
121+
122+
if ( empty( $column_exists ) ) {
123+
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange
124+
$wpdb->query(
125+
"ALTER TABLE {$table_subscribers} ADD COLUMN opt_in_token varchar(64) DEFAULT NULL AFTER unsubscribe_token"
126+
);
127+
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange
128+
$wpdb->query(
129+
"ALTER TABLE {$table_subscribers} ADD KEY opt_in_token (opt_in_token)"
130+
);
131+
}
132+
}
109133
}
110134

111135
/**
@@ -125,12 +149,14 @@ private static function create_tables() {
125149
last_name varchar(100) DEFAULT '',
126150
status enum('active','inactive','unsubscribed') DEFAULT 'active',
127151
unsubscribe_token varchar(64) NOT NULL,
152+
opt_in_token varchar(64) DEFAULT NULL,
128153
created_at datetime DEFAULT CURRENT_TIMESTAMP,
129154
updated_at datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
130155
PRIMARY KEY (id),
131156
UNIQUE KEY email (email),
132157
KEY status (status),
133-
KEY unsubscribe_token (unsubscribe_token)
158+
KEY unsubscribe_token (unsubscribe_token),
159+
KEY opt_in_token (opt_in_token)
134160
) $charset_collate;";
135161

136162
// Lists table

languages/mail-system-by-katsarov-design-bg_BG.po

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,3 +2130,54 @@ msgstr "Линк за отписване"
21302130
#: admin/partials/settings.php
21312131
msgid "Raw unsubscribe URL"
21322132
msgstr "Чист URL за отписване"
2133+
2134+
#: public/class-public.php
2135+
msgid "Invalid confirmation link."
2136+
msgstr "Невалиден линк за потвърждение."
2137+
2138+
#: public/class-public.php
2139+
msgid "Too many attempts. Please try again in 5 minutes."
2140+
msgstr "Твърде много опити. Моля, опитайте отново след 5 минути."
2141+
2142+
#: public/class-public.php
2143+
msgid "Please check your email to confirm your subscription."
2144+
msgstr "Моля, проверете имейла си, за да потвърдите абонамента си."
2145+
2146+
#: public/class-public.php
2147+
msgid "You are already subscribed!"
2148+
msgstr "Вече сте абонирани!"
2149+
2150+
#: public/class-public.php
2151+
#, php-format
2152+
msgid "Confirm your subscription to %s"
2153+
msgstr "Потвърдете абонамента си за %s"
2154+
2155+
#: public/class-public.php
2156+
#, php-format
2157+
msgid "Hello %s,"
2158+
msgstr "Здравейте %s,"
2159+
2160+
#: public/class-public.php
2161+
msgid "Hello,"
2162+
msgstr "Здравейте,"
2163+
2164+
#: public/class-public.php
2165+
#, php-format
2166+
msgid "%1$s\n\nThank you for subscribing to %2$s!\n\nPlease click the link below to confirm your subscription:\n\n%3$s\n\nIf you did not request this subscription, you can safely ignore this email.\n\nBest regards,\n%4$s"
2167+
msgstr "%1$s\n\nБлагодарим ви, че се абонирахте за %2$s!\n\nМоля, кликнете върху линка по-долу, за да потвърдите абонамента си:\n\n%3$s\n\nАко не сте заявили този абонамент, можете спокойно да игнорирате този имейл.\n\nС уважение,\n%4$s"
2168+
2169+
#: public/partials/opt-in-confirm.php
2170+
msgid "Subscription Confirmed"
2171+
msgstr "Абонаментът е потвърден"
2172+
2173+
#: public/partials/opt-in-confirm.php
2174+
msgid "Subscription Confirmed!"
2175+
msgstr "Абонаментът е потвърден!"
2176+
2177+
#: public/partials/opt-in-confirm.php
2178+
msgid "Thank you for confirming your subscription. You will now receive our emails."
2179+
msgstr "Благодарим ви, че потвърдихте абонамента си. Сега ще получавате нашите имейли."
2180+
2181+
#: public/partials/opt-in-confirm.php
2182+
msgid "Back to site"
2183+
msgstr "Обратно към сайта"

languages/mail-system-by-katsarov-design-de_DE.po

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,3 +2150,54 @@ msgstr "Klickbarer Abmeldelink"
21502150
#: admin/partials/settings.php
21512151
msgid "Raw unsubscribe URL"
21522152
msgstr "Rohe Abmelde-URL"
2153+
2154+
#: public/class-public.php
2155+
msgid "Invalid confirmation link."
2156+
msgstr "Ungültiger Bestätigungslink."
2157+
2158+
#: public/class-public.php
2159+
msgid "Too many attempts. Please try again in 5 minutes."
2160+
msgstr "Zu viele Versuche. Bitte versuchen Sie es in 5 Minuten erneut."
2161+
2162+
#: public/class-public.php
2163+
msgid "Please check your email to confirm your subscription."
2164+
msgstr "Bitte überprüfen Sie Ihre E-Mail, um Ihr Abonnement zu bestätigen."
2165+
2166+
#: public/class-public.php
2167+
msgid "You are already subscribed!"
2168+
msgstr "Sie sind bereits abonniert!"
2169+
2170+
#: public/class-public.php
2171+
#, php-format
2172+
msgid "Confirm your subscription to %s"
2173+
msgstr "Bestätigen Sie Ihr Abonnement für %s"
2174+
2175+
#: public/class-public.php
2176+
#, php-format
2177+
msgid "Hello %s,"
2178+
msgstr "Hallo %s,"
2179+
2180+
#: public/class-public.php
2181+
msgid "Hello,"
2182+
msgstr "Hallo,"
2183+
2184+
#: public/class-public.php
2185+
#, php-format
2186+
msgid "%1$s\n\nThank you for subscribing to %2$s!\n\nPlease click the link below to confirm your subscription:\n\n%3$s\n\nIf you did not request this subscription, you can safely ignore this email.\n\nBest regards,\n%4$s"
2187+
msgstr "%1$s\n\nVielen Dank für Ihr Abonnement von %2$s!\n\nBitte klicken Sie auf den folgenden Link, um Ihr Abonnement zu bestätigen:\n\n%3$s\n\nWenn Sie dieses Abonnement nicht angefordert haben, können Sie diese E-Mail ignorieren.\n\nMit freundlichen Grüßen,\n%4$s"
2188+
2189+
#: public/partials/opt-in-confirm.php
2190+
msgid "Subscription Confirmed"
2191+
msgstr "Abonnement bestätigt"
2192+
2193+
#: public/partials/opt-in-confirm.php
2194+
msgid "Subscription Confirmed!"
2195+
msgstr "Abonnement bestätigt!"
2196+
2197+
#: public/partials/opt-in-confirm.php
2198+
msgid "Thank you for confirming your subscription. You will now receive our emails."
2199+
msgstr "Vielen Dank für die Bestätigung Ihres Abonnements. Sie werden nun unsere E-Mails erhalten."
2200+
2201+
#: public/partials/opt-in-confirm.php
2202+
msgid "Back to site"
2203+
msgstr "Zurück zur Seite"

languages/mail-system-by-katsarov-design.pot

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,3 +2071,54 @@ msgstr ""
20712071
#: admin/partials/settings.php
20722072
msgid "Raw unsubscribe URL"
20732073
msgstr ""
2074+
2075+
#: public/class-public.php
2076+
msgid "Invalid confirmation link."
2077+
msgstr ""
2078+
2079+
#: public/class-public.php
2080+
msgid "Too many attempts. Please try again in 5 minutes."
2081+
msgstr ""
2082+
2083+
#: public/class-public.php
2084+
msgid "Please check your email to confirm your subscription."
2085+
msgstr ""
2086+
2087+
#: public/class-public.php
2088+
msgid "You are already subscribed!"
2089+
msgstr ""
2090+
2091+
#: public/class-public.php
2092+
#, php-format
2093+
msgid "Confirm your subscription to %s"
2094+
msgstr ""
2095+
2096+
#: public/class-public.php
2097+
#, php-format
2098+
msgid "Hello %s,"
2099+
msgstr ""
2100+
2101+
#: public/class-public.php
2102+
msgid "Hello,"
2103+
msgstr ""
2104+
2105+
#: public/class-public.php
2106+
#, php-format
2107+
msgid "%1$s\n\nThank you for subscribing to %2$s!\n\nPlease click the link below to confirm your subscription:\n\n%3$s\n\nIf you did not request this subscription, you can safely ignore this email.\n\nBest regards,\n%4$s"
2108+
msgstr ""
2109+
2110+
#: public/partials/opt-in-confirm.php
2111+
msgid "Subscription Confirmed"
2112+
msgstr ""
2113+
2114+
#: public/partials/opt-in-confirm.php
2115+
msgid "Subscription Confirmed!"
2116+
msgstr ""
2117+
2118+
#: public/partials/opt-in-confirm.php
2119+
msgid "Thank you for confirming your subscription. You will now receive our emails."
2120+
msgstr ""
2121+
2122+
#: public/partials/opt-in-confirm.php
2123+
msgid "Back to site"
2124+
msgstr ""

0 commit comments

Comments
 (0)