| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - die( 'You are not allowed to call this page directly.' ); | |
| 4 | -} | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * @since 2.03.04 |
| 8 | 5 | */ |
| @@ -7,99 +4,30 @@ | ||
| 7 | 4 | * @since 2.03.04 |
| 8 | 5 | */ |
| 9 | 6 | class FrmEmail { |
| 10 | 7 | |
| 11 | - /** | |
| 12 | - * @var string | |
| 13 | - */ | |
| 14 | 8 | private $email_key = ''; |
| 15 | - | |
| 16 | - /** | |
| 17 | - * @var array | |
| 18 | - */ | |
| 19 | 9 | private $to = array(); |
| 20 | - | |
| 21 | - /** | |
| 22 | - * @var array | |
| 23 | - */ | |
| 24 | 10 | private $cc = array(); |
| 25 | - | |
| 26 | - /** | |
| 27 | - * @var array | |
| 28 | - */ | |
| 29 | 11 | private $bcc = array(); |
| 30 | - | |
| 31 | - /** | |
| 32 | - * @var string | |
| 33 | - */ | |
| 34 | 12 | private $from = ''; |
| 35 | - | |
| 36 | - /** | |
| 37 | - * @var string | |
| 38 | - */ | |
| 39 | 13 | private $reply_to = ''; |
| 40 | - | |
| 41 | - /** | |
| 42 | - * @var string | |
| 43 | - */ | |
| 44 | 14 | private $subject = ''; |
| 45 | - | |
| 46 | - /** | |
| 47 | - * @var string | |
| 48 | - */ | |
| 49 | 15 | private $message = ''; |
| 50 | - | |
| 51 | - /** | |
| 52 | - * @var array | |
| 53 | - */ | |
| 54 | 16 | private $attachments = array(); |
| 55 | 17 | |
| 56 | - /** | |
| 57 | - * @var bool | |
| 58 | - */ | |
| 59 | 18 | private $is_plain_text = false; |
| 60 | - | |
| 61 | - /** | |
| 62 | - * @var bool | |
| 63 | - */ | |
| 64 | 19 | private $is_single_recipient = false; |
| 65 | - | |
| 66 | - /** | |
| 67 | - * @var bool | |
| 68 | - */ | |
| 69 | 20 | private $include_user_info = false; |
| 70 | 21 | |
| 71 | - /** | |
| 72 | - * @var string | |
| 73 | - */ | |
| 74 | 22 | private $charset = ''; |
| 75 | - | |
| 76 | - /** | |
| 77 | - * @var string | |
| 78 | - */ | |
| 79 | 23 | private $content_type = 'text/html'; |
| 80 | 24 | |
| 81 | - /** | |
| 82 | - * @var array | |
| 83 | - */ | |
| 84 | 25 | private $settings = array(); |
| 85 | - | |
| 86 | - /** | |
| 87 | - * @var stdClass | |
| 88 | - */ | |
| 89 | 26 | private $entry; |
| 90 | - | |
| 91 | - /** | |
| 92 | - * @var stdClass | |
| 93 | - */ | |
| 94 | 27 | private $form; |
| 95 | 28 | |
| 96 | 29 | /** |
| 97 | - * @var int | |
| 98 | - */ | |
| 99 | - private $action_id = 0; | |
| 100 | - | |
| 101 | - /** | |
| 102 | 30 | * FrmEmail constructor |
| 103 | 31 | * |
| 104 | 32 | * @param object $action |
| 105 | 33 | * @param object $entry |
| @@ -106,12 +34,11 @@ | ||
| 106 | 34 | * @param object $form |
| 107 | 35 | */ |
| 108 | 36 | public function __construct( $action, $entry, $form ) { |
| 109 | 37 | $this->set_email_key( $action ); |
| 110 | - $this->entry = $entry; | |
| 111 | - $this->form = $form; | |
| 112 | - $this->settings = $action->post_content; | |
| 113 | - $this->action_id = (int) $action->ID; | |
| 38 | + $this->entry = $entry; | |
| 39 | + $this->form = $form; | |
| 40 | + $this->settings = $action->post_content; | |
| 114 | 41 | |
| 115 | 42 | $user_id_args = self::get_user_id_args( $form->id ); |
| 116 | 43 | $this->set_to( $user_id_args ); |
| 117 | 44 | $this->set_cc( $user_id_args ); |
| @@ -141,10 +68,8 @@ | ||
| 141 | 68 | * |
| 142 | 69 | * @since 2.03.04 |
| 143 | 70 | * |
| 144 | 71 | * @param object $action |
| 145 | - * | |
| 146 | - * @return void | |
| 147 | 72 | */ |
| 148 | 73 | private function set_email_key( $action ) { |
| 149 | 74 | $this->email_key = $action->ID; |
| 150 | 75 | } |
| @@ -154,16 +79,14 @@ | ||
| 154 | 79 | * |
| 155 | 80 | * @since 2.03.04 |
| 156 | 81 | * |
| 157 | 82 | * @param array $user_id_args |
| 158 | - * | |
| 159 | - * @return void | |
| 160 | 83 | */ |
| 161 | 84 | private function set_to( $user_id_args ) { |
| 162 | 85 | $to = $this->prepare_email_setting( $this->settings['email_to'], $user_id_args ); |
| 163 | 86 | $to = $this->explode_emails( $to ); |
| 164 | 87 | |
| 165 | - $where = array( | |
| 88 | + $where = array( | |
| 166 | 89 | 'it.field_id !' => 0, |
| 167 | 90 | 'it.item_id' => $this->entry->id, |
| 168 | 91 | ); |
| 169 | 92 | $values = FrmEntryMeta::getAll( $where, ' ORDER BY fi.field_order' ); |
| @@ -190,10 +113,8 @@ | ||
| 190 | 113 | * |
| 191 | 114 | * @since 2.03.04 |
| 192 | 115 | * |
| 193 | 116 | * @param array $user_id_args |
| 194 | - * | |
| 195 | - * @return void | |
| 196 | 117 | */ |
| 197 | 118 | private function set_cc( $user_id_args ) { |
| 198 | 119 | $this->cc = $this->prepare_additional_recipients( $this->settings['cc'], $user_id_args ); |
| 199 | 120 | } |
| @@ -203,10 +124,8 @@ | ||
| 203 | 124 | * |
| 204 | 125 | * @since 2.03.04 |
| 205 | 126 | * |
| 206 | 127 | * @param array $user_id_args |
| 207 | - * | |
| 208 | - * @return void | |
| 209 | 128 | */ |
| 210 | 129 | private function set_bcc( $user_id_args ) { |
| 211 | 130 | $this->bcc = $this->prepare_additional_recipients( $this->settings['bcc'], $user_id_args ); |
| 212 | 131 | } |
| @@ -216,9 +135,9 @@ | ||
| 216 | 135 | * |
| 217 | 136 | * @since 2.03.04 |
| 218 | 137 | * |
| 219 | 138 | * @param string $recipients |
| 220 | - * @param array $user_id_args | |
| 139 | + * @param array $user_id_args | |
| 221 | 140 | * |
| 222 | 141 | * @return array |
| 223 | 142 | */ |
| 224 | 143 | private function prepare_additional_recipients( $recipients, $user_id_args ) { |
| @@ -236,14 +155,12 @@ | ||
| 236 | 155 | * |
| 237 | 156 | * @since 2.03.04 |
| 238 | 157 | * |
| 239 | 158 | * @param array $user_id_args |
| 240 | - * | |
| 241 | - * @return void | |
| 242 | 159 | */ |
| 243 | 160 | private function set_from( $user_id_args ) { |
| 244 | 161 | if ( empty( $this->settings['from'] ) ) { |
| 245 | - $from = FrmEmailHelper::get_default_from_email(); | |
| 162 | + $from = get_option( 'admin_email' ); | |
| 246 | 163 | } else { |
| 247 | 164 | $from = $this->prepare_email_setting( $this->settings['from'], $user_id_args ); |
| 248 | 165 | } |
| 249 | 166 | |
| @@ -255,22 +172,17 @@ | ||
| 255 | 172 | * |
| 256 | 173 | * @since 2.03.04 |
| 257 | 174 | * |
| 258 | 175 | * @param array $user_id_args |
| 259 | - * | |
| 260 | - * @return void | |
| 261 | 176 | */ |
| 262 | 177 | private function set_reply_to( $user_id_args ) { |
| 263 | 178 | $this->reply_to = trim( $this->settings['reply_to'] ); |
| 264 | 179 | |
| 265 | - if ( $this->reply_to ) { | |
| 180 | + if ( empty( $this->reply_to ) ) { | |
| 181 | + $this->reply_to = $this->get_email_from_name( $this->from ); | |
| 182 | + } else { | |
| 266 | 183 | $this->reply_to = $this->prepare_email_setting( $this->settings['reply_to'], $user_id_args ); |
| 267 | 184 | } |
| 268 | - | |
| 269 | - if ( ! $this->reply_to ) { | |
| 270 | - $this->reply_to = $this->get_email_from_name( $this->from ); | |
| 271 | - } | |
| 272 | - | |
| 273 | 185 | $this->reply_to = $this->format_reply_to( $this->reply_to ); |
| 274 | 186 | } |
| 275 | 187 | |
| 276 | 188 | /** |
| @@ -277,19 +189,13 @@ | ||
| 277 | 189 | * Set the is_plain_text property |
| 278 | 190 | * This should be set before the message |
| 279 | 191 | * |
| 280 | 192 | * @since 2.03.04 |
| 281 | - * | |
| 282 | - * @return void | |
| 283 | 193 | */ |
| 284 | 194 | private function set_is_plain_text() { |
| 285 | - if ( empty( $this->settings['email_style'] ) ) { | |
| 286 | - // If `email_style` isn't set, use the `plain_text` checkbox. | |
| 287 | - $this->is_plain_text = ! empty( $this->settings['plain_text'] ); | |
| 288 | - return; | |
| 195 | + if ( $this->settings['plain_text'] ) { | |
| 196 | + $this->is_plain_text = true; | |
| 289 | 197 | } |
| 290 | - | |
| 291 | - $this->is_plain_text = 'plain' === $this->settings['email_style']; | |
| 292 | 198 | } |
| 293 | 199 | |
| 294 | 200 | /** |
| 295 | 201 | * Set the include_user_info property |
| @@ -295,10 +201,8 @@ | ||
| 295 | 201 | * Set the include_user_info property |
| 296 | 202 | * This should be set before the message |
| 297 | 203 | * |
| 298 | 204 | * @since 2.03.04 |
| 299 | - * | |
| 300 | - * @return void | |
| 301 | 205 | */ |
| 302 | 206 | private function set_include_user_info() { |
| 303 | 207 | if ( isset( $this->settings['inc_user_info'] ) ) { |
| 304 | 208 | $this->include_user_info = $this->settings['inc_user_info']; |
| @@ -309,11 +213,9 @@ | ||
| 309 | 213 | * Set the is_single_recipient property |
| 310 | 214 | * |
| 311 | 215 | * @since 2.03.04 |
| 312 | 216 | * |
| 313 | - * @param object $action | |
| 314 | - * | |
| 315 | - * @return void | |
| 217 | + * @param $action | |
| 316 | 218 | */ |
| 317 | 219 | private function set_is_single_recipient( $action ) { |
| 318 | 220 | $args = array( |
| 319 | 221 | 'form' => $this->form, |
| @@ -332,10 +234,8 @@ | ||
| 332 | 234 | /** |
| 333 | 235 | * Set the charset |
| 334 | 236 | * |
| 335 | 237 | * @since 2.03.04 |
| 336 | - * | |
| 337 | - * @return void | |
| 338 | 238 | */ |
| 339 | 239 | private function set_charset() { |
| 340 | 240 | $this->charset = get_option( 'blog_charset' ); |
| 341 | 241 | } |
| @@ -343,10 +243,8 @@ | ||
| 343 | 243 | /** |
| 344 | 244 | * Set the content type |
| 345 | 245 | * |
| 346 | 246 | * @since 2.03.04 |
| 347 | - * | |
| 348 | - * @return void | |
| 349 | 247 | */ |
| 350 | 248 | private function set_content_type() { |
| 351 | 249 | if ( $this->is_plain_text ) { |
| 352 | 250 | $this->content_type = 'text/plain'; |
| @@ -356,10 +254,8 @@ | ||
| 356 | 254 | /** |
| 357 | 255 | * Set the subject |
| 358 | 256 | * |
| 359 | 257 | * @since 2.03.04 |
| 360 | - * | |
| 361 | - * @return void | |
| 362 | 258 | */ |
| 363 | 259 | private function set_subject() { |
| 364 | 260 | if ( empty( $this->settings['email_subject'] ) ) { |
| 365 | 261 | /* translators: %1$s: Form name, %2$s: Site name */ |
| @@ -367,9 +263,8 @@ | ||
| 367 | 263 | } else { |
| 368 | 264 | $this->subject = $this->settings['email_subject']; |
| 369 | 265 | } |
| 370 | 266 | |
| 371 | - // This also replaces [sitename] shortcode in default. | |
| 372 | 267 | $this->subject = FrmFieldsHelper::basic_replace_shortcodes( $this->subject, $this->form, $this->entry ); |
| 373 | 268 | |
| 374 | 269 | $args = array( |
| 375 | 270 | 'form' => $this->form, |
| @@ -376,8 +271,9 @@ | ||
| 376 | 271 | 'entry' => $this->entry, |
| 377 | 272 | 'email_key' => $this->email_key, |
| 378 | 273 | ); |
| 379 | 274 | $this->subject = apply_filters( 'frm_email_subject', $this->subject, $args ); |
| 275 | + | |
| 380 | 276 | $this->subject = wp_specialchars_decode( strip_tags( stripslashes( $this->subject ) ), ENT_QUOTES ); |
| 381 | 277 | } |
| 382 | 278 | |
| 383 | 279 | /** |
| @@ -383,38 +279,27 @@ | ||
| 383 | 279 | /** |
| 384 | 280 | * Set the email message |
| 385 | 281 | * |
| 386 | 282 | * @since 2.03.04 |
| 387 | - * | |
| 388 | - * @return void | |
| 389 | 283 | */ |
| 390 | 284 | private function set_message() { |
| 391 | - $this->message = $this->settings['email_message']; | |
| 285 | + $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->settings['email_message'], $this->form, $this->entry ); | |
| 392 | 286 | |
| 393 | - if ( ! $this->is_plain_text ) { | |
| 394 | - // The decode is to support [default-html] shortcodes. | |
| 395 | - $this->message = html_entity_decode( $this->message ); | |
| 396 | - } | |
| 397 | - | |
| 398 | - $this->message = FrmFieldsHelper::basic_replace_shortcodes( $this->message, $this->form, $this->entry ); | |
| 399 | 287 | $prev_mail_body = $this->message; |
| 400 | - | |
| 401 | - // Make a copy to prevent changes by reference. | |
| 402 | - $pass_entry = clone $this->entry; | |
| 403 | - $mail_body = FrmEntriesHelper::replace_default_message( | |
| 288 | + $pass_entry = clone $this->entry; // make a copy to prevent changes by reference | |
| 289 | + $mail_body = FrmEntriesHelper::replace_default_message( | |
| 404 | 290 | $prev_mail_body, |
| 405 | 291 | array( |
| 406 | - 'id' => $this->entry->id, | |
| 407 | - 'entry' => $pass_entry, | |
| 408 | - 'plain_text' => $this->is_plain_text, | |
| 409 | - 'user_info' => $this->include_user_info, | |
| 410 | - 'table_style' => $this->settings['email_style'], | |
| 292 | + 'id' => $this->entry->id, | |
| 293 | + 'entry' => $pass_entry, | |
| 294 | + 'plain_text' => $this->is_plain_text, | |
| 295 | + 'user_info' => $this->include_user_info, | |
| 411 | 296 | ) |
| 412 | 297 | ); |
| 413 | 298 | |
| 414 | 299 | // Add the user info if it isn't already included |
| 415 | 300 | if ( $this->include_user_info && $prev_mail_body === $mail_body ) { |
| 416 | - $data = $this->entry->description; | |
| 301 | + $data = maybe_unserialize( $this->entry->description ); | |
| 417 | 302 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
| 418 | 303 | $this->maybe_add_ip( $mail_body ); |
| 419 | 304 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntriesHelper::get_browser( $data['browser'] ) . "\r\n"; |
| 420 | 305 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
| @@ -421,39 +306,17 @@ | ||
| 421 | 306 | } |
| 422 | 307 | |
| 423 | 308 | $this->message = $mail_body; |
| 424 | 309 | |
| 310 | + $this->message = do_shortcode( $this->message ); | |
| 311 | + | |
| 425 | 312 | if ( $this->is_plain_text ) { |
| 426 | 313 | $this->message = wp_specialchars_decode( strip_tags( $this->message ), ENT_QUOTES ); |
| 427 | - $this->message = str_replace( ' ', '', $this->message ); | |
| 428 | - } else { | |
| 429 | - $this->add_autop(); | |
| 430 | 314 | } |
| 431 | 315 | |
| 432 | 316 | $this->message = apply_filters( 'frm_email_message', $this->message, $this->package_atts() ); |
| 433 | 317 | } |
| 434 | 318 | |
| 435 | - /** | |
| 436 | - * Runs message through autop, extracting the content inside body tag if it has <body>. | |
| 437 | - * | |
| 438 | - * @return void | |
| 439 | - */ | |
| 440 | - private function add_autop() { | |
| 441 | - $message = $this->message; | |
| 442 | - preg_match( '/<body[^>]*>([\s\S]*?)<\/body>/', $message, $match ); | |
| 443 | - | |
| 444 | - if ( ! empty( $match[1] ) ) { | |
| 445 | - $this->message = str_replace( $match[1], trim( wpautop( $match[1] ) ), $message ); | |
| 446 | - } else { | |
| 447 | - $this->message = trim( wpautop( $message ) ); | |
| 448 | - } | |
| 449 | - } | |
| 450 | - | |
| 451 | - /** | |
| 452 | - * @param string $mail_body | |
| 453 | - * | |
| 454 | - * @return void | |
| 455 | - */ | |
| 456 | 319 | private function maybe_add_ip( &$mail_body ) { |
| 457 | 320 | if ( ! empty( $this->entry->ip ) ) { |
| 458 | 321 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $this->entry->ip . "\r\n"; |
| 459 | 322 | } |
| @@ -462,18 +325,13 @@ | ||
| 462 | 325 | /** |
| 463 | 326 | * Set the attachments for an email message |
| 464 | 327 | * |
| 465 | 328 | * @since 2.03.04 |
| 466 | - * @since 5.0.16 added new action_id key to $args. | |
| 467 | - * | |
| 468 | - * @return void | |
| 469 | 329 | */ |
| 470 | 330 | private function set_attachments() { |
| 471 | 331 | $args = array( |
| 472 | 332 | 'entry' => $this->entry, |
| 473 | 333 | 'email_key' => $this->email_key, |
| 474 | - 'settings' => $this->settings, | |
| 475 | - 'action_id' => $this->action_id, | |
| 476 | 334 | ); |
| 477 | 335 | |
| 478 | 336 | $this->attachments = apply_filters( 'frm_notification_attachment', array(), $this->form, $args ); |
| 479 | 337 | } |
| @@ -518,10 +376,11 @@ | ||
| 518 | 376 | */ |
| 519 | 377 | private function has_recipients() { |
| 520 | 378 | if ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) ) { |
| 521 | 379 | return false; |
| 380 | + } else { | |
| 381 | + return true; | |
| 522 | 382 | } |
| 523 | - return true; | |
| 524 | 383 | } |
| 525 | 384 | |
| 526 | 385 | /** |
| 527 | 386 | * Send an email |
| @@ -534,9 +393,8 @@ | ||
| 534 | 393 | $this->remove_buddypress_filters(); |
| 535 | 394 | $this->add_mandrill_filter(); |
| 536 | 395 | |
| 537 | 396 | $sent = false; |
| 538 | - | |
| 539 | 397 | if ( count( $this->to ) > 1 && $this->is_single_recipient ) { |
| 540 | 398 | foreach ( $this->to as $recipient ) { |
| 541 | 399 | $sent = $this->send_single( $recipient ); |
| 542 | 400 | } |
| @@ -572,12 +430,9 @@ | ||
| 572 | 430 | |
| 573 | 431 | $sent = wp_mail( $recipient, $subject, $this->message, $header, $this->attachments ); |
| 574 | 432 | |
| 575 | 433 | if ( ! $sent ) { |
| 576 | - if ( is_array( $header ) ) { | |
| 577 | - $header = implode( "\r\n", $header ); | |
| 578 | - } | |
| 579 | - | |
| 434 | + $header = 'From: ' . $this->from . "\r\n"; | |
| 580 | 435 | $recipient = implode( ',', (array) $recipient ); |
| 581 | 436 | $sent = mail( $recipient, $subject, $this->message, $header ); |
| 582 | 437 | } |
| 583 | 438 | |
| @@ -593,9 +448,9 @@ | ||
| 593 | 448 | * |
| 594 | 449 | * @return array |
| 595 | 450 | */ |
| 596 | 451 | private function package_header() { |
| 597 | - $header = array(); | |
| 452 | + $header = array(); | |
| 598 | 453 | |
| 599 | 454 | if ( ! empty( $this->cc ) ) { |
| 600 | 455 | $header[] = 'CC: ' . implode( ',', $this->cc ); |
| 601 | 456 | } |
| @@ -615,9 +470,9 @@ | ||
| 615 | 470 | * Get the userID field ID and key for email settings |
| 616 | 471 | * |
| 617 | 472 | * @since 2.03.04 |
| 618 | 473 | * |
| 619 | - * @param int $form_id | |
| 474 | + * @param $form_id | |
| 620 | 475 | * |
| 621 | 476 | * @return array |
| 622 | 477 | */ |
| 623 | 478 | private function get_user_id_args( $form_id ) { |
| @@ -626,9 +481,8 @@ | ||
| 626 | 481 | 'field_key' => '', |
| 627 | 482 | ); |
| 628 | 483 | |
| 629 | 484 | $user_id_args['field_id'] = FrmEmailHelper::get_user_id_field_for_form( $form_id ); |
| 630 | - | |
| 631 | 485 | if ( $user_id_args['field_id'] ) { |
| 632 | 486 | $user_id_args['field_key'] = FrmField::get_key_by_id( $user_id_args['field_id'] ); |
| 633 | 487 | } |
| 634 | 488 | |
| @@ -640,9 +494,9 @@ | ||
| 640 | 494 | * |
| 641 | 495 | * @since 2.03.04 |
| 642 | 496 | * |
| 643 | 497 | * @param string $value |
| 644 | - * @param array $user_id_args | |
| 498 | + * @param array $user_id_args | |
| 645 | 499 | * |
| 646 | 500 | * @return string |
| 647 | 501 | */ |
| 648 | 502 | private function prepare_email_setting( $value, $user_id_args ) { |
| @@ -667,14 +521,12 @@ | ||
| 667 | 521 | * |
| 668 | 522 | * @since 2.03.04 |
| 669 | 523 | * |
| 670 | 524 | * @param string $emails |
| 671 | - * | |
| 672 | 525 | * @return array|string $emails |
| 673 | 526 | */ |
| 674 | 527 | private function explode_emails( $emails ) { |
| 675 | 528 | $emails = ( ! empty( $emails ) ? preg_split( '/(,|;)/', $emails ) : '' ); |
| 676 | - | |
| 677 | 529 | if ( is_array( $emails ) ) { |
| 678 | 530 | $emails = array_map( 'trim', $emails ); |
| 679 | 531 | } else { |
| 680 | 532 | $emails = trim( $emails ); |
| @@ -700,24 +552,24 @@ | ||
| 700 | 552 | |
| 701 | 553 | if ( is_email( $val ) ) { |
| 702 | 554 | // If a plain email is used, no formatting is needed |
| 703 | 555 | continue; |
| 704 | - } | |
| 556 | + } else { | |
| 557 | + $parts = explode( ' ', $val ); | |
| 558 | + $email = end( $parts ); | |
| 705 | 559 | |
| 706 | - $parts = explode( ' ', $val ); | |
| 707 | - $email = end( $parts ); | |
| 708 | - | |
| 709 | - if ( is_email( $email ) ) { | |
| 710 | - // If user enters a name and email | |
| 711 | - $name = trim( str_replace( $email, '', $val ) ); | |
| 712 | - } else { | |
| 713 | - // If user enters a name without an email | |
| 714 | - unset( $recipients[ $key ] ); | |
| 715 | - continue; | |
| 560 | + if ( is_email( $email ) ) { | |
| 561 | + // If user enters a name and email | |
| 562 | + $name = trim( str_replace( $email, '', $val ) ); | |
| 563 | + } else { | |
| 564 | + // If user enters a name without an email | |
| 565 | + unset( $recipients[ $key ] ); | |
| 566 | + continue; | |
| 567 | + } | |
| 716 | 568 | } |
| 717 | 569 | |
| 718 | 570 | $recipients[ $key ] = $this->format_from_email( $name, $email ); |
| 719 | - }//end foreach | |
| 571 | + } | |
| 720 | 572 | |
| 721 | 573 | return $recipients; |
| 722 | 574 | } |
| 723 | 575 | |
| @@ -743,9 +595,8 @@ | ||
| 743 | 595 | if ( strpos( $from_email, '@yahoo.com' ) ) { |
| 744 | 596 | |
| 745 | 597 | // Get the site domain and get rid of www. |
| 746 | 598 | $sitename = strtolower( FrmAppHelper::get_server_value( 'SERVER_NAME' ) ); |
| 747 | - | |
| 748 | 599 | if ( substr( $sitename, 0, 4 ) === 'www.' ) { |
| 749 | 600 | $sitename = substr( $sitename, 4 ); |
| 750 | 601 | } |
| 751 | 602 | |
| @@ -768,9 +619,9 @@ | ||
| 768 | 619 | $reply_to = trim( $reply_to ); |
| 769 | 620 | |
| 770 | 621 | if ( ! is_email( $reply_to ) ) { |
| 771 | 622 | list( $name, $email ) = $this->get_name_and_email_for_sender( $reply_to ); |
| 772 | - $reply_to = $this->format_from_email( $name, $email ); | |
| 623 | + $reply_to = $this->format_from_email( $name, $email ); | |
| 773 | 624 | } |
| 774 | 625 | |
| 775 | 626 | return $reply_to; |
| 776 | 627 | } |
| @@ -778,21 +629,15 @@ | ||
| 778 | 629 | /** |
| 779 | 630 | * Get only the email if the name and email have been combined |
| 780 | 631 | * |
| 781 | 632 | * @since 3.0.06 |
| 782 | - * | |
| 783 | - * @param string $name | |
| 784 | - * | |
| 785 | - * @return string | |
| 786 | 633 | */ |
| 787 | 634 | private function get_email_from_name( $name ) { |
| 788 | 635 | $email = trim( trim( $name, '>' ), '<' ); |
| 789 | - | |
| 790 | 636 | if ( strpos( $email, '<' ) !== false ) { |
| 791 | 637 | $parts = explode( '<', $email ); |
| 792 | 638 | $email = trim( $parts[1], '>' ); |
| 793 | 639 | } |
| 794 | - | |
| 795 | 640 | return $email; |
| 796 | 641 | } |
| 797 | 642 | |
| 798 | 643 | /** |
| @@ -820,19 +665,13 @@ | ||
| 820 | 665 | } |
| 821 | 666 | |
| 822 | 667 | /** |
| 823 | 668 | * @since 3.0.06 |
| 824 | - * | |
| 825 | - * @param string $name | |
| 826 | - * @param string $email | |
| 827 | - * | |
| 828 | - * @return string | |
| 829 | 669 | */ |
| 830 | 670 | private function format_from_email( $name, $email ) { |
| 831 | 671 | if ( '' !== $name ) { |
| 832 | 672 | $email = $name . ' <' . $email . '>'; |
| 833 | 673 | } |
| 834 | - | |
| 835 | 674 | return $email; |
| 836 | 675 | } |
| 837 | 676 | |
| 838 | 677 | /** |
| @@ -839,10 +678,8 @@ | ||
| 839 | 678 | * Remove phone numbers from To addresses |
| 840 | 679 | * Send the phone numbers to the frm_send_to_not_email hook |
| 841 | 680 | * |
| 842 | 681 | * @since 2.03.04 |
| 843 | - * | |
| 844 | - * @return void | |
| 845 | 682 | */ |
| 846 | 683 | private function handle_phone_numbers() { |
| 847 | 684 | |
| 848 | 685 | foreach ( $this->to as $key => $recipient ) { |
| @@ -869,10 +706,10 @@ | ||
| 869 | 706 | ); |
| 870 | 707 | |
| 871 | 708 | // Remove phone number from to addresses |
| 872 | 709 | unset( $this->to[ $key ] ); |
| 873 | - }//end if | |
| 874 | - }//end foreach | |
| 710 | + } | |
| 711 | + } | |
| 875 | 712 | } |
| 876 | 713 | |
| 877 | 714 | /** |
| 878 | 715 | * Package an array of FrmEmail properties |
| @@ -891,12 +728,10 @@ | ||
| 891 | 728 | 'subject' => $this->subject, |
| 892 | 729 | 'message' => $this->message, |
| 893 | 730 | 'attachments' => $this->attachments, |
| 894 | 731 | 'plain_text' => $this->is_plain_text, |
| 895 | - 'email_key' => $this->email_key, | |
| 896 | 732 | 'form' => $this->form, |
| 897 | 733 | 'entry' => $this->entry, |
| 898 | - 'email_style' => $this->settings['email_style'], | |
| 899 | 734 | ); |
| 900 | 735 | } |
| 901 | 736 | |
| 902 | 737 | /** |
| @@ -902,10 +737,8 @@ | ||
| 902 | 737 | /** |
| 903 | 738 | * Remove the Buddypress email filters |
| 904 | 739 | * |
| 905 | 740 | * @since 2.03.04 |
| 906 | - * | |
| 907 | - * @return void | |
| 908 | 741 | */ |
| 909 | 742 | private function remove_buddypress_filters() { |
| 910 | 743 | remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' ); |
| 911 | 744 | remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' ); |
| @@ -915,10 +748,8 @@ | ||
| 915 | 748 | * Add Mandrill line break filter |
| 916 | 749 | * Remove line breaks in HTML emails to prevent conflicts with Mandrill |
| 917 | 750 | * |
| 918 | 751 | * @since 2.03.04 |
| 919 | - * | |
| 920 | - * @return void | |
| 921 | 752 | */ |
| 922 | 753 | private function add_mandrill_filter() { |
| 923 | 754 | if ( ! $this->is_plain_text ) { |
| 924 | 755 | add_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' ); |
| @@ -928,10 +759,8 @@ | ||
| 928 | 759 | /** |
| 929 | 760 | * Remove Mandrill line break filter |
| 930 | 761 | * |
| 931 | 762 | * @since 2.03.04 |
| 932 | - * | |
| 933 | - * @return void | |
| 934 | 763 | */ |
| 935 | 764 | private function remove_mandrill_filter() { |
| 936 | 765 | remove_filter( 'mandrill_nl2br', 'FrmEmailHelper::remove_mandrill_br' ); |
| 937 | 766 | } |
| @@ -943,9 +772,9 @@ | ||
| 943 | 772 | * |
| 944 | 773 | * @return string |
| 945 | 774 | */ |
| 946 | 775 | private function encode_subject( $subject ) { |
| 947 | - if ( apply_filters( 'frm_encode_subject', false, $subject ) ) { | |
| 776 | + if ( apply_filters( 'frm_encode_subject', 1, $subject ) ) { | |
| 948 | 777 | $subject = '=?' . $this->charset . '?B?' . base64_encode( $subject ) . '?='; |
| 949 | 778 | } |
| 950 | 779 | |
| 951 | 780 | return $subject; |