SB Welcome Email Editor - Version 5.0

Version Description

| May 22, 2021 = * Hey there, David here :) We have taken over the Welcome Email Editor project from our friend Sean Barton. This is our initial release - Apart from some minor improvements, no new features were added. With this release we have reviewed & rewritten the codebase from ground up and greatly improved the settings page design. Stay tuned for more.

Download this release

Release Info

Developer davidvongries
Plugin Icon wp plugin SB Welcome Email Editor
Version 5.0
Comparing to
See all releases

Version 5.0

Files changed (41) hide show
  1. assets/css/heatbox.css +382 -0
  2. assets/images/page-builder-framework.jpg +0 -0
  3. assets/images/swift-control.jpg +0 -0
  4. assets/images/ultimate-dashboard.jpg +0 -0
  5. assets/images/welcome-email-editor-logo.png +0 -0
  6. assets/images/wp-video-popup.jpg +0 -0
  7. class-backwards-compatibility.php +163 -0
  8. class-setup.php +219 -0
  9. class-vars.php +62 -0
  10. helpers/class-content-helper.php +81 -0
  11. helpers/class-email-helper.php +90 -0
  12. helpers/class-screen-helper.php +28 -0
  13. modules/base/class-base-module.php +61 -0
  14. modules/base/class-base-output.php +61 -0
  15. modules/settings/ajax/class-test-emails.php +136 -0
  16. modules/settings/assets/css/settings.css +168 -0
  17. modules/settings/assets/js/settings.js +79 -0
  18. modules/settings/class-settings-module.php +420 -0
  19. modules/settings/class-settings-output.php +348 -0
  20. modules/settings/templates/fields/admin-new-user-notif-email/body.php +26 -0
  21. modules/settings/templates/fields/admin-new-user-notif-email/custom-recipients.php +32 -0
  22. modules/settings/templates/fields/admin-new-user-notif-email/subject.php +25 -0
  23. modules/settings/templates/fields/admin-new-user-notif-email/test-button.php +27 -0
  24. modules/settings/templates/fields/general/content-type.php +27 -0
  25. modules/settings/templates/fields/general/from-email.php +31 -0
  26. modules/settings/templates/fields/general/from-name.php +25 -0
  27. modules/settings/templates/fields/misc/remove-on-uninstall.php +24 -0
  28. modules/settings/templates/fields/reset-password-email/body.php +25 -0
  29. modules/settings/templates/fields/reset-password-email/subject.php +25 -0
  30. modules/settings/templates/fields/reset-password-email/test-button.php +27 -0
  31. modules/settings/templates/fields/user-welcome-email/additional-headers.php +33 -0
  32. modules/settings/templates/fields/user-welcome-email/attachment.php +29 -0
  33. modules/settings/templates/fields/user-welcome-email/body.php +25 -0
  34. modules/settings/templates/fields/user-welcome-email/reply-to-email.php +25 -0
  35. modules/settings/templates/fields/user-welcome-email/reply-to-name.php +25 -0
  36. modules/settings/templates/fields/user-welcome-email/subject.php +25 -0
  37. modules/settings/templates/fields/user-welcome-email/test-button.php +27 -0
  38. modules/settings/templates/settings-template.php +179 -0
  39. readme.txt +59 -0
  40. sb_welcome_email_editor.php +38 -0
  41. wp-new-user-notification.php +381 -0
