PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.12.3
WpStream – Live Streaming, Video on Demand, Pay Per View v4.12.3
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / hello-wpstream / framework / email-functions.php

email-functions.php in WpStream – Live Streaming, Video on Demand, Pay Per View 4.12.3, at hello-wpstream/framework/email-functions.php

170 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Email functions
4 *
5 * @package wpstream-theme
6 */
7
8 if ( ! function_exists( 'wpstream_theme_return_sending_email' ) ) {
9 /**
10 * Return sending email
11 */
12 function wpstream_theme_return_sending_email() {
13 $from_email = 'noreply@changeme.net';
14 $name_email = 'changeME';
15
16 return $name_email . ' <' . $from_email . '>';
17 }
18 }
19
20
21 if ( ! function_exists( 'wpstream_theme_send_emails' ) ) {
22 /**
23 * Send emails.
24 *
25 * @param string $user_email The email address of the recipient.
26 * @param string $subject The subject of the email.
27 * @param string $message The message content of the email.
28 * @param string $email_type The type of the email (text or HTML).
29 * @param string $reply_to The reply-to email address.
30 * @param string|array $extra_headers Extra headers to include in the email.
31 */
32 function wpstream_theme_send_emails( $user_email, $subject, $message, $email_type, $reply_to = '', $extra_headers = '' ) {
33 if ( '' === $reply_to ) {
34 $reply_to = wpstream_theme_return_sending_email();
35 }
36
37 $headers = 'From: ' . wpstream_theme_return_sending_email() . "\r\n" .
38 'Reply-To:' . $reply_to . "\r\n" .
39 'Content-Type: text/html; charset="UTF-8"' . "\r\n" .
40 'Content-Transfer-Encoding: 8bit' . "\r\n" .
41 'MIME-Version: 1.0' . "\r\n" .
42 'X-Mailer: PHP/' . phpversion();
43
44 if ( 'text' === $email_type ) {
45 $headers = 'From: ' . wpstream_theme_return_sending_email() . "\r\n" .
46 'Reply-To:' . $reply_to . "\r\n" .
47 'Content-Type: text/plain ; charset="UTF-8"' . "\r\n" .
48 'Content-Transfer-Encoding: 8bit' . "\r\n" .
49 'MIME-Version: 1.0' . "\r\n" .
50 'X-Mailer: PHP/' . phpversion();
51 }
52
53 $headers = $headers . $extra_headers;
54
55 $sent = wp_mail(
56 $user_email,
57 stripslashes( $subject ),
58 stripslashes( $message ),
59 $headers
60 );
61
62 if ( ! $sent ) {
63 error_log( 'Failed to send email to ' . $user_email ); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
64 }
65 }
66 }
67
68 /*
69 *
70 * Ajax adv search contact function
71 *
72 */
73
74
75 add_action( 'wp_ajax_nopriv_wpstream_ajax_contact_function', 'wpstream_ajax_contact_function' );
76 add_action( 'wp_ajax_wpstream_ajax_contact_function', 'wpstream_ajax_contact_function' );
77
78 if( !function_exists('wpstream_ajax_contact_function') ):
79
80 function wpstream_ajax_contact_function(){
81
82
83 // check for POST vars
84 $message = '';
85 $hasError = false;
86 $allowed_html = array();
87 $to_print = '';
88 if ( !wp_verify_nonce( $_POST['nonce'], 'ajax-property-contact')) {
89 exit("No naughty business please");
90 }
91
92 $is_elementor_contact_builder = intval($_POST['is_elementor']);
93
94 if($is_elementor_contact_builder==0){
95 if ( isset($_POST['name']) ) {
96 if( trim($_POST['name']) =='' || trim($_POST['name']) ==esc_html__( 'Your Name','hello-wpstream') ){
97 echo json_encode(array('sent'=>false, 'response'=>esc_html__( 'The name field is empty !','hello-wpstream') ));
98 exit();
99 }else {
100 $name = wp_kses( trim($_POST['name']),$allowed_html );
101 }
102 }
103
104
105 //Check email
106 if ( isset($_POST['email']) || trim($_POST['email']) ==esc_html__( 'Your Email','hello-wpstream') ) {
107 if( trim($_POST['email']) ==''){
108 echo json_encode(array('sent'=>false, 'response'=>esc_html__( 'The email field is empty','hello-wpstream' ) ) );
109 exit();
110 } else if( filter_var($_POST['email'],FILTER_VALIDATE_EMAIL) === false) {
111 echo json_encode(array('sent'=>false, 'response'=>esc_html__( 'The email doesn\'t look right !','hello-wpstream') ) );
112 exit();
113 } else {
114 $email = wp_kses( trim($_POST['email']),$allowed_html );
115 }
116 }
117
118 //Check comments
119 if ( isset($_POST['comment']) ) {
120 if( trim($_POST['comment']) =='' || trim($_POST['comment']) ==esc_html__( 'Your Message','hello-wpstream')){
121 echo json_encode(array('sent'=>false, 'response'=>esc_html__( 'Your message is empty !','hello-wpstream') ) );
122 exit();
123 }else {
124 $comment = wp_kses($_POST['comment'] ,$allowed_html );
125 }
126 }
127
128
129 $message .= esc_html__('Client Name','hello-wpstream').": " . $name . PHP_EOL;
130 $message .= esc_html__('Email','hello-wpstream').": " . $email . PHP_EOL;
131 if(isset($_POST['website'])){
132 $website = wp_kses( trim($_POST['website']),$allowed_html );
133 $message .= esc_html__('Website','hello-wpstream').": " . $website . PHP_EOL;
134 }
135
136 }else{
137 if ( isset($_POST['comment']) ) {
138 $comment = wp_kses($_POST['comment'] ,$allowed_html );
139 $comment = str_replace('/n',PHP_EOL,$comment);
140
141 }
142 }
143
144
145 $subject =esc_html__( 'Contact form from ','hello-wpstream') . esc_url( home_url('/') ) ;
146 $receiver_email = esc_html(get_option('admin_email') );
147 $message .= esc_html__('Message','hello-wpstream').": ".PHP_EOL." " . $comment. PHP_EOL;
148 $message .= esc_html__('Message sent from contact page','hello-wpstream'). PHP_EOL;
149
150
151 $site_web_url = parse_url(home_url(), PHP_URL_HOST);
152 $headers = 'From: No Reply <noreply@' . $site_web_url . '>' . "\r\n";
153
154 if(isset($_POST['elementor_email_subject'])){
155 $subject = sanitize_text_field( $_POST['elementor_email_subject']);
156 }
157
158
159
160
161 wpstream_theme_send_emails( $receiver_email, $subject, $message, '' );
162
163
164 echo json_encode(array('sent'=>true,'data'=>true, 'response'=>esc_html__( 'The message was sent !','hello-wpstream') ) );
165 die();
166 }
167
168 endif; // end wpstream_theme_ajax_agent_contact_form
169
170