JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<?php
/**
* The Forminator Mail.
*
* @package Forminator
*/
if ( ! defined( 'ABSPATH' ) ) {
die();
}
/**
* Class Forminator_Mail
*
* Handle mail sending
*
* @since 1.0
*/
abstract class Forminator_Mail {
/**
* Whether we're currently in email context
*
* @var bool
*/
protected static $is_email_context = false;
/**
* Message variables
*
* @var array
*/
protected $message_vars;
/**
* Check if we're currently in email context
*
* @return bool
*/
public static function is_email_context() {
return self::$is_email_context;
}
/**
* Default content type
*
* @since 1.5
* @var string
*/
protected $content_type = 'text/html; charset=UTF-8';
/**
* Mail recipient
* The email to receive the mail
*
* @var string
*/
protected $recipient = '';
/**
* Mail recipients
* The emails to receive the mail
*
* @var array
*/
protected $recipients = array();
/**
* Mail message
*
* @var string
*/
protected $message = '';
/**
* Mail subject
*
* @var string
*/
protected $subject = '';
/**
* Mail from email
*
* @var string
*/
protected $sender_email = '';
/**
* Mail from name
*
* @var string
*/
protected $sender_name = '';
/**
* Mail headers
*
* @var array
*/
protected $headers = array();
/**
* Mail headers
*
* @var array
*/
protected $attachment = array();
/**
* Selected PDFs
*
* @var array
*/
protected $pdfs = array();
/**
* Main constructor
*
* @since 1.0
*
* @param string $recipient - mail recipient email.
* @param string $message - mail message.
* @param string $subject - mail subject.
*/
public function __construct( $recipient = '', $message = '', $subject = '' ) {
if ( ! empty( $recipient ) && filter_var( $recipient, FILTER_VALIDATE_EMAIL ) ) {
$this->recipient = $recipient;
}
if ( ! empty( $message ) ) {
$this->message = $message;
}
if ( ! empty( $subject ) ) {
$this->subject = $subject;
}
$this->sender_email = get_global_sender_email_address();
$this->sender_name = get_global_sender_name();
$this->set_headers();
}
/**
* Initialize the mail
*/
public function init() {
$user_email = false;
$user_name = '';
$user_login = '';
$embed_id = filter_input( INPUT_POST, 'page_id', FILTER_VALIDATE_INT );
$embed_title = get_the_title( $embed_id );
$embed_url = forminator_get_current_url();
$site_url = site_url();
// Check if user is logged in.
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$user_email = $current_user->user_email;
if ( ! empty( $current_user->user_firstname ) ) {
$user_name = $current_user->user_firstname . ' ' . $current_user->user_lastname;
} elseif ( ! empty( $current_user->display_name ) ) {
$user_name = $current_user->display_name;
} else {
$user_name = $current_user->display_name;
}
$user_login = $current_user->user_login;
}
// Set up mail variables.
$message_vars = forminator_set_message_vars( $embed_id, $embed_title, $embed_url, $user_name, $user_email, $user_login, $site_url );
/**
* Message variables filter
*
* @since 1.0.2
*
* @param array $message_vars - the message variables.
* @param int $embed_id - the current module id.
*
* @return array $message_vars
*/
$this->message_vars = apply_filters( 'forminator_custom_' . static::$module_slug . '_message_vars', $message_vars, $embed_id );
}
/**
* Check if all conditions are met to send admin email
*
* @since 1.0
*
* @param array $setting - the module settings.
*
* @return bool
*/
public function is_send_admin_mail( $setting ) {
if ( isset( $setting['use-admin-email'] ) && ! empty( $setting['use-admin-email'] ) ) {
if ( filter_var( $setting['use-admin-email'], FILTER_VALIDATE_BOOLEAN ) ) {
if ( ! empty( $setting['admin-email-title'] ) && ! empty( $setting['admin-email-editor'] ) ) {
return true;
}
}
}
return false;
}
/**
* Get Recipients of admin emails
*
* @since 1.0.3
* @since 1.6.2 add $custom_form model, and entry
*
* @param array $notification Notification.
* @param Forminator_Base_Form_Model $module Base Form Model.
* @param Forminator_Form_Entry_Model $entry Entry Form Model.
* @param array $lead_model Lead Model.
* @param string $result_slug Result slug.
*
* @return array
*/
public function get_admin_email_recipients( $notification, $module = null, $entry = null, $lead_model = array(), $result_slug = '' ) {
$email = array();
$recipients = array();
if ( isset( $notification['email-recipients'] ) && 'routing' === $notification['email-recipients'] ) {
if ( ! empty( $notification['routing'] ) ) {
foreach ( $notification['routing'] as $routing ) {
if ( $this->is_routing( $routing, $module, $result_slug ) ) {
if ( false !== strpos( $routing['email'], ',' ) ) {
$recipients = array_merge( array_map( 'trim', explode( ',', $routing['email'] ) ), $recipients );
} else {
$recipients[] = trim( $routing['email'] );
}
}
}
}
} elseif ( isset( $notification['recipients'] ) && ! empty( $notification['recipients'] ) ) {
$recipients = array_map( 'trim', explode( ',', $notification['recipients'] ) );
}
if ( ! empty( $recipients ) ) {
foreach ( $recipients as $key => $recipient ) {
$recipient = $this->get_recipient( $recipient, $module, $entry, $lead_model );
if ( false !== strpos( $recipient, ',' ) ) {
$emails = array_map( 'trim', explode( ',', $recipient ) );
if ( ! empty( $emails ) ) {
foreach ( $emails as $email_key => $email_recipient ) {
if ( is_email( $email_recipient ) ) {
$email[] = $email_recipient;
}
}
}
} elseif ( is_email( $recipient ) ) {
$email[] = $recipient;
}
}
}
return apply_filters( 'forminator_' . static::$module_slug . '_get_admin_email_recipients', $email, $notification, Forminator_CForm_Front_Action::$prepared_data, $module, $entry );
}
/**
* Set recipeint
*
* @since 1.0
*
* @param string $recipient - recipient email.
*/
public function set_recipient( $recipient ) {
if ( filter_var( $recipient, FILTER_VALIDATE_EMAIL ) ) {
$this->recipient = $recipient;
}
}
/**
* Set Recipients as array
*
* @since 1.0.3
*
* @param array $recipients Recipients.
*/
public function set_recipients( $recipients ) {
$this->recipients = array();
if ( ! empty( $recipients ) ) {
foreach ( $recipients as $recipient ) {
if ( filter_var( $recipient, FILTER_VALIDATE_EMAIL ) ) {
$this->recipients[] = $recipient;
}
}
}
}
/**
* Set message
*
* @since 1.0
*
* @param string $message - the mail message.
*/
public function set_message( $message ) {
$this->message = $message;
}
/**
* Set message with vars
*
* @since 1.0
*
* @param array $message_vars - the mail message array variables.
* @param string $message - the mail message.
*/
public function set_message_with_vars( $message_vars, $message ) {
$this->message = str_replace(
array_keys( $message_vars ),
array_values( $message_vars ),
stripslashes( $message )
);
}
/**
* Set subject
*
* @since 1.0
*
* @param string $subject - the mail subject.
*/
public function set_subject( $subject ) {
$this->subject = $subject;
}
/**
* Set PDFs
*
* @since 2.0
*
* @param array $notification - Selected PDFs in form notifications.
*/
public function set_pdfs( $notification ) {
if ( ! empty( $notification['email-pdfs'] ) && ! forminator_addons_disabled() ) {
$this->pdfs = $notification['email-pdfs'];
} else {
$this->pdfs = array();
}
}
/**
* Set attachment
*
* @since 1.0
*
* @param array $attachment - the mail attachment.
* @param mixed $custom_form Custom form.
* @param mixed $entry - Entry.
*/
public function set_attachment( $attachment, $custom_form = null, $entry = null ) {
// Set email context to false to avoid replacing images in PDFs.
$old_value = self::$is_email_context;
self::$is_email_context = false;
$attachment = $this->filter_attachments( $attachment );
$this->attachment = apply_filters( 'forminator_custom_form_mail_attachment', $attachment, $custom_form, $entry, $this->pdfs );
self::$is_email_context = $old_value;
}
/**
* Filter attachments to make sure only files in upload dir can be attached.
*
* @param array $attachments Attachments to filter.
* @return array
*/
private function filter_attachments( $attachments ) {
if ( ! empty( $attachments ) ) {
foreach ( $attachments as $key => $attachment ) {
if ( ! forminator_attachment_path_is_allowed( $attachment ) ) {
unset( $attachments[ $key ] );
}
}
}
return $attachments;
}
/**
* Set headers
*
* @since 1.0
*
* @param array $headers - the mail headers.
*/
public function set_headers( $headers = array() ) {
if ( ! empty( $headers ) ) {
$this->headers = $headers;
} else {
$this->headers = array(
'From: ' . $this->sender_name . ' <' . $this->sender_email . '>',
);
$this->headers[] = 'Content-Type: text/html; charset=UTF-8';
}
}
/**
* Clean mail variables
*
* @since 1.0
*/
private function clean() {
$subject = stripslashes( $this->subject );
$subject = wp_strip_all_tags( $subject );
$this->subject = $subject;
$message = make_clickable( wpautop( stripslashes( $this->message ) ) );
/**
* Filter email body that will be sent by Forminator Mailer
*
* @param string $message
*/
$message = apply_filters( 'forminator_email_message', $message );
$this->message = $message;
}
/**
* Get Forminator mailer headers
*
* @since 1.5
* @return array
*/
public function get_headers() {
$headers = $this->headers;
/**
* Filter headers that will be sent by Forminator Mailer
*
* @since 1.5
*
* @param array $headers
*/
$headers = apply_filters( 'forminator_mailer_headers', $headers );
return $headers;
}
/**
* Send mail
*
* @since 1.0
* @since 1.5 use `get_headers`
* @return bool
*/
public function send() {
$sent = false;
$headers = $this->get_headers();
if ( ! empty( $this->recipient ) && ! empty( $this->subject ) && ! empty( $this->message ) ) {
$this->clean();
$sent = wp_mail( $this->recipient, $this->subject, $this->message, $headers );
}
return $sent;
}
/**
* Send mail for multiple recipients
*
* @since 1.0.3
* @since 1.5 use `get_headers`
*
* @return bool
*/
public function send_multiple() {
$sent = false;
$headers = $this->get_headers();
if ( ! empty( $this->recipients ) && ! empty( $this->subject ) && ! empty( $this->message ) ) {
$this->clean();
if ( $this->attachment ) {
$sent = wp_mail( $this->recipients, $this->subject, $this->message, $headers, $this->attachment );
} else {
$sent = wp_mail( $this->recipients, $this->subject, $this->message, $headers );
}
}
return $sent;
}
/**
* Check if Form Field value fullfilled the condition
*
* @since 1.0
*
* @param mixed $form_field_value Form field value.
* @param array $condition Condition.
*
* @return bool
*/
public static function is_condition_fulfilled( $form_field_value, $condition ) {
return Forminator_Field::is_condition_fulfilled( $form_field_value, $condition );
}
/**
* Check whether answer is correct for a question on Knowledge Quiz
*
* @since 1.6.2
*
* @param string $slug Question slug.
* @param int $answer_index Answer index.
* @param int $quiz_model Quiz model.
*
* @return bool
*/
public static function is_correct_answer( $slug, $answer_index, $quiz_model ) {
if ( ! empty( $quiz_model->questions ) ) {
foreach ( $quiz_model->questions as $question ) {
if ( isset( $question['slug'] ) && $question['slug'] === $slug ) {
$answers = $question['answers'];
foreach ( $answers as $k => $answer ) {
if ( isset( $answer['toggle'] ) && filter_var( $answer['toggle'], FILTER_VALIDATE_BOOLEAN ) === true ) {
if ( (int) $answer_index === (int) $k ) {
return true;
}
}
}
}
}
}
return false;
}
}