PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / features / email-customizer / user-email-customizer.php

user-email-customizer.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at features/email-customizer/user-email-customizer.php

376 lines 17.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 /**
6 * Function that creates the User Email Customizer menu
7 *
8 * @since v.2.0
9 *
10 * @return void
11 */
12 function wppb_user_email_customizer_submenu(){
13 $args = array(
14 'menu_title' => __( 'User Email Customizer', 'profile-builder' ),
15 'page_title' => __( 'User Email Customizer Settings', 'profile-builder' ),
16 'menu_slug' => 'user-email-customizer',
17 'page_type' => 'submenu_page',
18 'capability' => 'manage_options',
19 'priority' => 10,
20 'parent_slug' => 'profile-builder'
21 );
22
23 new WCK_Page_Creator_PB( $args );
24 }
25 add_action( 'admin_menu', 'wppb_user_email_customizer_submenu', 1 );
26
27 add_action( 'wck_before_meta_boxes', 'wppb_add_tabs_on_top_of_user_email_page' );
28 function wppb_add_tabs_on_top_of_user_email_page( $hookname ){
29 if( $hookname == 'profile-builder_page_user-email-customizer' ){
30
31 if( isset( $_GET['mustache_action'] ) && $_GET['mustache_action'] == 'save' ) { ?>
32 <div id="setting-error-settings_updated" class="updated settings-error notice">
33 <p><strong><?php esc_html_e( "Settings saved.", 'profile-builder' ); ?></strong></p>
34 </div>
35 <?php
36 }
37
38 wppb_generate_settings_tabs();
39 }
40 }
41
42 /* on the init hook add the mustache boxes */
43 add_action( 'init', 'wppb_user_email_customizer_add_mustache_in_backend', 11 );
44 /**
45 * Function that ads the mustache boxes in the backend for user email customizer
46 *
47 * @since v.2.0
48 */
49 function wppb_user_email_customizer_add_mustache_in_backend(){
50 if( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ) )
51 require_once( WPPB_PAID_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' );
52 elseif( file_exists( WPPB_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ) )
53 require_once( WPPB_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' );
54
55 $fields = array(
56 array(
57 'id' => 'wppb_admin_emailc_common_settings_header', // field id and name
58 'type' => 'header', // type of field
59 'default' => __( 'These settings are also replicated in the "Admin Email Customizer" settings-page upon save.', 'profile-builder' ).' '.__( 'Valid tags {{reply_to}} and {{site_name}}', 'profile-builder'), // type of field
60 ),
61 array(
62 'label' => __( 'From (name)', 'profile-builder' ), // <label>
63 'desc' => '', // description
64 'id' => 'wppb_emailc_common_settings_from_name', // field id and name
65 'type' => 'text', // type of field
66 'default' => '{{site_name}}', // type of field
67 'desc' => '',
68 ),
69 array(
70 'label' => __( 'From (reply-to email)', 'profile-builder' ), // <label>
71 'desc' => '', // description
72 'id' => 'wppb_emailc_common_settings_from_reply_to_email', // field id and name
73 'type' => 'text', // type of field
74 'default' => '{{reply_to}}', // type of field
75 'desc' => __( 'Must be a valid email address or the tag {{reply_to}} which defaults to the administrator email', 'profile-builder' ),
76 ),
77 );
78 new PB_Mustache_Generate_Admin_Box( 'uec_common_settings', __( 'Common Settings', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', '', '', $fields );
79
80 /*
81 * Default Registration
82 */
83
84 // we format the var like this for proper line breaks.
85 $uec_default_registration = __("<h3>Welcome to {{site_name}}!</h3>\n<p>Your username is: {{username}}</p>\n", 'profile-builder' );
86 $mustache_vars = wppb_email_customizer_generate_merge_tags();
87 $fields = array(
88 array(
89 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
90 'desc' => '', // description
91 'id' => 'wppb_user_emailc_default_registration_email_subject', // field id and name
92 'type' => 'text', // type of field
93 'default' => 'A new account has been created for you on {{site_name}}', // type of field
94 ),
95 array(
96 'label' => __( 'Enable email', 'profile-builder' ), // <label>
97 'desc' => '', // description
98 'id' => 'wppb_user_emailc_default_registration_email_enabled', // field id and name
99 'type' => 'checkbox', // type of field
100 'default' => 'on',
101 ),
102 array( // Textarea
103 'label' => '', // <label>
104 'desc' => '', // description
105 'id' => 'wppb_user_emailc_default_registration_email_content', // field id and name
106 'type' => 'textarea', // type of field
107 'default' => $uec_default_registration, // type of field
108 )
109 );
110 new PB_Mustache_Generate_Admin_Box( 'uec_default_registration', __( 'Default Registration', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
111
112 /*
113 * Registration with Email Confirmation
114 */
115 // we format the var like this for proper line breaks.
116 $uec_reg_with_email_confirm = __( "<p>To activate your user, please click the following link:<br/>\n{{{activation_link}}}</p>\n<p>After you activate, you will receive another email with your credentials.</p>\n", 'profile-builder' );
117 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'email_confirmation' );
118 $fields = array(
119 array(
120 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
121 'desc' => '', // description
122 'id' => 'wppb_user_emailc_registr_w_email_confirm_email_subject', // field id and name
123 'type' => 'text', // type of field
124 'default' => __( '[{{site_name}}] Activate {{username}}', 'profile-builder' ), // type of field
125 ),
126 array(
127 'label' => __( 'Enable email', 'profile-builder' ), // <label>
128 'desc' => '', // description
129 'id' => 'wppb_user_emailc_registr_w_email_confirm_email_enabled', // field id and name
130 'type' => 'checkbox', // type of field
131 'default' => 'on',
132 ),
133 array( // Textarea
134 'label' => '', // <label>
135 'desc' => '', // description
136 'id' => 'wppb_user_emailc_registr_w_email_confirm_email_content', // field id and name
137 'type' => 'textarea', // type of field
138 'default' => $uec_reg_with_email_confirm, // type of field
139 )
140 );
141
142 new PB_Mustache_Generate_Admin_Box( 'uec_reg_with_email_confirmation', __( 'Registration with Email Confirmation', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
143
144 if( PROFILE_BUILDER != 'Profile Builder Free' ){
145
146 /*
147 * Registration with Admin Approval
148 */
149
150 $uec_reg_with_admin_approval = __( "<h3>Welcome to {{site_name}}!</h3>\n<p>Your username is: {{username}}</p>\n<p>Before you can access your account, an administrator needs to approve it. You will be notified via email.</p>\n", 'profile-builder' );
151 $mustache_vars = wppb_email_customizer_generate_merge_tags();
152 $fields = array(
153 array(
154 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
155 'desc' => '', // description
156 'id' => 'wppb_user_emailc_registration_with_admin_approval_email_subject', // field id and name
157 'type' => 'text', // type of field
158 'default' => __( 'A new account has been created for you on {{site_name}}', 'profile-builder' ), // type of field
159 ),
160 array(
161 'label' => __( 'Enable email', 'profile-builder' ), // <label>
162 'desc' => '', // description
163 'id' => 'wppb_user_emailc_registration_with_admin_approval_email_enabled', // field id and name
164 'type' => 'checkbox', // type of field
165 'default' => 'on',
166 ),
167 array( // Textarea
168 'label' => '', // <label>
169 'desc' => '', // description
170 'id' => 'wppb_user_emailc_registration_with_admin_approval_email_content', // field id and name
171 'type' => 'textarea', // type of field
172 'default' => $uec_reg_with_admin_approval, // type of field
173 )
174 );
175
176 new PB_Mustache_Generate_Admin_Box( 'uec_reg_with_admin_approval', __( 'Registration with Admin Approval', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
177
178 /*
179 * Admin Approval Notifications ( on user approval )
180 */
181 $uec_notif_approved_email = __( "<h3>Good News!</h3>\n<p>An administrator has just approved your account: {{username}} on {{site_name}}.</p>\n", 'profile-builder' );
182 $mustache_vars = wppb_email_customizer_generate_merge_tags();
183 $fields = array(
184 array(
185 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
186 'desc' => '', // description
187 'id' => 'wppb_user_emailc_admin_approval_notif_approved_email_subject', // field id and name
188 'type' => 'text', // type of field
189 'default' => __( 'Your account on {{site_name}} has been approved!', 'profile-builder' ), // type of field
190 ),
191 array(
192 'label' => __( 'Enable email', 'profile-builder' ), // <label>
193 'desc' => '', // description
194 'id' => 'wppb_user_emailc_admin_approval_notif_approved_email_enabled', // field id and name
195 'type' => 'checkbox', // type of field
196 'default' => 'on',
197 ),
198 array( // Textarea
199 'label' => '', // <label>
200 'desc' => '', // description
201 'id' => 'wppb_user_emailc_admin_approval_notif_approved_email_content', // field id and name
202 'type' => 'textarea', // type of field
203 'default' => $uec_notif_approved_email, // type of field
204 )
205 );
206
207 new PB_Mustache_Generate_Admin_Box( 'uec_notif_approved_email', __( 'User Approval Notification', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
208
209 /*
210 * Admin Approval Notifications ( on user unapproval )
211 */
212 $uec_notif_unapproved_email = __( "<h3>Hello,</h3>\n<p>Unfortunatelly an administrator has just unapproved your account: {{username}} on {{site_name}}.</p>\n", 'profile-builder' );
213 $mustache_vars = wppb_email_customizer_generate_merge_tags();
214 $fields = array(
215 array(
216 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
217 'desc' => '', // description
218 'id' => 'wppb_user_emailc_admin_approval_notif_unapproved_email_subject', // field id and name
219 'type' => 'text', // type of field
220 'default' => __( 'Your account on {{site_name}} has been unapproved!', 'profile-builder' ), // type of field
221 ),
222 array(
223 'label' => __( 'Enable email', 'profile-builder' ), // <label>
224 'desc' => '', // description
225 'id' => 'wppb_user_emailc_admin_approval_notif_unapproved_email_enabled', // field id and name
226 'type' => 'checkbox', // type of field
227 'default' => 'on',
228 ),
229 array( // Textarea
230 'label' => '', // <label>
231 'desc' => '', // description
232 'id' => 'wppb_user_emailc_admin_approval_notif_unapproved_email_content', // field id and name
233 'type' => 'textarea', // type of field
234 'default' => $uec_notif_unapproved_email , // type of field
235 )
236 );
237
238 new PB_Mustache_Generate_Admin_Box( 'uec_notif_unapproved_email', __( 'Unapproved User Notification', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
239
240 }
241
242
243 /*
244 * Password Reset Email
245 */
246 // we format the var like this for proper line breaks.
247 $uec_reset = __( "<p>Someone requested that the password be reset for the following account: {{site_name}}<br/>\nUsername: {{username}}</p>\n<p>If this was a mistake, just ignore this email and nothing will happen.</p>\n<p>To reset your password, visit the following address:<br/>\n{{{reset_link}}}</p>\n", 'profile-builder' );
248 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'password_reset' );
249 $fields = array(
250 array(
251 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
252 'desc' => '', // description
253 'id' => 'wppb_user_emailc_reset_email_subject', // field id and name
254 'type' => 'text', // type of field
255 'default' => __( '[{{site_name}}] Password Reset', 'profile-builder' ), // type of field
256 ),
257 array(
258 'label' => __( 'Enable email', 'profile-builder' ), // <label>
259 'desc' => '', // description
260 'id' => 'wppb_user_emailc_reset_email_enabled', // field id and name
261 'type' => 'checkbox', // type of field
262 'default' => 'on',
263 ),
264 array( // Textarea
265 'label' => '', // <label>
266 'desc' => '', // description
267 'id' => 'wppb_user_emailc_reset_email_content', // field id and name
268 'type' => 'textarea', // type of field
269 'default' => $uec_reset, // type of field
270 )
271 );
272
273 new PB_Mustache_Generate_Admin_Box( 'uec_reset', __( 'Password Reset Email', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
274
275 /*
276 * Password Reset Success Email
277 */
278 // we format the var like this for proper line breaks.
279 $uec_reset_success = __( "<p>You have successfully reset your password.</p>\n", 'profile-builder' );
280 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'password_reset_success' );
281 $fields = array(
282 array(
283 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
284 'desc' => '', // description
285 'id' => 'wppb_user_emailc_reset_success_email_subject', // field id and name
286 'type' => 'text', // type of field
287 'default' => __( '[{{site_name}}] Password Reset Successfully', 'profile-builder' ), // type of field
288 ),
289 array(
290 'label' => __( 'Enable email', 'profile-builder' ), // <label>
291 'desc' => '', // description
292 'id' => 'wppb_user_emailc_reset_success_email_enabled', // field id and name
293 'type' => 'checkbox', // type of field
294 'default' => 'on',
295 ),
296 array( // Textarea
297 'label' => '', // <label>
298 'desc' => '', // description
299 'id' => 'wppb_user_emailc_reset_success_email_content', // field id and name
300 'type' => 'textarea', // type of field
301 'default' => $uec_reset_success, // type of field
302 )
303 );
304
305 new PB_Mustache_Generate_Admin_Box( 'uec_reset_success', __( 'Password Reset Success Email', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
306
307 /*
308 * Change Email Address Request Notification
309 */
310 $admin_email = get_option('admin_email');
311
312 // we format the var like this for proper line breaks.
313 $uec_change_email_request = sprintf( __( "<h3>Hi {{username}},</h3>\n<p>There is an email address change request on {{site_name}}.</p>\n<p>To change your email address click on: {{{user_email_change_link}}}</p>\n<p>Regards,<br>\nAll at {{site_name}}<br>\n<a href=\"{{site_url}}\">{{site_url}}</a></p>", 'profile-builder' ), $admin_email );
314 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'change_email_address_request' );
315 $fields = array(
316 array(
317 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
318 'desc' => '', // description
319 'id' => 'wppb_user_emailc_change_email_address_request_subject', // field id and name
320 'type' => 'text', // type of field
321 'default' => __( '[{{site_name}}] Notice of Email Change Request', 'profile-builder' ), // type of field
322 ),
323 array(
324 'label' => __( 'Enable email', 'profile-builder' ), // <label>
325 'desc' => '', // description
326 'id' => 'wppb_user_emailc_change_email_address_request_enabled', // field id and name
327 'type' => 'checkbox', // type of field
328 'default' => 'on',
329 ),
330 array( // Textarea
331 'label' => '', // <label>
332 'desc' => '', // description
333 'id' => 'wppb_user_emailc_change_email_address_request_content', // field id and name
334 'type' => 'textarea', // type of field
335 'default' => $uec_change_email_request, // type of field
336 )
337 );
338
339 new PB_Mustache_Generate_Admin_Box( 'uec_change_email_request', __( 'Change Email Address Request Email', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
340
341 /*
342 * Change Email Address Notification
343 */
344 $admin_email = get_option('admin_email');
345
346 // we format the var like this for proper line breaks.
347 $uec_change_email = sprintf( __( "<h3>Hi {{username}},</h3>\n<p>This notice confirms that your email was changed on {{site_name}}.</p>\n<p>If you did not change your email, please contact the Site Administrator at %s</p>\n<p>This email has been sent to {{user_email}}</p>\n<p>Regards,<br>\nAll at {{site_name}}<br>\n<a href=\"{{site_url}}\">{{site_url}}</a></p>", 'profile-builder' ), $admin_email );
348 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'change_email_address' );
349 $fields = array(
350 array(
351 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
352 'desc' => '', // description
353 'id' => 'wppb_user_emailc_change_email_address_subject', // field id and name
354 'type' => 'text', // type of field
355 'default' => __( '[{{site_name}}] Notice of Email Change', 'profile-builder' ), // type of field
356 ),
357 array(
358 'label' => __( 'Enable email', 'profile-builder' ), // <label>
359 'desc' => '', // description
360 'id' => 'wppb_user_emailc_change_email_address_enabled', // field id and name
361 'type' => 'checkbox', // type of field
362 'default' => 'on',
363 ),
364 array( // Textarea
365 'label' => '', // <label>
366 'desc' => '', // description
367 'id' => 'wppb_user_emailc_change_email_address_content', // field id and name
368 'type' => 'textarea', // type of field
369 'default' => $uec_change_email, // type of field
370 )
371 );
372
373 new PB_Mustache_Generate_Admin_Box( 'uec_change_email', __( 'Changed Email Address Notification', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
374
375 }
376