assets/css/heatbox.css ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Init */
2
+ .heatbox-wrap,
3
+ .heatbox-wrap * {
4
+ -webkit-box-sizing: border-box;
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ .heatbox-admin.has-header .update-nag {
9
+ display: none;
10
+ }
11
+
12
+ .heatbox-admin.has-header #wpcontent {
13
+ padding-left: 0 !important;
14
+ }
15
+
16
+ .heatbox-admin.has-header .wrap {
17
+ margin: 0;
18
+ }
19
+
20
+ /* Divider */
21
+ .heatbox-divider {
22
+ width: 100%;
23
+ height: 1px;
24
+ margin: 50px 0;
25
+ background: #ccc;
26
+ }
27
+
28
+ @media screen and (max-width: 991px) {
29
+ .heatbox-divider {
30
+ margin: 20px 0;
31
+ }
32
+ }
33
+
34
+ /* Container */
35
+ .heatbox-container {
36
+ max-width: 1200px;
37
+ padding: 0 20px;
38
+ }
39
+
40
+ .heatbox-container-wide {
41
+ max-width: 1400px;
42
+ }
43
+
44
+ .heatbox-container-center {
45
+ margin: 0 auto;
46
+ }
47
+
48
+ /* Header */
49
+ .heatbox-header {
50
+ background: #fff;
51
+ padding-top: 40px;
52
+ border-bottom: 1px solid #ddd;
53
+ }
54
+
55
+ .heatbox-header .logo-container {
56
+ display: flex;
57
+ align-items: center;
58
+ margin-bottom: 40px;
59
+ }
60
+
61
+ .heatbox-header .logo-container div {
62
+ width: 50%;
63
+ }
64
+
65
+ .heatbox-header .logo-container img {
66
+ width: 100px;
67
+ height: auto;
68
+ float: right;
69
+ }
70
+
71
+ .heatbox-header .tab-navigation {
72
+ margin: -20px 0 20px 0;
73
+ padding: 0;
74
+ }
75
+
76
+ .heatbox-header .tab-navigation li {
77
+ display: inline-flex;
78
+ padding: 10px 30px 10px 0;
79
+ font-weight: 600;
80
+ font-size: 20px;
81
+ }
82
+
83
+ .heatbox-header .tab-navigation li a {
84
+ color: #23282d;
85
+ text-decoration: none;
86
+ }
87
+
88
+ .heatbox-header .tab-navigation li.active a {
89
+ color: #0073aa;
90
+ }
91
+
92
+ /* Title */
93
+ .heatbox-wrap .title {
94
+ margin: 0;
95
+ padding: 0;
96
+ font-size: 34px;
97
+ font-weight: 700;
98
+ line-height: 1;
99
+ }
100
+
101
+ .heatbox-wrap .subtitle {
102
+ margin: 20px 0 0 0;
103
+ padding: 0;
104
+ font-size: 20px;
105
+ line-height: 1;
106
+ }
107
+
108
+ /* Version */
109
+ .heatbox-wrap .version {
110
+ font-size: 50%;
111
+ opacity: 0.6;
112
+ font-weight: 600;
113
+ background: #ccc;
114
+ border-radius: 5px;
115
+ padding: 5px 12px;
116
+ line-height: 1;
117
+ }
118
+
119
+ /* 2 Column Layout - Wrapper */
120
+ .heatbox-column-container {
121
+ display: flex;
122
+ flex-wrap: wrap;
123
+ }
124
+
125
+ /* 2 Column Layout - Main Content */
126
+ .heatbox-main {
127
+ width: 73%;
128
+ margin-right: 2%;
129
+ }
130
+
131
+ /* 2 Column Layout - Sidebar */
132
+ .heatbox-sidebar {
133
+ width: 25%;
134
+ }
135
+
136
+ /* 2 Column Layout - Responsive */
137
+ @media screen and (max-width: 991px) {
138
+ .heatbox-main, .heatbox-sidebar {
139
+ width: 100%;
140
+ }
141
+ .heatbox-main {
142
+ margin-right: 0;
143
+ }
144
+ }
145
+
146
+ /* Panels */
147
+ .heatbox-admin-panel {
148
+ display: none;
149
+ }
150
+
151
+ /* Heatbox */
152
+ .heatbox {
153
+ background: #fff;
154
+ margin-bottom: 20px;
155
+ border: 1px solid #ddd;
156
+ }
157
+
158
+ .heatbox h2 {
159
+ border-bottom: 1px solid #ddd;
160
+ margin: 0;
161
+ padding: 20px;
162
+ }
163
+
164
+ .heatbox.is-grouped h2 {
165
+ border-top: 1px solid #ddd;
166
+ }
167
+
168
+ .heatbox.is-grouped h2:first-child {
169
+ border-top: none;
170
+ }
171
+
172
+ .heatbox h3 {
173
+ margin: 0 0 10px 0;
174
+ }
175
+
176
+ .heatbox p {
177
+ margin: 0 0 20px 0;
178
+ }
179
+
180
+ .heatbox-content {
181
+ margin: 0;
182
+ padding: 20px;
183
+ }
184
+
185
+ .heatbox-content p:first-child {
186
+ margin-top: 0;
187
+ }
188
+
189
+ /* Margins */
190
+ .heatbox-margin-top {
191
+ margin-top: 20px;
192
+ }
193
+
194
+ .heatbox-margin-bottom {
195
+ margin-bottom: 20px;
196
+ }
197
+
198
+ /* Paddings */
199
+ .heatbox-margin-top {
200
+ margin-top: 20px;
201
+ }
202
+
203
+ .heatbox-margin-bottom {
204
+ margin-bottom: 20px;
205
+ }
206
+
207
+ /* Buttons */
208
+ .heatbox-wrap .button-larger {
209
+ padding: 5px 20px;
210
+ }
211
+
212
+ /* Settings */
213
+ .heatbox .form-table {
214
+ margin: 0;
215
+ }
216
+
217
+ .heatbox .form-table th,
218
+ .heatbox .form-table td {
219
+ padding: 20px;
220
+ vertical-align: top;
221
+ }
222
+
223
+ .heatbox .form-table th .description {
224
+ margin-top: 10px;
225
+ }
226
+
227
+ .heatbox .setting-fields {
228
+
229
+ }
230
+
231
+ .heatbox .setting-fields .setting-field {
232
+ margin-bottom: 7px;
233
+ }
234
+
235
+ .heatbox .setting-fields .setting-field:last-of-type {
236
+ margin-bottom: 0;
237
+ }
238
+
239
+ /* Submit button */
240
+ .heatbox-wrap p.submit {
241
+ margin: 20px 0;
242
+ padding: 0;
243
+ }
244
+
245
+ /**
246
+ * Checkboxes & Radio Buttons
247
+ * Copied & modified from https://codepen.io/KenanYusuf/pen/PZKEKd/
248
+ */
249
+ .heatbox .label {
250
+ display: inline-block;
251
+ position: relative;
252
+ cursor: pointer;
253
+ }
254
+
255
+ .heatbox .label input {
256
+ position: absolute;
257
+ z-index: -1;
258
+ opacity: 0;
259
+ }
260
+
261
+ .heatbox .label .indicator {
262
+ position: absolute;
263
+ top: 0;
264
+ left: 0;
265
+ height: 20px;
266
+ width: 20px;
267
+ background-color: #e6e6e6;
268
+ -webkit-transition: all 0.2s ease-in-out;
269
+ transition: all 0.2s ease-in-out;
270
+ }
271
+
272
+ .heatbox .radio-label .indicator {
273
+ border-radius: 50%;
274
+ }
275
+
276
+ .heatbox .label:hover input ~ .indicator,
277
+ .heatbox .label input:focus ~ .indicator {
278
+ background-color: #ccc;
279
+ }
280
+
281
+ .heatbox .label input:checked ~ .indicator {
282
+ background-color: #007cba;
283
+ }
284
+
285
+ .heatbox .label:hover input:not([disabled]):checked ~ .indicator,
286
+ .heatbox .label input:checked:focus ~ .indicator {
287
+ background-color: #00669b;
288
+ }
289
+
290
+ .heatbox .label input:disabled ~ .indicator {
291
+ background-color: #e6e6e6;
292
+ opacity: 0.6;
293
+ pointer-events: none;
294
+ }
295
+
296
+ .heatbox .label .indicator::after {
297
+ display: none;
298
+ position: absolute;
299
+ content: "";
300
+ }
301
+
302
+ .heatbox .label input:checked ~ .indicator::after {
303
+ display: block;
304
+ }
305
+
306
+ .heatbox .checkbox-label {
307
+ padding-left: 30px;
308
+ }
309
+
310
+ .heatbox .checkbox-label .indicator::after {
311
+ left: 8px;
312
+ top: 4px;
313
+ width: 3px;
314
+ height: 8px;
315
+ border: solid #fff;
316
+ border-width: 0 2px 2px 0;
317
+ transform: rotate(45deg);
318
+ }
319
+
320
+ .heatbox .checkbox-label input:disabled ~ .indicator::after {
321
+ border-color: #7b7b7b;
322
+ }
323
+
324
+ .heatbox .radio-label .indicator::after {
325
+ left: 7px;
326
+ top: 7px;
327
+ height: 6px;
328
+ width: 6px;
329
+ border-radius: 50%;
330
+ background-color: #fff;
331
+ }
332
+
333
+ .heatbox .radio-label input:disabled ~ .indicator::after {
334
+ background-color: #7b7b7b;
335
+ }
336
+
337
+ /* Call to action */
338
+ .heatbox-cta-container.is-attached {
339
+ padding: 20px;
340
+ background: #fff;
341
+ margin-top: -20px;
342
+ margin-bottom: 20px;
343
+ border: 1px solid #ddd;
344
+ border-top: none;
345
+ }
346
+
347
+ .heatbox-cta {
348
+ width: 100%;
349
+ display: flex;
350
+ justify-content: space-between;
351
+ align-items: center;
352
+ padding: 20px;
353
+ font-weight: 700;
354
+ border: 1px solid #ddd;
355
+ background: #fff;
356
+ }
357
+
358
+ .heatbox-cta > * {
359
+ margin: 0 !important;
360
+ }
361
+
362
+ .heatbox-cta .button {
363
+ padding: 5px 15px !important;
364
+ }
365
+
366
+ .heatbox-cta.primary {
367
+ background: #197cff;
368
+ color: #fff;
369
+ border: none;
370
+ }
371
+
372
+ .heatbox-cta.secondary {
373
+ background: #f1f1f1;
374
+ }
375
+
376
+ .heatbox-cta.primary .button {
377
+ background: rgba(0, 45, 96, 0.5);
378
+ }
379
+
380
+ .heatbox-cta.primary .button:hover {
381
+ background: rgba(0, 45, 96, 0.6);
382
+ }
assets/images/page-builder-framework.jpg ADDED
Binary file
assets/images/swift-control.jpg ADDED
Binary file
assets/images/ultimate-dashboard.jpg ADDED
Binary file
assets/images/welcome-email-editor-logo.png ADDED
Binary file
assets/images/wp-video-popup.jpg ADDED
Binary file
class-backwards-compatibility.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Backwards compatibility.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ /**
13
+ * Class that handles backwards compatibility.
14
+ */
15
+ class Backwards_Compatibility {
16
+
17
+ /**
18
+ * The class instance.
19
+ *
20
+ * @var object
21
+ */
22
+ public static $instance;
23
+
24
+ /**
25
+ * Get instance of the class.
26
+ */
27
+ public static function get_instance() {
28
+
29
+ if ( null === self::$instance ) {
30
+ self::$instance = new self();
31
+ }
32
+
33
+ return self::$instance;
34
+
35
+ }
36
+
37
+ /**
38
+ * Init the class setup.
39
+ */
40
+ public static function init() {
41
+ $instance = new Backwards_Compatibility();
42
+ $instance->setup();
43
+ }
44
+
45
+ /**
46
+ * Setup the class.
47
+ */
48
+ public function setup() {
49
+
50
+ add_action( 'admin_init', array( $this, 'compatibility_check' ) );
51
+
52
+ }
53
+
54
+ /**
55
+ * Run compatibility checking on admin_init hook.
56
+ */
57
+ public function compatibility_check() {
58
+
59
+ // Don't run checking on heartbeat request.
60
+ if ( isset( $_POST['action'] ) && 'heartbeat' === $_POST['action'] ) {
61
+ return;
62
+ }
63
+
64
+ $this->v5_compatibility();
65
+
66
+ }
67
+
68
+ /**
69
+ * Run compatibility check based on v5 update.
70
+ *
71
+ * The v5 update is the first update after plugin's transfer from Sean to David.
72
+ * It was a major update where there are plugin re-structure and option key (and sub-keys) renaming.
73
+ */
74
+ public function v5_compatibility() {
75
+
76
+ // Make sure we don't check again.
77
+ if ( get_option( 'weed_v5_compatibility' ) ) {
78
+ return;
79
+ }
80
+
81
+ $old_settings = get_option( 'sb_we_settings', array() );
82
+ $settings = get_option( 'weed_settings', array() );
83
+
84
+ if ( empty( $old_settings ) || ! is_object( $old_settings ) ) {
85
+ // Make sure we don't check again.
86
+ update_option( 'weed_v5_compatibility', 1 );
87
+
88
+ return;
89
+ }
90
+
91
+ /**
92
+ * If "Set Global Email Headers" was set to "Yes", then bring the values to the new "General Settings".
93
+ * If set to "No", then leave the "General Settings" empty.
94
+ *
95
+ * The "Mail Content Type" has "html" as the default value for it's selectbox.
96
+ */
97
+ if ( $old_settings->set_global_headers ) {
98
+ if ( $old_settings->header_from_email ) {
99
+ $settings['from_email'] = $old_settings->header_from_email;
100
+ }
101
+
102
+ if ( $old_settings->header_from_name ) {
103
+ $settings['from_name'] = $old_settings->header_from_name;
104
+ }
105
+
106
+ if ( $old_settings->header_send_as ) {
107
+ $settings['content_type'] = $old_settings->header_send_as;
108
+ }
109
+ }
110
+
111
+ // User welcome email metabox.
112
+
113
+ if ( $old_settings->user_subject ) {
114
+ $settings['user_welcome_email_subject'] = $old_settings->user_subject;
115
+ }
116
+
117
+ if ( $old_settings->user_body ) {
118
+ $settings['user_welcome_email_body'] = $old_settings->user_body;
119
+ }
120
+
121
+ if ( $old_settings->we_attachment_url ) {
122
+ $settings['user_welcome_email_attachment_url'] = $old_settings->we_attachment_url;
123
+ }
124
+
125
+ if ( $old_settings->header_reply_to ) {
126
+ $settings['user_welcome_email_reply_to_email'] = $old_settings->header_reply_to;
127
+ }
128
+
129
+ if ( $old_settings->header_additional ) {
130
+ $settings['user_welcome_email_additional_headers'] = $old_settings->header_additional;
131
+ }
132
+
133
+ // Admin new user notification metabox.
134
+
135
+ if ( $old_settings->admin_subject ) {
136
+ $settings['admin_new_user_notif_email_subject'] = $old_settings->admin_subject;
137
+ }
138
+
139
+ if ( $old_settings->admin_body ) {
140
+ $settings['admin_new_user_notif_email_body'] = $old_settings->admin_body;
141
+ }
142
+
143
+ if ( $old_settings->admin_notify_user_id ) {
144
+ $settings['admin_new_user_notif_email_custom_recipients'] = $old_settings->admin_notify_user_id;
145
+ }
146
+
147
+ // Reset password metabox.
148
+
149
+ if ( $old_settings->password_reminder_subject ) {
150
+ $settings['reset_password_email_subject'] = $old_settings->password_reminder_subject;
151
+ }
152
+
153
+ if ( $old_settings->password_reminder_body ) {
154
+ $settings['reset_password_email_body'] = $old_settings->password_reminder_body;
155
+ }
156
+
157
+ update_option( 'weed_settings', $settings );
158
+ delete_option( 'sb_we_settings' );
159
+
160
+ // Make sure we don't check again.
161
+ update_option( 'weed_v5_compatibility', 1 );
162
+ }
163
+ }
class-setup.php ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Setup Welcome Email Editor plugin.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ use Weed\Vars;
13
+
14
+ /**
15
+ * Class to setup Ultimate Quick View plugin.
16
+ */
17
+ class Setup {
18
+ /**
19
+ * The class instance.
20
+ *
21
+ * @var object
22
+ */
23
+ public static $instance;
24
+
25
+ /**
26
+ * Get instance of the class.
27
+ */
28
+ public static function get_instance() {
29
+
30
+ if ( null === self::$instance ) {
31
+ self::$instance = new self();
32
+ }
33
+
34
+ return self::$instance;
35
+
36
+ }
37
+
38
+ /**
39
+ * Init the class setup.
40
+ */
41
+ public static function init() {
42
+
43
+ $class = self::get_instance();
44
+
45
+ add_action( 'plugins_loaded', array( $class, 'setup' ) );
46
+
47
+ }
48
+
49
+ /**
50
+ * Setup the class.
51
+ */
52
+ public function setup() {
53
+
54
+ $this->set_data();
55
+
56
+ add_action( 'init', array( $this, 'setup_text_domain' ) );
57
+ add_filter( 'plugin_action_links_' . WEED_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
58
+ add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
+
60
+ $this->load_modules();
61
+
62
+ register_deactivation_hook( WEED_PLUGIN_BASENAME, array( $this, 'deactivation' ), 20 );
63
+
64
+ }
65
+
66
+ /**
67
+ * Setup textdomain.
68
+ */
69
+ public function setup_text_domain() {
70
+ load_plugin_textdomain( 'welcome-email-editor', false, WEED_PLUGIN_BASENAME . '/languages' );
71
+ }
72
+
73
+ /**
74
+ * Provide data for the plugin.
75
+ * This is optimal strategy to only get_option once across modules.
76
+ */
77
+ public function set_data() {
78
+
79
+ /* translators: %s: User login. */
80
+ $user_welcome_email_body = __( 'Username:', 'welcome-email-editor' ) . ' [user_login]' . "<br><br>\r\n\r\n";
81
+ $user_welcome_email_body .= __( 'To set your password, visit the following address:' ) . "<br><br>\r\n\r\n";
82
+ $user_welcome_email_body .= '[reset_pass_url]<br><br>' . "\r\n\r\n";
83
+ $user_welcome_email_body .= '[login_url]' . "\r\n";
84
+
85
+ /* translators: %s: Site title. */
86
+ $user_welome_email_body = __( 'New user registration on your site', 'welcome-email-editor' ) . " [blog_name]<br><br>\r\n\r\n";
87
+ /* translators: %s: User login. */
88
+ $user_welome_email_body .= __( 'Username:', 'welcome-email-editor' ) . " [user_login]<br><br>\r\n\r\n";
89
+ /* translators: %s: User email address. */
90
+ $user_welome_email_body .= __( 'Email:', 'welcome-email-editor' ) . " [user_email]<br><br>\r\n";
91
+
92
+ $reset_password_message = __( 'Someone has requested a password reset for the following account:', 'welcome-email-editor' ) . "<br><br>\r\n\r\n";
93
+ /* translators: %s: Site name. */
94
+ $reset_password_message .= __( 'Site Name:', 'welcome-email-editor' ) . " [blog_name]<br><br>\r\n\r\n";
95
+ /* translators: %s: User login. */
96
+ $reset_password_message .= __( 'Username:', 'welcome-email-editor' ) . " [user_login]<br><br>\r\n\r\n";
97
+ $reset_password_message .= __( 'If this was a mistake, ignore this email and nothing will happen.', 'welcome-email-editor' ) . "<br><br>\r\n\r\n";
98
+ $reset_password_message .= __( 'To reset your password, visit the following address:', 'welcome-email-editor' ) . "<br><br>\r\n\r\n";
99
+ $reset_password_message .= "[reset_url]\r\n";
100
+
101
+ $defaults = array(
102
+ // General settings.
103
+ 'from_email' => '',
104
+ 'from_name' => '',
105
+ 'content_type' => 'html',
106
+
107
+ // Welcome email settings - for user.
108
+ 'user_welcome_email_subject' => '[[blog_name]] ' . __( 'Login Details', 'welcome-email-editor' ),
109
+ 'user_welcome_email_body' => $user_welcome_email_body,
110
+ 'user_welcome_email_attachment_url' => '',
111
+ 'user_welcome_email_reply_to_email' => '',
112
+ 'user_welcome_email_reply_to_name' => '',
113
+ 'user_welcome_email_additional_headers' => '',
114
+
115
+ // Welcome email settings - for admin.
116
+ 'admin_new_user_notif_email_subject' => '[[blog_name]] ' . __( 'New User Registration', 'welcome-email-editor' ),
117
+ 'admin_new_user_notif_email_body' => $user_welome_email_body,
118
+ 'admin_new_user_notif_email_custom_recipients' => '',
119
+
120
+ // Reset password email settings.
121
+ 'reset_password_email_subject' => '[[blog_name]] ' . __( 'Password Reset', 'welcome-email-editor' ),
122
+ 'reset_password_email_body' => $reset_password_message,
123
+ );
124
+
125
+ $settings = get_option( 'weed_settings', array() );
126
+
127
+ $values = wp_parse_args( $settings, $defaults );
128
+
129
+ Vars::set( 'default_settings', $defaults );
130
+ Vars::set( 'settings', $settings );
131
+ Vars::set( 'values', $values );
132
+
133
+ }
134
+
135
+ /**
136
+ * Add action links displayed in plugins page.
137
+ *
138
+ * @param array $links The action links array.
139
+ * @return array The modified action links array.
140
+ */
141
+ public function plugin_action_links( $links ) {
142
+
143
+ $settings = array( '<a href="' . admin_url( 'admin.php?page=weed_settings' ) . '">' . __( 'Settings', 'ultimate-quick-view-woocommerce' ) . '</a>' );
144
+
145
+ return array_merge( $settings, $links );
146
+
147
+ }
148
+
149
+ /**
150
+ * Admin body class.
151
+ *
152
+ * @param string $classes The existing body classes.
153
+ * @return string The body classes.
154
+ */
155
+ public function admin_body_class( $classes ) {
156
+
157
+ $screens = array(
158
+ 'settings_page_weed_settings',
159
+ );
160
+
161
+ $screen = get_current_screen();
162
+
163
+ if ( ! in_array( $screen->id, $screens, true ) ) {
164
+ return $classes;
165
+ }
166
+
167
+ $classes .= ' heatbox-admin has-header';
168
+
169
+ return $classes;
170
+
171
+ }
172
+
173
+ /**
174
+ * Load modules.
175
+ */
176
+ public function load_modules() {
177
+
178
+ $modules = array();
179
+
180
+ $modules['Weed\\Settings\\Settings_Module'] = __DIR__ . '/modules/settings/class-settings-module.php';
181
+
182
+ $modules = apply_filters( 'weed_modules', $modules );
183
+
184
+ foreach ( $modules as $class => $file ) {
185
+ $splits = explode( '/', $file );
186
+ $module_name = $splits[ count( $splits ) - 2 ];
187
+ $filter_name = str_ireplace( '-', '_', $module_name );
188
+ $filter_name = 'weed_' . $filter_name;
189
+
190
+ // We have a filter here weed_$module_name to allow us to prevent loading modules under certain circumstances.
191
+ if ( apply_filters( $filter_name, true ) ) {
192
+
193
+ require_once $file;
194
+ $module = new $class();
195
+ $module->setup();
196
+
197
+ }
198
+ }
199
+
200
+ }
201
+
202
+ /**
203
+ * Plugin deactivation.
204
+ */
205
+ public function deactivation() {
206
+
207
+ $settings = get_option( 'weed_settings' );
208
+
209
+ $remove_on_uninstall = isset( $settings['remove_on_uninstall'] ) ? true : false;
210
+
211
+ if ( $remove_on_uninstall ) {
212
+
213
+ delete_option( 'weed_settings' );
214
+ delete_option( 'weed_v5_compatibility' );
215
+
216
+ }
217
+
218
+ }
219
+ }
class-vars.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Setter & getter utility
4
+ *
5
+ * @package Ultimate_Quick_View
6
+ */
7
+
8
+ namespace Weed;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ /**
13
+ * Global setter & getter utility
14
+ *
15
+ * Vars::set($key, $value);
16
+ *
17
+ * @param string/array $key
18
+ * @param mix $value
19
+ *
20
+ * Vars::get($key);
21
+ * @param string $key
22
+ * @return mix $value
23
+ */
24
+ class Vars {
25
+
26
+ /**
27
+ * Item's container
28
+ *
29
+ * @var array
30
+ */
31
+ private static $vars = [];
32
+
33
+ /**
34
+ * Get value from a given key
35
+ *
36
+ * @param string $name The key name.
37
+ * @return mixed
38
+ */
39
+ public static function get( $name ) {
40
+ $value = isset( self::$vars[ $name ] ) ? self::$vars[ $name ] : '';
41
+ return $value;
42
+ }
43
+
44
+ /**
45
+ * Set key-value pair
46
+ * - single mode: set the $key as key name, $value as the data
47
+ * - multiple mode: set the $key as array of key-value pairs, and leave the $value empty
48
+ *
49
+ * @param string $name Can be either key name or array of key-value pairs.
50
+ * @param string $value The data.
51
+ * @return void
52
+ */
53
+ public static function set( $name, $value = '' ) {
54
+ if ( is_array( $name ) ) {
55
+ foreach ( $name as $key => $value ) {
56
+ self::$vars[ $key ] = $value;
57
+ }
58
+ } else {
59
+ self::$vars[ $name ] = $value;
60
+ }
61
+ }
62
+ }
helpers/class-content-helper.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Content helper.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed\Helpers;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ /**
13
+ * Class to setup screen helper.
14
+ */
15
+ class Content_Helper {
16
+
17
+ /**
18
+ * Get BuddyPress custom profile fields.
19
+ *
20
+ * @param int $user_id The user ID.
21
+ * @return array
22
+ */
23
+ public function get_bp_user_custom_fields( $user_id ) {
24
+
25
+ if ( ! defined( 'BP_PLUGIN_URL' ) ) {
26
+ return array();
27
+ }
28
+
29
+ global $wpdb;
30
+
31
+ // TODO: Use BuddyPress function if it exists instead of directly touching wpdb.
32
+ $sql = 'SELECT f.name, d.value
33
+ FROM
34
+ ' . $wpdb->prefix . 'bp_xprofile_fields f
35
+ JOIN ' . $wpdb->prefix . 'bp_xprofile_data d ON (d.field_id = f.id)
36
+ WHERE d.user_id = ' . $user_id;
37
+
38
+ $array = $wpdb->get_results( $sql );
39
+
40
+ $assoc_array = array();
41
+
42
+ foreach ( $array as $key => $value ) {
43
+ $assoc_array[ $value->name ] = $value->value;
44
+ }
45
+
46
+ $assoc_array = apply_filters( 'weed_bp_custom_fields', $assoc_array );
47
+
48
+ return $assoc_array;
49
+
50
+ }
51
+
52
+ /**
53
+ * Get user's custom fields.
54
+ *
55
+ * @param int $user_id The user ID.
56
+ * @return array
57
+ */
58
+ public function get_user_custom_fields( $user_id ) {
59
+
60
+ global $wpdb;
61
+
62
+ // TODO: Use get_user_meta instead of directly touching wpdb.
63
+ $sql = 'SELECT meta_key, meta_value
64
+ FROM ' . $wpdb->usermeta . '
65
+ WHERE user_ID = ' . $user_id;
66
+
67
+ $meta_items = $wpdb->get_results( $sql );
68
+
69
+ $custom_fields = array();
70
+
71
+ if ( $meta_items ) {
72
+ foreach ( $meta_items as $meta_item ) {
73
+ $custom_fields[ $meta_item->meta_key ] = $meta_item->meta_value;
74
+ }
75
+ }
76
+
77
+ return $custom_fields;
78
+
79
+ }
80
+
81
+ }
helpers/class-email-helper.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Screen helper.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed\Helpers;
9
+
10
+ use Weed\Vars;
11
+
12
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
13
+
14
+ /**
15
+ * Class to setup screen helper.
16
+ */
17
+ class Email_Helper {
18
+ /**
19
+ * Get extra email headers.
20
+ *
21
+ * This will be used to set the headers parameter in `wp_mail()`.
22
+ *
23
+ * Included as extra headers:
24
+ * - Reply-To (name & email).
25
+ * - Additional / custom headers.
26
+ *
27
+ * @return array List of Header string.
28
+ */
29
+ public function get_extra_headers() {
30
+
31
+ $values = Vars::get( 'values' );
32
+ $settings = Vars::get( 'settings' );
33
+
34
+ /**
35
+ * The blogname option is escaped with esc_html() on the way into the database in sanitize_option().
36
+ * We want to reverse this for the plain text arena of emails.
37
+ *
38
+ * This comment was taken from wp-includes/pluggable.php inside `wp_new_user_notification` function.
39
+ */
40
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
41
+ $admin_email = get_option( 'admin_email' );
42
+
43
+ $headers = array();
44
+ $reply_to = '';
45
+
46
+ if ( ! empty( $values['user_welcome_email_reply_to_email'] ) ) {
47
+ $reply_to = 'Reply-To:';
48
+
49
+ // Only check for reply to name, if reply to email exists.
50
+ if ( ! empty( $values['user_welcome_email_reply_to_name'] ) ) {
51
+ $reply_to .= ' ' . $settings['user_welcome_email_reply_to_name'];
52
+ }
53
+
54
+ $reply_to .= ' <' . $settings['user_welcome_email_reply_to_email'] . '>';
55
+ }
56
+
57
+ if ( ! empty( $reply_to ) ) {
58
+ array_push( $headers, $reply_to );
59
+ }
60
+
61
+ $custom_headers = $values['user_welcome_email_additional_headers'];
62
+ $custom_headers = trim( $custom_headers );
63
+ $custom_headers = str_ireplace( "\r\n", "\n", $custom_headers );
64
+ $custom_headers = explode( "\n", $custom_headers );
65
+
66
+ $placeholders = array(
67
+ '[site_url]',
68
+ '[blog_name]',
69
+ '[admin_email]',
70
+ );
71
+
72
+ $replacements = array(
73
+ network_site_url(),
74
+ $blogname,
75
+ $admin_email,
76
+ );
77
+
78
+ foreach ( $custom_headers as $custom_header ) {
79
+ $custom_header = trim( $custom_header );
80
+
81
+ if ( ! empty( $custom_header ) ) {
82
+ $custom_header = str_ireplace( $placeholders, $replacements, $custom_header );
83
+ array_push( $headers, $custom_header );
84
+ }
85
+ }
86
+
87
+ return $headers;
88
+
89
+ }
90
+ }
helpers/class-screen-helper.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Screen helper.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed\Helpers;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ /**
13
+ * Class to setup screen helper.
14
+ */
15
+ class Screen_Helper {
16
+ /**
17
+ * Check if current screen is Welcome Email Editor's settings page.
18
+ *
19
+ * @return boolean
20
+ */
21
+ public function is_settings() {
22
+
23
+ $current_screen = get_current_screen();
24
+
25
+ return ( 'settings_page_weed_settings' === $current_screen->id ? true : false );
26
+
27
+ }
28
+ }
modules/base/class-base-module.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Base module setup.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed\Base;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ use Weed\Vars;
13
+ use Weed\Helpers\Screen_Helper;
14
+
15
+ /**
16
+ * Class to setup base module.
17
+ */
18
+ class Base_Module {
19
+ /**
20
+ * The default settings.
21
+ *
22
+ * @var array
23
+ */
24
+ public $defaults;
25
+
26
+ /**
27
+ * The saved settings.
28
+ *
29
+ * @var array
30
+ */
31
+ public $settings;
32
+
33
+ /**
34
+ * The parsed settings values.
35
+ *
36
+ * @var array
37
+ */
38
+ public $values;
39
+
40
+ /**
41
+ * Module constructor.
42
+ */
43
+ public function __construct() {
44
+
45
+ $this->defaults = Vars::get( 'default_settings' );
46
+ $this->settings = Vars::get( 'settings' );
47
+ $this->values = Vars::get( 'values' );
48
+
49
+ }
50
+
51
+ /**
52
+ * Screen helper.
53
+ *
54
+ * @return object Instance of array helper.
55
+ */
56
+ public function screen() {
57
+
58
+ return new Screen_Helper();
59
+
60
+ }
61
+ }
modules/base/class-base-output.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Base module output.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed\Base;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ use Weed\Vars;
13
+ use Weed\Helpers\Screen_Helper;
14
+
15
+ /**
16
+ * Class to setup base output.
17
+ */
18
+ class Base_Output {
19
+ /**
20
+ * The default settings.
21
+ *
22
+ * @var array
23
+ */
24
+ public $defaults;
25
+
26
+ /**
27
+ * The saved settings.
28
+ *
29
+ * @var array
30
+ */
31
+ public $settings;
32
+
33
+ /**
34
+ * The parsed settings values.
35
+ *
36
+ * @var array
37
+ */
38
+ public $values;
39
+
40
+ /**
41
+ * Module constructor.
42
+ */
43
+ public function __construct() {
44
+
45
+ $this->defaults = Vars::get( 'default_settings' );
46
+ $this->settings = Vars::get( 'settings' );
47
+ $this->values = Vars::get( 'values' );
48
+
49
+ }
50
+
51
+ /**
52
+ * Screen helper.
53
+ *
54
+ * @return object Instance of screen helper.
55
+ */
56
+ public function screen() {
57
+
58
+ return new Screen_Helper();
59
+
60
+ }
61
+ }
modules/settings/ajax/class-test-emails.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Test emails.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed\Settings\Ajax;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ /**
13
+ * Class to handle ajax request to test emails.
14
+ */
15
+ class Test_Emails {
16
+
17
+ /**
18
+ * The class instance.
19
+ *
20
+ * @var object
21
+ */
22
+ public static $instance;
23
+
24
+ /**
25
+ * The email type.
26
+ *
27
+ * @var string
28
+ */
29
+ public $email_type;
30
+
31
+ /**
32
+ * Get instance of the class.
33
+ */
34
+ public static function get_instance() {
35
+
36
+ if ( null === self::$instance ) {
37
+ self::$instance = new self();
38
+ }
39
+
40
+ return self::$instance;
41
+
42
+ }
43
+
44
+ /**
45
+ * The ajax handler.
46
+ */
47
+ public function ajax_handler() {
48
+
49
+ $this->email_type = isset( $_POST['email_type'] ) ? sanitize_text_field( $_POST['email_type'] ) : '';
50
+ $this->nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : '';
51
+
52
+ if ( ! $this->email_type ) {
53
+ wp_send_json_error( 'Email type is required', 'welcome-email-editor' );
54
+ }
55
+
56
+ if ( ! $this->nonce ) {
57
+ wp_send_json_error( 'Invalid nonce', 'welcome-email-editor' );
58
+ }
59
+
60
+ add_filter( 'weed_test_email_recipient', array( $this, 'set_testing_recipient' ) );
61
+
62
+ switch ( $this->email_type ) {
63
+ case 'admin_new_user_notif_email':
64
+ $this->admin_new_user_notif_email();
65
+ break;
66
+
67
+ case 'user_welcome_email':
68
+ $this->user_welcome_email();
69
+ break;
70
+
71
+ case 'reset_password_email':
72
+ $this->reset_password_email();
73
+ break;
74
+
75
+ default:
76
+ // code...
77
+ break;
78
+ }
79
+
80
+ remove_filter( 'weed_test_email_recipient', array( $this, 'set_testing_recipient' ) );
81
+
82
+ }
83
+
84
+ /**
85
+ * Test admin's welcome email.
86
+ */
87
+ public function admin_new_user_notif_email() {
88
+
89
+ $current_user = wp_get_current_user();
90
+
91
+ wp_new_user_notification( $current_user->ID, null, 'admin' );
92
+
93
+ wp_send_json_success( __( 'Email has been sent successfully', 'welome-email-editor' ) );
94
+
95
+ }
96
+
97
+ /**
98
+ * Test user's welcome email.
99
+ */
100
+ public function user_welcome_email() {
101
+
102
+ $current_user = wp_get_current_user();
103
+
104
+ wp_new_user_notification( $current_user->ID, null, 'user' );
105
+
106
+ wp_send_json_success( __( 'Email has been sent successfully', 'welome-email-editor' ) );
107
+
108
+ }
109
+
110
+ /**
111
+ * Test reset password email.
112
+ */
113
+ public function reset_password_email() {
114
+
115
+ $current_user = wp_get_current_user();
116
+
117
+ retrieve_password( $current_user->user_login );
118
+
119
+ wp_send_json_success( __( 'Email has been sent successfully', 'welome-email-editor' ) );
120
+
121
+ }
122
+
123
+ /**
124
+ * Set custom recipient for testing emails.
125
+ *
126
+ * @return string
127
+ */
128
+ public function set_testing_recipient() {
129
+
130
+ $current_user = wp_get_current_user();
131
+
132
+ return $current_user->user_email;
133
+
134
+ }
135
+
136
+ }
modules/settings/assets/css/settings.css ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @-webkit-keyframes loadingSpinAround {
2
+ from {
3
+ transform: rotate(0);
4
+ }
5
+ to {
6
+ transform: rotate(359deg);
7
+ }
8
+ }
9
+
10
+ @keyframes loadingSpinAround {
11
+ from {
12
+ transform: rotate(0);
13
+ }
14
+ to {
15
+ transform: rotate(359deg);
16
+ }
17
+ }
18
+
19
+ /* Button */
20
+ .button.weed-test-email-button {
21
+ display: flex;
22
+ position: relative;
23
+ align-items: center;
24
+ justify-content: center;
25
+ }
26
+
27
+ .weed-test-email-button.is-loading {
28
+ color: transparent !important;
29
+ pointer-events: none;
30
+ }
31
+
32
+ .weed-test-email-button.is-loading::after {
33
+ content: "";
34
+ position: absolute;
35
+ width: 1em;
36
+ display: block;
37
+ height: 1em;
38
+ border: 2px solid #dbdbdb;
39
+ /* border: 2px solid #814676; */
40
+ border-color: transparent transparent #fff #fff !important;
41
+ /* border-color: transparent transparent #9B5C8F #9B5C8F !important; */
42
+ border-radius: 290486px;
43
+ -webkit-animation: loadingSpinAround 0.5s infinite linear;
44
+ animation: loadingSpinAround 0.5s infinite linear;
45
+ }
46
+
47
+ /* Code Mirror */
48
+ .CodeMirror-wrap {
49
+ border: 1px solid #ddd;
50
+ }
51
+
52
+ /* Template tags metabox */
53
+ .weed-tags-metabox .tags-wrapper {
54
+ line-height: 1.8;
55
+ }
56
+
57
+ .weed-tags-metabox .heatbox-content p:last-child {
58
+ margin-bottom: 0;
59
+ }
60
+
61
+ /* Settings form */
62
+ .button.weed-reset-button {
63
+ margin-left: 7px;
64
+ color: #fff;
65
+ background-color: tomato;
66
+ border-color: tomato;
67
+ }
68
+
69
+ .button.weed-reset-button:hover,
70
+ .button.weed-reset-button:active,
71
+ .button.weed-reset-button:focus {
72
+ color: #fff;
73
+ background-color: #f5492a;
74
+ border-color: #f5492a;
75
+ }
76
+
77
+ .button.weed-reset-button:focus {
78
+ box-shadow: 0 0 0 1px #fff, 0 0 0 3px #f5492a
79
+ }
80
+
81
+ /* Featured */
82
+ .weed-featured-products > h2 {
83
+ text-align: center;
84
+ margin-bottom: 50px;
85
+ font-size: 24px;
86
+ }
87
+
88
+ .weed-featured-products .products {
89
+ display: flex;
90
+ justify-content: space-between;
91
+ }
92
+
93
+ .weed-featured-products .products li {
94
+ width: 32%;
95
+ }
96
+
97
+ .weed-featured-products .products .subheadline {
98
+ font-weight: 600;
99
+ margin-top: -6px;
100
+ }
101
+
102
+ .weed-featured-products .products img {
103
+ max-width: 100%;
104
+ }
105
+
106
+ .weed-featured-products .credit {
107
+ margin-top: 20px;
108
+ text-align: center;
109
+ opacity: 0.5;
110
+ }
111
+
112
+ /* Fields */
113
+ .weed-fields {
114
+ position: relative;
115
+ }
116
+
117
+ .weed-field {
118
+ margin-bottom: 15px;
119
+ }
120
+
121
+ .weed-inline-fields .weed-field:last-child {
122
+ margin-bottom: 0;
123
+ }
124
+
125
+ .weed-inline-fields {
126
+ display: flex;
127
+ position: relative;
128
+ }
129
+
130
+ .weed-inline-fields .weed-field {
131
+ margin-right: 10px;
132
+ }
133
+
134
+ .weed-inline-fields .weed-field:last-child {
135
+ margin-right: 0;
136
+ }
137
+
138
+ .weed-field .wp-picker-input-wrap .color-picker {
139
+ width: 160px !important;
140
+ }
141
+
142
+ .weed-field .wp-picker-input-wrap {
143
+ display: inline-flex;
144
+ max-width: 220px;
145
+ overflow: hidden;
146
+ transition: max-width 0.2s;
147
+ }
148
+
149
+ .weed-field .wp-picker-input-wrap.hidden {
150
+ display: inline-flex;
151
+ max-width: 0;
152
+ }
153
+
154
+ .weed-label {
155
+ display: block;
156
+ margin-bottom: 3px;
157
+ }
158
+
159
+ .is-hidden {
160
+ display: none;
161
+ }
162
+
163
+ @media screen and (max-width: 780px) {
164
+ .heatbox-header .logo-container .title,
165
+ .heatbox-header .logo-container .subtitle {
166
+ width: 100%;
167
+ }
168
+ }
modules/settings/assets/js/settings.js ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Settings.
3
+ *
4
+ * Used global objects:
5
+ * - ajaxurl
6
+ * - weedSettings
7
+ */
8
+ (function ($) {
9
+ var isRequesting = false;
10
+ var loading = {};
11
+
12
+ function init() {
13
+ $(document).on('click', '.weed-reset-settings-button', resetSettings);
14
+ $(document).on('click', '.weed-test-email-button', sendTestEmail);
15
+ }
16
+
17
+ /**
18
+ * Send test email via ajax request.
19
+ */
20
+ function resetSettings(e) {
21
+ if (!confirm(weedSettings.warningMessages.resetSettings)) e.preventDefault();
22
+ }
23
+
24
+ /**
25
+ * Send test email via ajax request.
26
+ */
27
+ function sendTestEmail(e) {
28
+ e.preventDefault();
29
+
30
+ var button = this;
31
+
32
+ if (isRequesting) return;
33
+ isRequesting = true;
34
+ loading.start(button);
35
+
36
+ var data = {};
37
+
38
+ data.email_type = this.dataset.emailType;
39
+ data.action = 'weed_test_emails'
40
+
41
+ switch (data.email_type) {
42
+ case 'admin_new_user_notif_email':
43
+ data.nonce = weedSettings.nonces.adminWelcomeEmail;
44
+ break;
45
+
46
+ case 'user_welcome_email':
47
+ data.nonce = weedSettings.nonces.userWelcomeEmail;
48
+ break;
49
+
50
+ case 'reset_password_email':
51
+ data.nonce = weedSettings.nonces.resetPasswordEmail;
52
+ break;
53
+ }
54
+
55
+ $.ajax({
56
+ url: ajaxurl,
57
+ type: 'post',
58
+ dataType: 'json',
59
+ data: data
60
+ }).done(function (r) {
61
+ //
62
+ }).fail(function () {
63
+ //
64
+ }).always(function () {
65
+ isRequesting = false;
66
+ loading.stop(button);
67
+ })
68
+ }
69
+
70
+ loading.start = function (button) {
71
+ button.classList.add('is-loading');
72
+ }
73
+
74
+ loading.stop = function (button) {
75
+ button.classList.remove('is-loading');
76
+ }
77
+
78
+ init();
79
+ })(jQuery);
modules/settings/class-settings-module.php ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Settings module setup.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed\Settings;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ use Weed\Vars;
13
+ use Weed\Base\Base_Module;
14
+
15
+ /**
16
+ * Class to setup quick view module.
17
+ */
18
+ class Settings_Module extends Base_Module {
19
+
20
+ /**
21
+ * The class instance.
22
+ *
23
+ * @var object
24
+ */
25
+ public static $instance;
26
+
27
+ /**
28
+ * The current module url.
29
+ *
30
+ * @var string
31
+ */
32
+ public $url;
33
+
34
+ /**
35
+ * Module constructor.
36
+ */
37
+ public function __construct() {
38
+
39
+ parent::__construct();
40
+
41
+ $this->url = WEED_PLUGIN_URL . '/modules/settings';
42
+
43
+ }
44
+
45
+ /**
46
+ * Get instance of the class.
47
+ */
48
+ public static function get_instance() {
49
+
50
+ if ( null === self::$instance ) {
51
+ self::$instance = new self();
52
+ }
53
+
54
+ return self::$instance;
55
+
56
+ }
57
+
58
+ /**
59
+ * Setup tool module.
60
+ */
61
+ public function setup() {
62
+
63
+ add_action( 'init', array( $this, 'set_plugin_priority' ) );
64
+
65
+ add_action( 'admin_menu', array( $this, 'submenu_page' ), 20 );
66
+ add_action( 'current_screen', array( $this, 'reset_settings' ) );
67
+ add_action( 'admin_init', array( $this, 'add_settings' ) );
68
+
69
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
70
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
71
+
72
+ // The module output.
73
+ require_once __DIR__ . '/class-settings-output.php';
74
+ Settings_Output::init();
75
+
76
+ $this->setup_ajax();
77
+
78
+ }
79
+
80
+ /**
81
+ * Setup ajax.
82
+ */
83
+ public function setup_ajax() {
84
+
85
+ require_once __DIR__ . '/ajax/class-test-emails.php';
86
+ add_action( 'wp_ajax_weed_test_emails', array( Ajax\Test_Emails::get_instance(), 'ajax_handler' ) );
87
+
88
+ }
89
+
90
+ /**
91
+ * Set our plugin as the first plugin priority.
92
+ */
93
+ public function set_plugin_priority() {
94
+
95
+ $active_plugins = get_option( 'active_plugins' );
96
+ $current_index = array_search( WEED_PLUGIN_BASENAME, $active_plugins, true );
97
+
98
+ // Stop if our plugin is already the first priority (index 0).
99
+ if ( ! $current_index ) {
100
+ return;
101
+ }
102
+
103
+ array_splice( $active_plugins, $current_index, 1 );
104
+ array_unshift( $active_plugins, WEED_PLUGIN_BASENAME );
105
+ update_option( 'active_plugins', $active_plugins );
106
+
107
+ }
108
+
109
+ /**
110
+ * Add submenu page.
111
+ */
112
+ public function submenu_page() {
113
+
114
+ add_submenu_page(
115
+ 'options-general.php',
116
+ __( 'Welcome Email Editor', 'welcome-email-editor' ),
117
+ __( 'Welcome Email Editor', 'welcome-email-editor' ),
118
+ apply_filters( 'weed_settings_capability', 'manage_options' ),
119
+ 'weed_settings',
120
+ array( $this, 'submenu_page_content' )
121
+ );
122
+
123
+ }
124
+
125
+ /**
126
+ * Submenu page content.
127
+ */
128
+ public function submenu_page_content() {
129
+
130
+ $template = require __DIR__ . '/templates/settings-template.php';
131
+ $template();
132
+
133
+ }
134
+
135
+ /**
136
+ * Enqueue admin styles.
137
+ */
138
+ public function admin_styles() {
139
+
140
+ if ( ! $this->screen()->is_settings() ) {
141
+ return;
142
+ }
143
+
144
+ wp_enqueue_style( 'heatbox', WEED_PLUGIN_URL . '/assets/css/heatbox.css', array(), WEED_PLUGIN_VERSION );
145
+ wp_enqueue_style( 'weed-admin', $this->url . '/assets/css/settings.css', array(), WEED_PLUGIN_VERSION );
146
+
147
+ }
148
+
149
+ /**
150
+ * Enqueue admin scripts.
151
+ */
152
+ public function admin_scripts() {
153
+
154
+ if ( ! $this->screen()->is_settings() ) {
155
+ return;
156
+ }
157
+
158
+ wp_enqueue_script( 'weed-settings', $this->url . '/assets/js/settings.js', array( 'jquery', 'wp-polyfill' ), WEED_PLUGIN_VERSION, true );
159
+
160
+ wp_localize_script(
161
+ 'weed-settings',
162
+ 'weedSettings',
163
+ array(
164
+ 'nonces' => array(
165
+ 'adminWelcomeEmail' => wp_create_nonce( WEED_PLUGIN_DIR . '_Admin_Welcome_Email' ),
166
+ 'userWelcomeEmail' => wp_create_nonce( WEED_PLUGIN_DIR . '_User_Welcome_Email' ),
167
+ 'resetPasswordEmail' => wp_create_nonce( WEED_PLUGIN_DIR . '_Reset_Password_Email' ),
168
+ ),
169
+ 'warningMessages' => array(
170
+ 'resetSettings' => __( 'Caution! Are you sure you want to reset all settings?', 'welcome-email-editor' ),
171
+ ),
172
+ )
173
+ );
174
+
175
+ }
176
+
177
+ /**
178
+ * Reset all settings.
179
+ */
180
+ public function reset_settings() {
181
+
182
+ if ( ! $this->screen()->is_settings() || ! isset( $_GET['action'] ) || ! isset( $_GET['nonce'] ) || ! isset( $_GET['http_referer'] ) ) {
183
+ return;
184
+ }
185
+
186
+ if ( 'weed_reset_settings' !== $_GET['action'] || ! wp_verify_nonce( $_GET['nonce'], WEED_PLUGIN_DIR ) ) {
187
+ return;
188
+ }
189
+
190
+ delete_option( 'weed_settings' );
191
+ wp_safe_redirect( $_GET['http_referer'] );
192
+
193
+ }
194
+
195
+ /**
196
+ * Add settings.
197
+ */
198
+ public function add_settings() {
199
+
200
+ // Register settings.
201
+ register_setting( 'weed-settings-group', 'weed_settings' );
202
+
203
+ // Register sections.
204
+ add_settings_section( 'weed-general-section', __( 'General Settings', 'welcome-email-editor' ), '', 'weed-general-settings' );
205
+ add_settings_section( 'weed-user-welcome-email-section', __( 'Welcome Email Settings &mdash; For User', 'welcome-email-editor' ), '', 'weed-user-welcome-email-settings' );
206
+ add_settings_section( 'weed-admin-new-user-notif-email-section', __( 'New User Notification Email Settings &mdash; For Admin', 'welcome-email-editor' ), '', 'weed-admin-new-user-notif-email-settings' );
207
+ add_settings_section( 'weed-reset-password-email-section', __( 'Reset Password Email Settings', 'welcome-email-editor' ), '', 'weed-reset-password-email-settings' );
208
+ add_settings_section( 'weed-misc-section', __( 'Misc. Settings', 'welcome-email-editor' ), '', 'weed-misc-settings' );
209
+
210
+ // General fields.
211
+ add_settings_field( 'from-email', __( 'From Email Address', 'welcome-email-editor' ), array( $this, 'from_email_field' ), 'weed-general-settings', 'weed-general-section' );
212
+ add_settings_field( 'from-name', __( 'From Name', 'welcome-email-editor' ), array( $this, 'from_name_field' ), 'weed-general-settings', 'weed-general-section' );
213
+ add_settings_field( 'content-type', __( 'Mail Content Type', 'welcome-email-editor' ), array( $this, 'content_type_field' ), 'weed-general-settings', 'weed-general-section' );
214
+
215
+ // User welcome email fields.
216
+ add_settings_field( 'user-welcome-email-subject', __( 'Email Subject', 'welcome-email-editor' ), array( $this, 'user_welcome_email_subject_field' ), 'weed-user-welcome-email-settings', 'weed-user-welcome-email-section' );
217
+ add_settings_field( 'user-welcome-email-body', __( 'Email Body', 'welcome-email-editor' ), array( $this, 'user_welcome_email_body_field' ), 'weed-user-welcome-email-settings', 'weed-user-welcome-email-section' );
218
+ add_settings_field( 'user-welcome-email-attachment', __( 'Email Attachment URL', 'welcome-email-editor' ), array( $this, 'user_welcome_email_attachment_field' ), 'weed-user-welcome-email-settings', 'weed-user-welcome-email-section' );
219
+ add_settings_field( 'user-welcome-email-reply-to-email', __( '"Reply-To" Email Address', 'welcome-email-editor' ), array( $this, 'user_welcome_email_reply_to_email_field' ), 'weed-user-welcome-email-settings', 'weed-user-welcome-email-section' );
220
+ add_settings_field( 'user-welcome-email-reply-to-name', __( '"Reply-To" Name', 'welcome-email-editor' ), array( $this, 'user_welcome_email_reply_to_name_field' ), 'weed-user-welcome-email-settings', 'weed-user-welcome-email-section' );
221
+ add_settings_field( 'user-welcome-email-additional-headers', __( 'Additional Email Headers', 'welcome-email-editor' ), array( $this, 'user_welcome_email_additional_headers_field' ), 'weed-user-welcome-email-settings', 'weed-user-welcome-email-section' );
222
+ add_settings_field( 'user-welcome-email-test', '', array( $this, 'user_welcome_email_test_field' ), 'weed-user-welcome-email-settings', 'weed-user-welcome-email-section' );
223
+
224
+ // Admin new user notification email fields.
225
+ add_settings_field( 'admin-new-user-notif-email-subject', __( 'Email Subject', 'welcome-email-editor' ), array( $this, 'admin_new_user_notif_email_subject_field' ), 'weed-admin-new-user-notif-email-settings', 'weed-admin-new-user-notif-email-section' );
226
+ add_settings_field( 'admin-new-user-notif-email-body', __( 'Email Body', 'welcome-email-editor' ), array( $this, 'admin_new_user_notif_email_body_field' ), 'weed-admin-new-user-notif-email-settings', 'weed-admin-new-user-notif-email-section' );
227
+ add_settings_field( 'admin-new-user-notif-email-recipients', __( 'Additional Recipients', 'welcome-email-editor' ), array( $this, 'admin_new_user_notif_email_custom_recipients_field' ), 'weed-admin-new-user-notif-email-settings', 'weed-admin-new-user-notif-email-section' );
228
+ add_settings_field( 'admin-new-user-notif-email-test', '', array( $this, 'admin_new_user_notif_email_test_field' ), 'weed-admin-new-user-notif-email-settings', 'weed-admin-new-user-notif-email-section' );
229
+
230
+ // Reset password email fields.
231
+ add_settings_field( 'reset-password-email-subject', __( 'Email Subject', 'welcome-email-editor' ), array( $this, 'reset_password_email_subject_field' ), 'weed-reset-password-email-settings', 'weed-reset-password-email-section' );
232
+ add_settings_field( 'reset-password-email-body', __( 'Email Body', 'welcome-email-editor' ), array( $this, 'reset_password_email_body_field' ), 'weed-reset-password-email-settings', 'weed-reset-password-email-section' );
233
+ add_settings_field( 'reset-password-email-test', '', array( $this, 'reset_password_email_test_field' ), 'weed-reset-password-email-settings', 'weed-reset-password-email-section' );
234
+
235
+ // Misc. settings.
236
+ add_settings_field( 'remove-on-uninstall', __( 'Remove on Uninstall', 'welcome-email-editor' ), array( $this, 'remove_on_uninstall_field' ), 'weed-misc-settings', 'weed-misc-section' );
237
+
238
+ }
239
+
240
+ /**
241
+ * From email field.
242
+ */
243
+ public function from_email_field() {
244
+
245
+ $field = require __DIR__ . '/templates/fields/general/from-email.php';
246
+ $field( $this );
247
+
248
+ }
249
+
250
+ /**
251
+ * From name field.
252
+ */
253
+ public function from_name_field() {
254
+
255
+ $field = require __DIR__ . '/templates/fields/general/from-name.php';
256
+ $field( $this );
257
+
258
+ }
259
+
260
+ /**
261
+ * Content type field.
262
+ */
263
+ public function content_type_field() {
264
+
265
+ $field = require __DIR__ . '/templates/fields/general/content-type.php';
266
+ $field( $this );
267
+
268
+ }
269
+
270
+ /**
271
+ * User welcome email's subject field.
272
+ */
273
+ public function user_welcome_email_subject_field() {
274
+
275
+ $field = require __DIR__ . '/templates/fields/user-welcome-email/subject.php';
276
+ $field( $this );
277
+
278
+ }
279
+
280
+ /**
281
+ * User welcome email's body field.
282
+ */
283
+ public function user_welcome_email_body_field() {
284
+
285
+ $field = require __DIR__ . '/templates/fields/user-welcome-email/body.php';
286
+ $field( $this );
287
+
288
+ }
289
+
290
+ /**
291
+ * User welcome email's attachment field.
292
+ */
293
+ public function user_welcome_email_attachment_field() {
294
+
295
+ $field = require __DIR__ . '/templates/fields/user-welcome-email/attachment.php';
296
+ $field( $this );
297
+
298
+ }
299
+
300
+ /**
301
+ * User welcome email's reply to email field.
302
+ */
303
+ public function user_welcome_email_reply_to_email_field() {
304
+
305
+ $field = require __DIR__ . '/templates/fields/user-welcome-email/reply-to-email.php';
306
+ $field( $this );
307
+
308
+ }
309
+
310
+ /**
311
+ * User welcome email's reply to name field.
312
+ */
313
+ public function user_welcome_email_reply_to_name_field() {
314
+
315
+ $field = require __DIR__ . '/templates/fields/user-welcome-email/reply-to-name.php';
316
+ $field( $this );
317
+
318
+ }
319
+
320
+ /**
321
+ * User welcome email's additional headers field.
322
+ */
323
+ public function user_welcome_email_additional_headers_field() {
324
+
325
+ $field = require __DIR__ . '/templates/fields/user-welcome-email/additional-headers.php';
326
+ $field( $this );
327
+
328
+ }
329
+
330
+ /**
331
+ * User welcome email's test field.
332
+ */
333
+ public function user_welcome_email_test_field() {
334
+
335
+ $field = require __DIR__ . '/templates/fields/user-welcome-email/test-button.php';
336
+ $field( $this );
337
+
338
+ }
339
+
340
+ /**
341
+ * Admin new user notification email's subject field.
342
+ */
343
+ public function admin_new_user_notif_email_subject_field() {
344
+
345
+ $field = require __DIR__ . '/templates/fields/admin-new-user-notif-email/subject.php';
346
+ $field( $this );
347
+
348
+ }
349
+
350
+ /**
351
+ * Admin new user notification email's body field.
352
+ */
353
+ public function admin_new_user_notif_email_body_field() {
354
+
355
+ $field = require __DIR__ . '/templates/fields/admin-new-user-notif-email/body.php';
356
+ $field( $this );
357
+
358
+ }
359
+
360
+ /**
361
+ * Admin new user notification email's body field.
362
+ */
363
+ public function admin_new_user_notif_email_custom_recipients_field() {
364
+
365
+ $field = require __DIR__ . '/templates/fields/admin-new-user-notif-email/custom-recipients.php';
366
+ $field( $this );
367
+
368
+ }
369
+
370
+ /**
371
+ * Admin new user notification email's test field.
372
+ */
373
+ public function admin_new_user_notif_email_test_field() {
374
+
375
+ $field = require __DIR__ . '/templates/fields/admin-new-user-notif-email/test-button.php';
376
+ $field( $this );
377
+
378
+ }
379
+
380
+ /**
381
+ * Reset password email's subject field.
382
+ */
383
+ public function reset_password_email_subject_field() {
384
+
385
+ $field = require __DIR__ . '/templates/fields/reset-password-email/subject.php';
386
+ $field( $this );
387
+
388
+ }
389
+
390
+ /**
391
+ * Reset password email's body field.
392
+ */
393
+ public function reset_password_email_body_field() {
394
+
395
+ $field = require __DIR__ . '/templates/fields/reset-password-email/body.php';
396
+ $field( $this );
397
+
398
+ }
399
+
400
+ /**
401
+ * Reset password email's test field.
402
+ */
403
+ public function reset_password_email_test_field() {
404
+
405
+ $field = require __DIR__ . '/templates/fields/reset-password-email/test-button.php';
406
+ $field( $this );
407
+
408
+ }
409
+
410
+ /**
411
+ * Remove data on uninstall field.
412
+ */
413
+ public function remove_on_uninstall_field() {
414
+
415
+ $field = require __DIR__ . '/templates/fields/misc/remove-on-uninstall.php';
416
+ $field( $this );
417
+
418
+ }
419
+
420
+ }
modules/settings/class-settings-output.php ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Settings module output.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ namespace Weed\Settings;
9
+
10
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
11
+
12
+ use Weed\Base\Base_Output;
13
+
14
+ /**
15
+ * Class to setup dashboard output.
16
+ */
17
+ class Settings_Output extends Base_Output {
18
+
19
+ /**
20
+ * The class instance.
21
+ *
22
+ * @var object
23
+ */
24
+ public static $instance;
25
+
26
+ /**
27
+ * The current module url.
28
+ *
29
+ * @var string
30
+ */
31
+ public $url;
32
+
33
+ /**
34
+ * Module constructor.
35
+ */
36
+ public function __construct() {
37
+
38
+ parent::__construct();
39
+
40
+ $this->url = WEED_PLUGIN_URL . '/modules/settings';
41
+
42
+ }
43
+
44
+ /**
45
+ * Get instance of the class.
46
+ */
47
+ public static function get_instance() {
48
+
49
+ if ( null === self::$instance ) {
50
+ self::$instance = new self();
51
+ }
52
+
53
+ return self::$instance;
54
+
55
+ }
56
+
57
+ /**
58
+ * Init the class setup.
59
+ */
60
+ public static function init() {
61
+
62
+ $class = new self();
63
+ $class->setup();
64
+
65
+ }
66
+
67
+ /**
68
+ * Setup settings output.
69
+ */
70
+ public function setup() {
71
+
72
+ add_filter( 'retrieve_password_title', array( $this, 'retrieve_password_title' ), 10, 3 );
73
+ add_filter( 'retrieve_password_message', array( $this, 'retrieve_password_message' ), 10, 4 );
74
+ add_filter( 'wpmu_welcome_user_notification', array( $this, 'wpmu_new_user_notification' ), 10, 3 );
75
+
76
+ /**
77
+ * Supporting https://s2member.com/ plugin.
78
+ * This support brought from the our plugin's old code.
79
+ *
80
+ * @see https://www.s2member.com/codex/stable/s2member/email_configs/package-filters/#src_doc_ws_plugin__s2member_after_email_config_release
81
+ */
82
+ add_action( 'ws_plugin__s2member_after_email_config_release', array( $this, 'set_email_from_headers' ) );
83
+
84
+ }
85
+
86
+ /**
87
+ * Retrieve password title.
88
+ *
89
+ * @see https://developer.wordpress.org/reference/hooks/retrieve_password_title/
90
+ *
91
+ * @param string $title Email subject.
92
+ * @param string $user_login The username for the user.
93
+ * @param WP_User $user_data WP_User object.
94
+ *
95
+ * @return string
96
+ */
97
+ public function retrieve_password_title( $title, $user_login, $user_data ) {
98
+
99
+ $saved_title = $this->values['reset_password_email_subject'];
100
+
101
+ if ( ! $saved_title ) {
102
+ return $title;
103
+ }
104
+
105
+ // The blogname option is escaped with esc_html() on the way into the database in sanitize_option().
106
+ // We want to reverse this for the plain text arena of emails.
107
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
108
+
109
+ $find = array(
110
+ '[blog_name]',
111
+ '[user_login]',
112
+ '[first_name]',
113
+ '[last_name]',
114
+ );
115
+
116
+ $replace = array(
117
+ $blogname,
118
+ $user_login,
119
+ $user_data->first_name,
120
+ $user_data->last_name,
121
+ );
122
+
123
+ $saved_title = str_ireplace( $find, $replace, $saved_title );
124
+
125
+ $this->set_email_headers();
126
+
127
+ return $saved_title;
128
+
129
+ }
130
+
131
+ /**
132
+ * Retrieve password message.
133
+ *
134
+ * @param string $message Email message.
135
+ * @param string $key The activation key.
136
+ * @param string $user_login The activation key.
137
+ * @param WP_User $user_data WP_User object.
138
+ *
139
+ * @return string
140
+ */
141
+ public function retrieve_password_message( $message, $key, $user_login, $user_data ) {
142
+
143
+ $saved_message = $this->values['reset_password_email_body'];
144
+
145
+ if ( ! $saved_message ) {
146
+ return $message;
147
+ }
148
+
149
+ $site_url = get_site_url();
150
+
151
+ // The blogname option is escaped with esc_html() on the way into the database in sanitize_option().
152
+ // We want to reverse this for the plain text arena of emails.
153
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
154
+
155
+ // $reset_url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
156
+ $reset_url = wp_login_url() . '?action=rp&key=' . $key . '&login=' . rawurlencode( $user_login );
157
+
158
+ $find = array(
159
+ '[blog_name]',
160
+ '[site_url]',
161
+ '[reset_url]',
162
+ '[user_login]',
163
+ '[first_name]',
164
+ '[last_name]',
165
+ );
166
+
167
+ $replace = array(
168
+ $blogname,
169
+ $site_url,
170
+ $reset_url,
171
+ $user_login,
172
+ $user_data->first_name,
173
+ $user_data->last_name,
174
+ );
175
+
176
+ $saved_message = str_ireplace( $find, $replace, $saved_message );
177
+
178
+ return $saved_message;
179
+
180
+ }
181
+
182
+ /**
183
+ * Filters whether to bypass the welcome email after user activation.
184
+ *
185
+ * Returning false disables the welcome email.
186
+ *
187
+ * @param int $user_id User ID.
188
+ * @param string $password User password.
189
+ * @param array $meta Signup meta data. Default empty array.
190
+ */
191
+ public function wpmu_new_user_notification( $user_id, $password, $meta = array() ) {
192
+
193
+ return wp_new_user_notification( $user_id, null, 'both' ); // @todo.. check this does something and fix.
194
+
195
+ }
196
+
197
+ /**
198
+ * Set email http headers but only the from_email and from_name.
199
+ */
200
+ public function set_email_from_headers() {
201
+
202
+ $values = $this->values;
203
+
204
+ if ( $values['from_email'] ) {
205
+ add_filter( 'wp_mail_from', array( $this, 'from_email' ) );
206
+ }
207
+
208
+ if ( $values['from_name'] ) {
209
+ add_filter( 'wp_mail_from_name', array( $this, 'from_name' ) );
210
+ }
211
+
212
+ }
213
+
214
+ /**
215
+ * Set email http headers.
216
+ */
217
+ public function set_email_headers() {
218
+
219
+ $values = $this->values;
220
+
221
+ if ( $values['from_email'] ) {
222
+ add_filter( 'wp_mail_from', array( $this, 'from_email' ) );
223
+ }
224
+
225
+ if ( $values['from_name'] ) {
226
+ add_filter( 'wp_mail_from_name', array( $this, 'from_name' ) );
227
+ }
228
+
229
+ if ( 'html' === $values['content_type'] ) {
230
+ add_filter( 'wp_mail_content_type', array( $this, 'html_content_type' ) );
231
+ add_filter( 'wp_mail_charset', array( $this, 'charset' ) );
232
+ }
233
+
234
+ }
235
+
236
+ /**
237
+ * Reset email http headers.
238
+ *
239
+ * @return void
240
+ */
241
+ public function reset_email_headers() {
242
+
243
+ $values = $this->values;
244
+
245
+ if ( $values['from_email'] ) {
246
+ remove_filter( 'wp_mail_from', array( $this, 'from_email' ) );
247
+ }
248
+
249
+ if ( $values['from_name'] ) {
250
+ remove_filter( 'wp_mail_from_name', array( $this, 'from_name' ) );
251
+ }
252
+
253
+ if ( 'html' === $values['content_type'] ) {
254
+ remove_filter( 'wp_mail_content_type', array( $this, 'html_content_type' ) );
255
+ remove_filter( 'wp_mail_charset', array( $this, 'charset' ) );
256
+ }
257
+
258
+ }
259
+
260
+ /**
261
+ * Implement from to http header.
262
+ *
263
+ * @param string $from_email Email address to send from.
264
+ */
265
+ public function from_email( $from_email ) {
266
+
267
+ $values = $this->values;
268
+
269
+ if ( ! $values['from_email'] ) {
270
+ return $from_email;
271
+ }
272
+
273
+ if ( ! apply_filters( 'weed_use_from_email', true ) ) {
274
+ return $from_email;
275
+ }
276
+
277
+ $admin_email = get_option( 'admin_email' );
278
+
279
+ $find = array(
280
+ '[admin_email]',
281
+ );
282
+
283
+ $replace = array(
284
+ $admin_email,
285
+ );
286
+
287
+ $from_email = str_ireplace( $find, $replace, $values['from_email'] );
288
+
289
+ return $from_email;
290
+
291
+ }
292
+
293
+ /**
294
+ * Implement from to http header.
295
+ *
296
+ * @param string $from_name Name associated with the "from" email address.
297
+ */
298
+ public function from_name( $from_name ) {
299
+
300
+ $values = $this->values;
301
+
302
+ if ( ! $values['from_name'] ) {
303
+ return $from_name;
304
+ }
305
+
306
+ if ( ! apply_filters( 'weed_use_from_name', true ) ) {
307
+ return $from_name;
308
+ }
309
+
310
+ $admin_email = get_option( 'admin_email' );
311
+
312
+ $find = array(
313
+ '[admin_email]',
314
+ );
315
+
316
+ $replace = array(
317
+ $admin_email,
318
+ );
319
+
320
+ $from_name = str_ireplace( $find, $replace, $values['from_name'] );
321
+
322
+ return $from_name;
323
+
324
+ }
325
+
326
+ /**
327
+ * Set content type header to text/html.
328
+ *
329
+ * @param string $content_type The current content type.
330
+ */
331
+ public function html_content_type( $content_type ) {
332
+
333
+ return 'text/html';
334
+
335
+ }
336
+
337
+ /**
338
+ * Set charset.
339
+ *
340
+ * @param string $charset The current charset.
341
+ */
342
+ public function charset( $charset ) {
343
+
344
+ return get_bloginfo( 'charset' );
345
+
346
+ }
347
+
348
+ }
modules/settings/templates/fields/admin-new-user-notif-email/body.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin new user notification email's body field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting admin new user notification email's body field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $settings = $module->settings;
19
+ $values = $module->values;
20
+ ?>
21
+
22
+ <textarea name="weed_settings[admin_new_user_notif_email_body]" id="weed_settings--admin_new_user_notif_email_body" class="large-text" rows="8" placeholder="<?php echo esc_attr( $defaults['admin_new_user_notif_email_body'] ); ?>"><?php echo esc_html( $values['admin_new_user_notif_email_body'] ); ?></textarea>
23
+
24
+ <?php
25
+
26
+ };
modules/settings/templates/fields/admin-new-user-notif-email/custom-recipients.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin new user notification email's custom recipient field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting admin new user notification email's custom recipient field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <input type="text" name="weed_settings[admin_new_user_notif_email_custom_recipients]" id="weed_settings--admin_new_user_notif_email_custom_recipients" class="regular-text" value="<?php echo esc_attr( $values['admin_new_user_notif_email_custom_recipients'] ); ?>" placeholder="<?php echo esc_attr( $defaults['admin_new_user_notif_email_custom_recipients'] ); ?>" />
22
+
23
+ <p class="description">
24
+ <?php _e( 'Add additional recipients to receive the notification email when new user is registered. Add a comma separated list of user ID\'s (eg: 1,2,3,4).', 'welcome-email-editor' ); ?>
25
+ </p>
26
+ <p class="description">
27
+ <?php echo sprintf( __( 'By default, this email is sent only to the admin email (%1s).', 'welcome-email-editor' ), get_option( 'admin_email' ) ); ?>
28
+ </p>
29
+
30
+ <?php
31
+
32
+ };
modules/settings/templates/fields/admin-new-user-notif-email/subject.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin new user notification email's subject field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting admin new user notification email's subject field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <input type="text" name="weed_settings[admin_new_user_notif_email_subject]" id="weed_settings--admin_new_user_notif_email_subject" class="regular-text" value="<?php echo esc_attr( $values['admin_new_user_notif_email_subject'] ); ?>" placeholder="<?php echo esc_attr( $defaults['admin_new_user_notif_email_subject'] ); ?>" />
22
+
23
+ <?php
24
+
25
+ };
modules/settings/templates/fields/admin-new-user-notif-email/test-button.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's test button field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's test button field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <button type="button" class="button button-primary weed-test-email-button" data-email-type="admin_new_user_notif_email">
22
+ <?php _e( 'Send a test email for current user (save first!)', 'welcome-email-editor' ); ?>
23
+ </button>
24
+
25
+ <?php
26
+
27
+ };
modules/settings/templates/fields/general/content-type.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Content type field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting content type field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $values = $module->values;
18
+ ?>
19
+
20
+ <select name="weed_settings[content_type]" id="weed_settings--content_type" class="regular-text">
21
+ <option value="html" <?php selected( $values['content_type'], 'html' ); ?>><?php _e( 'HTML', 'welcome-email-editor' ); ?></option>
22
+ <option value="text" <?php selected( $values['content_type'], 'text' ); ?>><?php _e( 'Plain Text', 'welcome-email-editor' ); ?></option>
23
+ </select>
24
+
25
+ <?php
26
+
27
+ };
modules/settings/templates/fields/general/from-email.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * From email field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting from email field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $values = $module->values;
18
+
19
+ $placeholder = site_url();
20
+ $placeholder = rtrim( $placeholder, '/' );
21
+ $placeholder = str_ireplace( 'https://', '', $placeholder );
22
+ $placeholder = str_ireplace( 'http://', '', $placeholder );
23
+ $placeholder = str_ireplace( 'www.', '', $placeholder );
24
+ $placeholder = 'wordpress@' . $placeholder;
25
+ ?>
26
+
27
+ <input type="text" name="weed_settings[from_email]" id="weed_settings--from_email" class="regular-text" value="<?php echo esc_attr( $values['from_email'] ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" />
28
+
29
+ <?php
30
+
31
+ };
modules/settings/templates/fields/general/from-name.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * From name field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting from name field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <input type="text" name="weed_settings[from_name]" id="weed_settings--from_name" class="regular-text" value="<?php echo esc_attr( $values['from_name'] ); ?>" placeholder="WordPress" />
22
+
23
+ <?php
24
+
25
+ };
modules/settings/templates/fields/misc/remove-on-uninstall.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Remove on uninstall field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ return function ( $module ) {
11
+
12
+ $settings = $module->settings;
13
+ $is_checked = isset( $settings['remove_on_uninstall'] ) ? 1 : 0;
14
+ ?>
15
+
16
+ <label for="weed_settings[remove_on_uninstall]" class="label checkbox-label">
17
+ &nbsp;
18
+ <input type="checkbox" name="weed_settings[remove_on_uninstall]" id="weed_settings[remove_on_uninstall]" value="1" <?php checked( $is_checked, 1 ); ?>>
19
+ <div class="indicator"></div>
20
+ </label>
21
+
22
+ <?php
23
+
24
+ };
modules/settings/templates/fields/reset-password-email/body.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Reset password email's body field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting reset password email's body field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <textarea name="weed_settings[reset_password_email_body]" id="weed_settings--reset_password_email_body" class="large-text" rows="8" placeholder="<?php echo esc_attr( $defaults['reset_password_email_body'] ); ?>"><?php echo esc_html( $values['reset_password_email_body'] ); ?></textarea>
22
+
23
+ <?php
24
+
25
+ };
modules/settings/templates/fields/reset-password-email/subject.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Reset password email's subject field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting reset password email's subject field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <input type="text" name="weed_settings[reset_password_email_subject]" id="weed_settings--reset_password_email_subject" class="regular-text" value="<?php echo esc_attr( $values['reset_password_email_subject'] ); ?>" placeholder="<?php echo esc_attr( $defaults['reset_password_email_subject'] ); ?>" />
22
+
23
+ <?php
24
+
25
+ };
modules/settings/templates/fields/reset-password-email/test-button.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's test button field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's test button field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <button type="button" class="button button-primary weed-test-email-button" data-email-type="reset_password_email">
22
+ <?php _e( 'Send a test email for current user (save first!)', 'welcome-email-editor' ); ?>
23
+ </button>
24
+
25
+ <?php
26
+
27
+ };
modules/settings/templates/fields/user-welcome-email/additional-headers.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's additional headers field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's additional_headers field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <textarea name="weed_settings[user_welcome_email_additional_headers]" id="weed_settings--user_welcome_email_additional_headers" class="regular-text" rows="5" placeholder="<?php echo esc_attr( $defaults['user_welcome_email_additional_headers'] ); ?>"><?php echo esc_html( $values['user_welcome_email_additional_headers'] ); ?></textarea>
22
+
23
+ <p class="description">
24
+ <?php _e( 'Add custom http header string for your email sending. E.g:', 'welcome-email-editor' ); ?>
25
+ <br>
26
+ <code>Content-Type: text/plain</code>
27
+ <br>
28
+ <?php _e( 'If you would like to add multiple headers, then add them in multi lines format.', 'welcome-email-editor' ); ?>
29
+ </p>
30
+
31
+ <?php
32
+
33
+ };
modules/settings/templates/fields/user-welcome-email/attachment.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's attachment field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's attachment field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <input type="url" name="weed_settings[user_welcome_email_attachment_url]" id="weed_settings--user_welcome_email_attachment_url" class="regular-text" value="<?php echo esc_attr( $values['user_welcome_email_attachment_url'] ); ?>" placeholder="<?php echo esc_attr( $defaults['user_welcome_email_attachment_url'] ); ?>" />
22
+
23
+ <p class="description">
24
+ <?php _e( 'If you want the welcome email to have an attachment then put the URL here.', 'welcome-email-editor' ); ?>
25
+ </p>
26
+
27
+ <?php
28
+
29
+ };
modules/settings/templates/fields/user-welcome-email/body.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's body field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's body field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <textarea name="weed_settings[user_welcome_email_body]" id="weed_settings--user_welcome_email_body" class="large-text" rows="8" placeholder="<?php echo esc_attr( $defaults['user_welcome_email_body'] ); ?>"><?php echo esc_html( $values['user_welcome_email_body'] ); ?></textarea>
22
+
23
+ <?php
24
+
25
+ };
modules/settings/templates/fields/user-welcome-email/reply-to-email.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's reply to email field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's reply to field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <input type="text" name="weed_settings[user_welcome_email_reply_to_email]" id="weed_settings--user_welcome_email_reply_to_email" class="regular-text" value="<?php echo esc_attr( $values['user_welcome_email_reply_to_email'] ); ?>" placeholder="<?php echo esc_attr( $defaults['user_welcome_email_reply_to_email'] ); ?>" />
22
+
23
+ <?php
24
+
25
+ };
modules/settings/templates/fields/user-welcome-email/reply-to-name.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's reply to name field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's reply to field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <input type="text" name="weed_settings[user_welcome_email_reply_to_name]" id="weed_settings--user_welcome_email_reply_to_name" class="regular-text" value="<?php echo esc_attr( $values['user_welcome_email_reply_to_name'] ); ?>" placeholder="<?php echo esc_attr( $defaults['user_welcome_email_reply_to_name'] ); ?>" />
22
+
23
+ <?php
24
+
25
+ };
modules/settings/templates/fields/user-welcome-email/subject.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's subject field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's subject field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <input type="text" name="weed_settings[user_welcome_email_subject]" id="weed_settings--user_welcome_email_subject" class="regular-text" value="<?php echo esc_attr( $values['user_welcome_email_subject'] ); ?>" placeholder="<?php echo esc_attr( $defaults['user_welcome_email_subject'] ); ?>" />
22
+
23
+ <?php
24
+
25
+ };
modules/settings/templates/fields/user-welcome-email/test-button.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * User welcome email's test button field.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ /**
11
+ * Outputting user welcome email's test button field.
12
+ *
13
+ * @param Settings_Module $module The Settings_Module instance.
14
+ */
15
+ return function ( $module ) {
16
+
17
+ $defaults = $module->defaults;
18
+ $values = $module->values;
19
+ ?>
20
+
21
+ <button type="button" class="button button-primary weed-test-email-button" data-email-type="user_welcome_email">
22
+ <?php _e( 'Send a test email for current user (save first!)', 'welcome-email-editor' ); ?>
23
+ </button>
24
+
25
+ <?php
26
+
27
+ };
modules/settings/templates/settings-template.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Settings page template.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
9
+
10
+ return function () {
11
+ ?>
12
+
13
+ <div class="wrap heatbox-wrap weed-settings-page">
14
+
15
+ <div class="heatbox-header heatbox-margin-bottom">
16
+
17
+ <div class="heatbox-container heatbox-container-center">
18
+
19
+ <div class="logo-container">
20
+
21
+ <div>
22
+ <span class="title">
23
+ <?php _e( 'Welcome Email Editor', 'welcome-email-editor' ); ?>
24
+ <span class="version"><?php echo esc_html( WEED_PLUGIN_VERSION ); ?></span>
25
+ </span>
26
+ <p class="subtitle"><?php _e( 'Change WordPress\' Welcome & Reset Password Emails', 'welcome-email-editor' ); ?></p>
27
+ </div>
28
+
29
+ <div>
30
+ <img src="<?php echo esc_url( WEED_PLUGIN_URL ); ?>/assets/images/welcome-email-editor-logo.png">
31
+ </div>
32
+
33
+ </div>
34
+
35
+ </div>
36
+
37
+ </div>
38
+
39
+ <div class="heatbox-container heatbox-container-center heatbox-column-container">
40
+
41
+ <div class="heatbox-main">
42
+ <!-- Faking H1 tag to place admin notices -->
43
+ <h1 style="display: none;"></h1>
44
+
45
+ <form method="post" action="options.php" class="weed-settings-form">
46
+
47
+ <?php settings_fields( 'weed-settings-group' ); ?>
48
+
49
+ <div class="heatbox">
50
+ <?php do_settings_sections( 'weed-general-settings' ); ?>
51
+ </div>
52
+
53
+ <div class="heatbox">
54
+ <?php do_settings_sections( 'weed-user-welcome-email-settings' ); ?>
55
+ </div>
56
+
57
+ <div class="heatbox">
58
+ <?php do_settings_sections( 'weed-admin-new-user-notif-email-settings' ); ?>
59
+ </div>
60
+
61
+ <div class="heatbox">
62
+ <?php do_settings_sections( 'weed-reset-password-email-settings' ); ?>
63
+ </div>
64
+
65
+ <div class="heatbox">
66
+ <?php do_settings_sections( 'weed-misc-settings' ); ?>
67
+ </div>
68
+
69
+ <div class="udb-buttons">
70
+ <?php
71
+ submit_button( '', 'button button-primary button-larger', 'submit', false );
72
+
73
+ $current_url = site_url() . $_SERVER['REQUEST_URI'];
74
+
75
+ $reset_settings_url = add_query_arg(
76
+ array(
77
+ 'action' => 'weed_reset_settings',
78
+ 'nonce' => wp_create_nonce( WEED_PLUGIN_DIR ),
79
+ 'http_referer' => $current_url,
80
+ ),
81
+ $current_url
82
+ );
83
+ ?>
84
+
85
+ <a href="<?php echo esc_url( $reset_settings_url ); ?>" class="button button-larger weed-reset-button weed-reset-settings-button">
86
+ <?php _e( 'Reset Settings', 'welcome-email-editor' ); ?>
87
+ </a>
88
+ </div>
89
+
90
+ </form>
91
+ </div>
92
+
93
+ <div class="heatbox-sidebar">
94
+ <div class="heatbox weed-tags-metabox">
95
+ <h2><?php _e( 'Template Tags', 'welome-email-editor' ); ?></h2>
96
+ <div class="heatbox-content">
97
+ <p><?php _e( 'Use the template tags below in any fields to output certain information.', 'welcome-email-editor' ); ?></p>
98
+ <p class="tags-wrapper">
99
+ <code>[site_url]</code>, <code>[login_url]</code>, <code>[reset_pass_url]</code>, <code>[user_email]</code>, <code>[user_login]</code>, <code>[user_id]</code>, <code>[first_name]</code>, <code>[last_name]</code>, <code>[blog_name]</code>, <code>[admin_email]</code>, <code>[custom_fields]</code>, <code>[date]</code>, <code>[time]</code>
100
+ </p>
101
+ </div>
102
+ </div>
103
+
104
+ <?php if ( defined( 'BP_PLUGIN_URL' ) ) : ?>
105
+ <div class="heatbox weed-tags-metabox">
106
+ <h2><?php _e( 'BuddyPress Template Tags', 'welome-email-editor' ); ?></h2>
107
+ <div class="heatbox-content">
108
+ <p><?php _e( 'Use the template tag below in your <strong>Admin Email</strong>.', 'welcome-email-editor' ); ?></p>
109
+ <p><?php _e( 'This will print BuddyPress custom fields.', 'welcome-email-editor' ); ?></p>
110
+ <p class="tags-wrapper">
111
+ <code>[bp_custom_fields]</code>
112
+ </p>
113
+ </div>
114
+ </div>
115
+ <?php endif; ?>
116
+
117
+ <div class="heatbox weed-tags-metabox">
118
+ <h2><?php _e( 'Debugging', 'welome-email-editor' ); ?></h2>
119
+ <div class="heatbox-content">
120
+ <p><?php _e( 'Use the template tag below in your <strong>Admin Email</strong> for debugging.', 'welcome-email-editor' ); ?></p>
121
+ <p><?php _e( 'This will print $_REQUEST.', 'welcome-email-editor' ); ?></p>
122
+ <p class="tags-wrapper">
123
+ <code>[post_data]</code>
124
+ </p>
125
+ </div>
126
+ </div>
127
+ </div>
128
+
129
+ </div>
130
+
131
+ <div class="heatbox-container heatbox-container-wide heatbox-container-center weed-featured-products">
132
+ <div class="heatbox-divider"></div>
133
+
134
+ <h2><?php _e( 'Check out our other free WordPress products!', 'welcome-email-editor' ); ?></h2>
135
+
136
+ <ul class="products">
137
+ <li class="heatbox">
138
+ <a href="https://wordpress.org/plugins/swift-control/" target="_blank">
139
+ <img src="<?php echo esc_url( WEED_PLUGIN_URL ); ?>/assets/images/swift-control.jpg">
140
+ </a>
141
+ <div class="heatbox-content">
142
+ <h3><?php _e( 'WP Swift Control', 'welcome-email-editor' ); ?></h3>
143
+ <p class="subheadline"><?php _e( 'Replace the boring WordPress Admin Bar with this!', 'welcome-email-editor' ); ?></p>
144
+ <p><?php _e( 'Swift Control is the plugin that make your clients love WordPress. It drastically improves the user experience when working with WordPress and allows you to replace the boring WordPress admin bar with your own navigation panel.', 'welcome-email-editor' ); ?></p>
145
+ <a href="https://wordpress.org/plugins/swift-control/" target="_blank" class="button"><?php _e( 'View Features', 'welcome-email-editor' ); ?></a>
146
+ </div>
147
+ </li>
148
+ <li class="heatbox">
149
+ <a href="https://wordpress.org/plugins/ultimate-dashboard/" target="_blank">
150
+ <img src="<?php echo esc_url( WEED_PLUGIN_URL ); ?>/assets/images/ultimate-dashboard.jpg">
151
+ </a>
152
+ <div class="heatbox-content">
153
+ <h3><?php _e( 'Ultimate Dashboard', 'welcome-email-editor' ); ?></h3>
154
+ <p class="subheadline"><?php _e( 'The #1 plugin to customize your WordPress dashboard.', 'welcome-email-editor' ); ?></p>
155
+ <p><?php _e( 'Ultimate Dashboard is a clean & lightweight plugin that was made to optimize the user experience for clients inside the WordPress admin area.', 'welcome-email-editor' ); ?></p>
156
+ <a href="https://wordpress.org/plugins/ultimate-dashboard/" target="_blank" class="button"><?php _e( 'View Features', 'welcome-email-editor' ); ?></a>
157
+ </div>
158
+ </li>
159
+ <li class="heatbox">
160
+ <a href="https://wordpress.org/plugins/responsive-youtube-vimeo-popup/" target="_blank">
161
+ <img src="<?php echo esc_url( WEED_PLUGIN_URL ); ?>/assets/images/page-builder-framework.jpg">
162
+ </a>
163
+ <div class="heatbox-content">
164
+ <h3><?php _e( 'Page Builder Framework', 'welcome-email-editor' ); ?></h3>
165
+ <p class="subheadline"><?php _e( 'A modern, fast & minimalistic theme designed for the new WordPress Era.', 'welcome-email-editor' ); ?></p>
166
+ <p><?php _e( 'The theme was designed specifically to work with WordPress page builders, like Elementor, Beaver Builder & Brizy.', 'welcome-email-editor' ); ?></p>
167
+ <a href="https://wordpress.org/themes/page-builder-framework/" target="_blank" class="button"><?php _e( 'View Features', 'welcome-email-editor' ); ?></a>
168
+ </div>
169
+ </li>
170
+ </ul>
171
+
172
+ <p class="credit"><?php _e( 'Made with ❤ in Aschaffenburg, Germany', 'welcome-email-editor' ); ?></p>
173
+
174
+ </div>
175
+
176
+ </div>
177
+
178
+ <?php
179
+ };
readme.txt ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Welcome Email Editor ===
2
+ Contributors: davidvongries, seanbarton
3
+ Tags: welcome email, wordpress welcome email, welcome email editor, mail, email, new user email, password reminder, lost password, welcome email attachment, mail attachment, email attachment
4
+ Requires at least: 4.9
5
+ Tested up to: 5.7
6
+ Stable tag: 5.0
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ == Description ==
11
+ **Welcome Email Editor** is a clean, simple & lightweight plugin which allows you to **change the default WordPress Welcome & Forgot Password emails**.
12
+
13
+ Whenever a user is added to a website, WordPress sends a notification to the site admin & the user that was added (or signed up) to the website. This plugin allows you to customize those emails.
14
+
15
+ = Change the WordPress Welcome Emails =
16
+ The Welcome Email Editor plugin allows you to change the default welcome emails for both, the user & site administrator individually.
17
+
18
+ * Change the email subject
19
+ * Change the email content
20
+ * Add an attachment
21
+ * Change "Reply-To" email address
22
+ * & more
23
+
24
+ = Change the WordPress Forgot Password emails =
25
+ Welcome Email Editor also allows you to change the default **Forgot Password** email in WordPress.
26
+
27
+ * Change the email subject
28
+ * Change the email content
29
+
30
+ = General Settings =
31
+ In addition to the settings above, there are general settings which will apply to the welcome & forgot password emails.
32
+
33
+ * Change *From Email* address
34
+ * Change *From Name*
35
+ * Change Content Type from Plain Text to HTML
36
+
37
+ = What's next? =
38
+ If you like Welcome Email Editor, make sure to check out our other products:
39
+
40
+ * **[Ultimate Dashboard](https://ultimatedashboard.io/?utm_source=weed&utm_medium=repository&utm_campaign=udb)** - The #1 WordPress plugin to customize your WordPress dashboard and admin area.
41
+ * **[Page Builder Framework](https://wp-pagebuilderframework.com/?utm_source=weed&utm_medium=repository&utm_campaign=wpbf)** - A fast & minimalistic WordPress theme designed for the new WordPress era.
42
+ * **[WP Swift Control](https://wpswiftcontrol.com/?utm_source=weed&utm_medium=repository&utm_campaign=swiftcontrol)** - The plugin to make your clients enjoy WordPress. It replaces the default admin bar to provide the best possible user experience when editing & navigating a website.
43
+
44
+ == Installation ==
45
+ 1. Download the welcome-email-editor.zip file to your computer.
46
+ 1. Unzip the file.
47
+ 1. Upload the `welcome-email-editor` folder to your `/wp-content/plugins/` directory.
48
+ 1. Activate the plugin through the *Plugins* menu in WordPress.
49
+
50
+ == Frequently Asked Questions ==
51
+ = Why is the password not included in the welcome email? =
52
+ Since version 4.3 the password is no longer sent to the user via email and instead a reset password link is sent instead. This was a controversial decision but it was done for good reason.
53
+
54
+ == Screenshots ==
55
+ 1. Welcome Email Editor Settings Page
56
+
57
+ == Changelog ==
58
+ = 5.0 | May 22, 2021 =
59
+ * Hey there, David here :) We have taken over the Welcome Email Editor project from our friend Sean Barton. This is our initial release - Apart from some minor improvements, no new features were added. With this release we have reviewed & rewritten the codebase from ground up and greatly improved the settings page design. Stay tuned for more.
sb_welcome_email_editor.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Welcome Email Editor
4
+ * Description: Welcome Email Editor allows you to change the default WordPress welcome & reset password emails.
5
+ * Version: 5.0
6
+ * Author: David Vongries
7
+ * Author URI: https://ultimatedashboard.com
8
+ * Text Domain: welcome-email-editor
9
+ *
10
+ * @package Welcome_Email_Editor
11
+ */
12
+
13
+ defined( 'ABSPATH' ) || die( "Can't access directly" );
14
+
15
+ // Plugin constants.
16
+ define( 'WEED_PLUGIN_DIR', rtrim( plugin_dir_path( __FILE__ ), '/' ) );
17
+ define( 'WEED_PLUGIN_URL', rtrim( plugin_dir_url( __FILE__ ), '/' ) );
18
+ define( 'WEED_PLUGIN_VERSION', '5.0' );
19
+ define( 'WEED_PLUGIN_NAME', 'Welome Email Editor' );
20
+ define( 'WEED_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
21
+
22
+ // Helper classes.
23
+ require __DIR__ . '/helpers/class-screen-helper.php';
24
+ require __DIR__ . '/helpers/class-content-helper.php';
25
+ require __DIR__ . '/helpers/class-email-helper.php';
26
+
27
+ // Base module.
28
+ require __DIR__ . '/modules/base/class-base-module.php';
29
+ require __DIR__ . '/modules/base/class-base-output.php';
30
+
31
+ // Core classes.
32
+ require __DIR__ . '/class-backwards-compatibility.php';
33
+ require __DIR__ . '/class-vars.php';
34
+ require __DIR__ . '/wp-new-user-notification.php';
35
+ require __DIR__ . '/class-setup.php';
36
+
37
+ Weed\Backwards_Compatibility::init();
38
+ Weed\Setup::init();
wp-new-user-notification.php ADDED
@@ -0,0 +1,381 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Replace wp_new_user_notification pluggable function.
4
+ *
5
+ * @package Welcome_Email_Editor
6
+ */
7
+
8
+ use Weed\Vars;
9
+ use Weed\Helpers\Content_Helper;
10
+ use Weed\Helpers\Email_Helper;
11
+ use Weed\Settings\Settings_Output;
12
+
13
+ if ( ! function_exists( 'wp_new_user_notification' ) ) {
14
+
15
+ /**
16
+ * Email login credentials to a newly-registered user.
17
+ *
18
+ * A new user registration notification is also sent to admin email.
19
+ *
20
+ * @see https://developer.wordpress.org/reference/functions/wp_new_user_notification/
21
+ * @see wp-includes/pluggable.php
22
+ *
23
+ * @since 2.0.0
24
+ * @since 4.3.0 The `$plaintext_pass` parameter was changed to `$notify`.
25
+ * @since 4.3.1 The `$plaintext_pass` parameter was deprecated. `$notify` added as a third parameter.
26
+ * @since 4.6.0 The `$notify` parameter accepts 'user' for sending notification only to the user created.
27
+ *
28
+ * @param int $user_id User ID.
29
+ * @param null $deprecated Not used (argument deprecated).
30
+ * @param string $notify Optional. Type of notification that should happen. Accepts 'admin' or an empty
31
+ * string (admin only), 'user', or 'both' (admin and user). Default empty.
32
+ */
33
+ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
34
+
35
+ if ( null !== $deprecated ) {
36
+ _deprecated_argument( __FUNCTION__, '4.3.1' );
37
+ }
38
+
39
+ // Accepts only 'user', 'admin' , 'both' or default '' as $notify.
40
+ if ( ! in_array( $notify, array( 'user', 'admin', 'both', '' ), true ) ) {
41
+ return;
42
+ }
43
+
44
+ $user = get_userdata( $user_id );
45
+
46
+ $values = Vars::get( 'values' );
47
+
48
+ $content_helper = new Content_Helper();
49
+ $email_helper = new Email_Helper();
50
+ $module_output = Settings_Output::get_instance();
51
+
52
+ $module_output->set_email_headers();
53
+
54
+ // The blogname option is escaped with esc_html() on the way into the database in sanitize_option().
55
+ // We want to reverse this for the plain text arena of emails.
56
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
57
+
58
+ $current_date = date_i18n( get_option( 'date_format' ) );
59
+ $current_time = date_i18n( get_option( 'time_format' ) );
60
+ $admin_email = get_option( 'admin_email' );
61
+ $custom_fields = $content_helper->get_user_custom_fields( $user_id );
62
+
63
+ $headers = $email_helper->get_extra_headers();
64
+
65
+ if ( 'user' !== $notify ) {
66
+ $switched_locale = switch_to_locale( get_locale() );
67
+
68
+ $default_admin_subject = __( '[%s] New User Registration' );
69
+
70
+ $admin_subject_placeholders = array(
71
+ '[blog_name]',
72
+ '[site_url]',
73
+ '[first_name]',
74
+ '[last_name]',
75
+ '[user_email]',
76
+ '[user_login]',
77
+ '[user_id]',
78
+ '[date]',
79
+ '[time]',
80
+ );
81
+
82
+ $admin_subject_values = array(
83
+ $blogname,
84
+ network_site_url(),
85
+ $user->first_name,
86
+ $user->last_name,
87
+ $user->user_email,
88
+ $user->user_login,
89
+ $user->ID,
90
+ $current_date,
91
+ $current_time,
92
+ );
93
+
94
+ $admin_subject = $values['admin_new_user_notif_email_subject'];
95
+ $admin_subject = $admin_subject ? $admin_subject : $default_admin_subject;
96
+ $admin_subject = str_ireplace( $admin_subject_placeholders, $admin_subject_values, $admin_subject );
97
+ $admin_subject = apply_filters( 'weed_user_welcome_email_subject', $admin_subject );
98
+
99
+ $admin_body_placeholders = array(
100
+ '[blog_name]',
101
+ '[site_url]',
102
+ '[first_name]',
103
+ '[last_name]',
104
+ '[user_email]',
105
+ '[user_login]',
106
+ '[user_id]',
107
+ '[date]',
108
+ '[time]',
109
+ '[admin_email]',
110
+ '[login_url]',
111
+ '[reset_pass_url]',
112
+ '[plaintext_password]',
113
+ '[user_password]',
114
+ '[custom_fields]',
115
+ '[bp_custom_fields]',
116
+ '[post_data]',
117
+ );
118
+
119
+ $admin_body_values = array(
120
+ $blogname,
121
+ network_site_url(),
122
+ $user->first_name,
123
+ $user->last_name,
124
+ $user->user_email,
125
+ $user->user_login,
126
+ $user->ID,
127
+ $current_date,
128
+ $current_time,
129
+ $admin_email,
130
+ wp_login_url(),
131
+ wp_login_url(),
132
+ '*****',
133
+ '*****',
134
+ '<pre>' . print_r( $custom_fields, true ) . '</pre>', // ! Not recommended.
135
+ '<pre>' . print_r( $_REQUEST, true ) . '</pre>', // ! Not recommended.
136
+ );
137
+
138
+ /* translators: %s: Site title. */
139
+ $default_admin_body = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
140
+ /* translators: %s: User login. */
141
+ $default_admin_body .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
142
+ /* translators: %s: User email address. */
143
+ $default_admin_body .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
144
+
145
+ $admin_body = $values['admin_new_user_notif_email_body'];
146
+ $admin_body = $admin_body ? $admin_body : $default_admin_body;
147
+ $admin_body = str_ireplace( $admin_body_placeholders, $admin_body_values, $admin_body );
148
+
149
+ if ( stripos( $admin_body, '[bp_custom_fields]' ) ) {
150
+ if ( defined( 'BP_PLUGIN_URL' ) ) {
151
+ $admin_body = str_replace(
152
+ '[bp_custom_fields]',
153
+ '<pre>' . print_r( $content_helper->get_bp_user_custom_fields( $user_id ), true ) . '</pre>',
154
+ $admin_body
155
+ );
156
+ }
157
+ }
158
+
159
+ $admin_body = apply_filters( 'weed_user_welcome_email_body', $admin_body );
160
+
161
+ $wp_new_user_notification_email_admin = array(
162
+ 'to' => get_option( 'admin_email' ),
163
+ /* translators: New user registration notification email subject. %s: Site title. */
164
+ 'subject' => $admin_subject,
165
+ 'message' => $admin_body,
166
+ 'headers' => ! empty( $headers ) ? $headers : '',
167
+ );
168
+
169
+ /**
170
+ * Filters the contents of the new user notification email sent to the site admin.
171
+ *
172
+ * @param array $wp_new_user_notification_email_admin {
173
+ * Used to build wp_mail().
174
+ *
175
+ * @type string $to The intended recipient - site admin email address.
176
+ * @type string $subject The subject of the email.
177
+ * @type string $message The body of the email.
178
+ * @type string $headers The headers of the email.
179
+ * }
180
+ * @param WP_User $user User object for new user.
181
+ * @param string $blogname The site title.
182
+ */
183
+ $wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname );
184
+
185
+ $custom_recipient_emails = array();
186
+
187
+ $custom_recipients = $values['admin_new_user_notif_email_custom_recipients'];
188
+ $custom_recipients = trim( $custom_recipients );
189
+ $custom_recipients = rtrim( $custom_recipients, ',' ); // Make sure there's no trailing comma to prevent double commas.
190
+
191
+ if ( ! empty( $custom_recipients ) ) {
192
+ $custom_recipients = $custom_recipients . ','; // Let's add a trailing comma for the explode.
193
+ $custom_recipients = explode( ',', $custom_recipients );
194
+
195
+ foreach ( $custom_recipients as $custom_recipient ) {
196
+ $custom_recipient = trim( $custom_recipient );
197
+
198
+ if ( ! empty( $custom_recipient ) ) {
199
+ // Let's keep this checking separately, think about future possibility if would add custom recipient(s) as email string.
200
+ if ( is_numeric( $custom_recipient ) ) {
201
+ $custom_recipient = absint( $custom_recipient );
202
+
203
+ $custom_recipient_user = get_userdata( $custom_recipient );
204
+
205
+ if ( $custom_recipient_user ) {
206
+ // Prevent the email from being sent twice to admin_email.
207
+ if ( $custom_recipient_user->user_email !== $admin_email ) {
208
+ array_push( $custom_recipient_emails, $custom_recipient_user->user_email );
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+
216
+ $testing_recipient = apply_filters( 'weed_test_email_recipient', '' );
217
+
218
+ wp_mail(
219
+ ( ! empty( $testing_recipient ) ? $testing_recipient : $wp_new_user_notification_email_admin['to'] ),
220
+ wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ),
221
+ $wp_new_user_notification_email_admin['message'],
222
+ $wp_new_user_notification_email_admin['headers']
223
+ );
224
+
225
+ if ( empty( $testing_recipient ) ) {
226
+ foreach ( $custom_recipient_emails as $custom_recipient_email ) {
227
+ wp_mail(
228
+ $custom_recipient_email,
229
+ wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ),
230
+ $wp_new_user_notification_email_admin['message'],
231
+ $wp_new_user_notification_email_admin['headers']
232
+ );
233
+ }
234
+ }
235
+
236
+ if ( $switched_locale ) {
237
+ restore_previous_locale();
238
+ }
239
+ }
240
+
241
+ // `$deprecated` was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification.
242
+ if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {
243
+ return;
244
+ }
245
+
246
+ $key = get_password_reset_key( $user );
247
+
248
+ if ( is_wp_error( $key ) ) {
249
+ return;
250
+ }
251
+
252
+ $switched_locale = switch_to_locale( get_user_locale( $user ) );
253
+
254
+ $reset_pass_url = network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' );
255
+
256
+ $default_user_subject = __( '[%s] Login Details' );
257
+
258
+ $user_subject_placeholders = array(
259
+ '[blog_name]',
260
+ '[site_url]',
261
+ '[first_name]',
262
+ '[last_name]',
263
+ '[user_email]',
264
+ '[user_login]',
265
+ '[user_id]',
266
+ '[date]',
267
+ '[time]',
268
+ );
269
+
270
+ $user_subject_values = array(
271
+ $blogname,
272
+ network_site_url(),
273
+ $user->first_name,
274
+ $user->last_name,
275
+ $user->user_email,
276
+ $user->user_login,
277
+ $user->ID,
278
+ $current_date,
279
+ $current_time,
280
+ );
281
+
282
+ $user_subject = $values['user_welcome_email_subject'];
283
+ $user_subject = $user_subject ? $user_subject : $default_user_subject;
284
+ $user_subject = str_ireplace( $user_subject_placeholders, $user_subject_values, $user_subject );
285
+ $user_subject = apply_filters( 'weed_user_welcome_email_subject', $user_subject );
286
+
287
+ /* translators: %s: User login. */
288
+ $default_user_body = sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
289
+ $default_user_body .= __( 'To set your password, visit the following address:' ) . "\r\n\r\n";
290
+ $default_user_body .= $reset_pass_url . "\r\n\r\n";
291
+ $default_user_body .= wp_login_url() . "\r\n";
292
+
293
+ $user_body_placeholders = array(
294
+ '[blog_name]',
295
+ '[site_url]',
296
+ '[first_name]',
297
+ '[last_name]',
298
+ '[user_email]',
299
+ '[user_login]',
300
+ '[user_id]',
301
+ '[date]',
302
+ '[time]',
303
+ '[admin_email]',
304
+ '[login_url]',
305
+ '[reset_pass_url]',
306
+ '[reset_pass_link]',
307
+ '[plaintext_password]',
308
+ '[user_password]',
309
+ );
310
+
311
+ $user_body_values = array(
312
+ $blogname,
313
+ network_site_url(),
314
+ $user->first_name,
315
+ $user->last_name,
316
+ $user->user_email,
317
+ $user->user_login,
318
+ $user->ID,
319
+ $current_date,
320
+ $current_time,
321
+ $admin_email,
322
+ wp_login_url(),
323
+ $reset_pass_url,
324
+ '<a href="' . $reset_pass_url . '" target="_blank">' . __( 'Click to set', 'welome-email-editor' ) . '</a>',
325
+ '*****',
326
+ '*****',
327
+ );
328
+
329
+ $user_body = $values['user_welcome_email_body'];
330
+ $user_body = $user_body ? $user_body : $default_user_body;
331
+ $user_body = str_ireplace( $user_body_placeholders, $user_body_values, $user_body );
332
+
333
+ $wp_new_user_notification_email = array(
334
+ 'to' => $user->user_email,
335
+ /* translators: Login details notification email subject. %s: Site title. */
336
+ 'subject' => $user_subject,
337
+ 'message' => $user_body,
338
+ 'headers' => ! empty( $headers ) ? $headers : '',
339
+ );
340
+
341
+ /**
342
+ * Filters the contents of the new user notification email sent to the new user.
343
+ *
344
+ * This comment was taken from wp-includes/pluggable.php inside wp_new_user_notification() function.
345
+ *
346
+ * @param array $wp_new_user_notification_email {
347
+ * Used to build wp_mail().
348
+ *
349
+ * @type string $to The intended recipient - New user email address.
350
+ * @type string $subject The subject of the email.
351
+ * @type string $message The body of the email.
352
+ * @type string $headers The headers of the email.
353
+ * }
354
+ * @param WP_User $user User object for new user.
355
+ * @param string $blogname The site title.
356
+ */
357
+ $wp_new_user_notification_email = apply_filters( 'wp_new_user_notification_email', $wp_new_user_notification_email, $user, $blogname );
358
+
359
+ $attachment = $values['user_welcome_email_attachment_url'];
360
+ $attachment = trim( $attachment );
361
+ $attachment = empty( $attachment ) ? '' : $attachment;
362
+
363
+ if ( ! empty( $attachment ) ) {
364
+ $attachment = str_replace( trailingslashit( site_url() ), trailingslashit( $_SERVER['DOCUMENT_ROOT'] ), $attachment );
365
+ }
366
+
367
+ wp_mail(
368
+ $wp_new_user_notification_email['to'],
369
+ wp_specialchars_decode( sprintf( $wp_new_user_notification_email['subject'], $blogname ) ),
370
+ $wp_new_user_notification_email['message'],
371
+ $wp_new_user_notification_email['headers'],
372
+ $attachment
373
+ );
374
+
375
+ if ( $switched_locale ) {
376
+ restore_previous_locale();
377
+ }
378
+
379
+ $module_output->reset_email_headers();
380
+ }
381
+ }