PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.5.2
EmailKit – Email Customizer for WooCommerce & WP v1.5.2
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / includes / Admin / Emails / WordPress / NewUserRegister.php

NewUserRegister.php in EmailKit – Email Customizer for WooCommerce & WP 1.5.2, at includes/Admin/Emails/WordPress/NewUserRegister.php

77 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace EmailKit\Admin\Emails\WordPress;
4
5 use WP_Query;
6 use EmailKit\Admin\Emails\EmailLists;
7
8 defined( 'ABSPATH' ) || exit;
9
10 class NewUserRegister {
11
12 private $db_query_class = null;
13
14 public function __construct() {
15
16 $args = array(
17 'post_type' => 'emailkit',
18 'meta_query' => array(
19 array(
20 'key' => 'emailkit_template_type',
21 'value' => EmailLists::WP_NEW_REGISTER,
22 ),
23 array(
24 'key' => 'emailkit_template_status',
25 'value' => 'Active',
26 ),
27 ),
28 );
29
30 $this->db_query_class = new WP_Query($args);
31 if (isset($this->db_query_class->posts[0])) {
32
33 add_filter('wp_new_user_notification_email', [$this, 'newUserMail'], 10, 3);
34 }
35 }
36
37
38 public function newUserMail($new_user_notification_email, $user, $blogname)
39 {
40
41 $query = $this->db_query_class;
42 $key = get_password_reset_key($user);
43
44 $recipient_email = $user->user_email;
45
46 $details = [
47 "{{app_name}}" => $blogname,
48 "{{reset_url}}" => network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login'),
49 "{{display_name}}" => $user->display_name,
50 "{{user_url}}" => $user->user_url,
51 "{{user_email}}" => $recipient_email,
52 ];
53
54 $new_user_notification_email['from'] = get_option('admin_email');
55 if (isset($query->posts[0])) {
56 $new_user_notification_email['message'] = str_replace(array_keys($details), array_values($details), apply_filters('emailkit_shortcode_filter', get_post_meta($query->posts[0]->ID, 'emailkit_template_content_html', true)));
57 }
58
59 $pre_header = get_post_meta($query->posts[0]->ID, 'emailkit_email_preheader', true);
60 $pre_header = !empty( $pre_header) ? $pre_header : esc_html__('user registration', 'emailkit');
61 $new_user_notification_email['subject'] = str_replace(array_keys($details), array_values($details), get_post_meta($query->posts[0]->ID, 'emailkit_email_subject', true));
62 $new_user_notification_email['subject'] = !empty( $new_user_notification_email['subject']) ? $new_user_notification_email['subject'] . ' - ' . $pre_header : esc_html__(' Welcome! New User Added to', 'emailkit') . ' ' . $blogname . ' - ' . $pre_header;
63
64
65
66 $new_user_notification_email['headers'] = [
67 'From: ' . $blogname . ' <' . $new_user_notification_email['from'] . "> \r\n",
68 'Reply-To: <' . $new_user_notification_email['from'],
69 'Content-Type: text/html; charset=UTF-8',
70 ];
71
72 $new_user_notification_email['to'] = $recipient_email;
73
74 return $new_user_notification_email;
75 }
76
77 }