Helper::get_site_domain(),
'dce_form_email_to_cc' => '',
'dce_form_email_to_bcc' => '',
];
foreach ($email_fields as $key => $default) {
$setting = $amail[$key];
if (!empty($setting)) {
$email_fields[$key] = $setting;
}
}
$headers = \sprintf('From: %s <%s>' . "\r\n", $email_fields['dce_form_email_from_name'], $email_fields['dce_form_email_from']);
if (!empty($email_fields['dce_form_email_reply_to'])) {
if (\filter_var($email_fields['dce_form_email_reply_to'], \FILTER_VALIDATE_EMAIL)) {
// control if is a valid email
$headers .= \sprintf('Reply-To: %s' . "\r\n", $email_fields['dce_form_email_reply_to']);
}
}
if ($send_html) {
$headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
}
$cc_header = '';
if (!empty($email_fields['dce_form_email_to_cc'])) {
$cc_header = 'Cc: ' . $email_fields['dce_form_email_to_cc'] . "\r\n";
}
$bcc_header = '';
if (!empty($email_fields['dce_form_email_to_bcc'])) {
$bcc_header = 'Bcc: ' . $email_fields['dce_form_email_to_bcc'] . "\r\n";
}
/**
* Email headers.
*
* Filters the additional headers sent when the form send an email.
*
* @since 1.0.0
*
* @param string|array $headers Additional headers.
*/
$headers = apply_filters('elementor_pro/forms/wp_mail_headers', $headers);
/**
* Email content.
*
* Filters the content of the email sent by the form.
*
* @since 1.0.0
*
* @param string $email_content Email content.
*/
if ($use_template) {
// using a template
$inline = '';
if ($amail['dce_form_email_content_template_style'] == 'embed') {
$inline = ' inlinecss="true"';
}
$author = '';
$current_user_id = get_current_user_id();
if ($current_user_id) {
$author = ' author_id="' . $current_user_id . '"';
}
$t_post = '';
if (get_the_ID()) {
$t_post = ' post_id="' . get_the_ID() . '"';
}
$dce_form_email_content = do_shortcode('[dce-elementor-template id="' . $amail['dce_form_email_content_template'] . '"' . $t_post . $inline . $author . ']');
$pdf_attachments = $this->get_email_pdf_attachments($dce_form_email_content, $fields, $amail, $settings);
$all_pdf_attachments += $pdf_attachments;
$upload_attachments = $this->get_email_upload_attachments($dce_form_email_content, $fields, $amail, $settings);
$attachments = $pdf_attachments + $upload_attachments;
$dce_form_email_content = $this->remove_attachment_tokens($dce_form_email_content, $fields);
$dce_form_email_content = $this->replace_content_shortcodes($dce_form_email_content, $record, $line_break);
$dce_form_email_content = Helper::get_dynamic_value($dce_form_email_content, $fields);
if ($amail['dce_form_email_content_template_style']) {
$css = Helper::get_post_css($amail['dce_form_email_content_template']);
// add some fixies
$css .= '/*.elementor-column-wrap,*/ .elementor-widget-wrap { display: block !important; }';
if (!empty($amail['dce_form_email_content_template_layout']) && $amail['dce_form_email_content_template_layout'] != 'flex') {
// from flex to table
$css .= '.elementor-section .elementor-container { display: table !important; width: 100% !important; }';
$css .= '.elementor-row { display: table-row !important; }';
$css .= '.elementor-column { display: table-cell !important; }';
$css .= '.elementor-column-wrap, .elementor-widget-wrap { display: block !important; }';
$css = \str_replace(':not(.elementor-motion-effects-element-type-background) > .elementor-element-populated', ':not(.elementor-motion-effects-element-type-background)', $css);
}
if ($amail['dce_form_email_content_template_style'] == 'inline') {
// https://github.com/tijsverkoyen/CssToInlineStyles
// create instance
$cssToInlineStyles = new \DynamicOOOS\TijsVerkoyen\CssToInlineStyles\CssToInlineStyles();
// output
$dce_form_email_content = $cssToInlineStyles->convert($dce_form_email_content, $css);
}
if (!empty($amail['dce_form_email_content_template_layout']) && $amail['dce_form_email_content_template_layout'] == 'html') {
// from div to table
$dce_form_email_content = Helper::tablefy($dce_form_email_content);
}
if ($amail['dce_form_email_content_template_style'] == 'embed') {
$dce_form_email_content = '' . $dce_form_email_content;
}
}
$dce_form_email_content_txt = '';
} else {
$settings_raw = $record->get('form_settings');
// from message textarea with dynamic token
$dce_form_email_content = $settings_raw['dce_form_email_repeater'][$mkey]['dce_form_email_content'];
$pdf_attachments = $this->get_email_pdf_attachments($dce_form_email_content, $fields, $amail, $settings);
$all_pdf_attachments += $pdf_attachments;
$upload_attachments = $this->get_email_upload_attachments($dce_form_email_content, $fields, $amail, $settings);
$attachments = \array_merge($pdf_attachments, $upload_attachments);
$dce_form_email_content = $this->remove_attachment_tokens($dce_form_email_content, $fields);
$dce_form_email_content = $this->replace_content_shortcodes($dce_form_email_content, $record, $line_break);
$dce_form_email_content = Helper::get_dynamic_value($dce_form_email_content, $fields);
// generate the TEXT/PLAIN version
$dce_form_email_content_txt = $dce_form_email_content;
$dce_form_email_content_txt = \str_replace('
', '
', $dce_form_email_content_txt);
$dce_form_email_content_txt = \str_replace('
', "\n", $dce_form_email_content_txt);
$dce_form_email_content_txt = \str_replace('
', "\n", $dce_form_email_content_txt);
$dce_form_email_content_txt = \strip_tags($dce_form_email_content_txt);
if ($send_html) {
add_action('phpmailer_init', [$this, 'set_wp_mail_altbody']);
} else {
$dce_form_email_content = $dce_form_email_content_txt;
$dce_form_email_content_txt = '';
}
$dce_form_email_content = apply_filters('elementor_pro/forms/wp_mail_message', $dce_form_email_content);
}
self::$txt = $dce_form_email_content_txt;
// replace single fields shorcode
$dce_form_email_content = Helper::replace_setting_shortcodes($dce_form_email_content, $fields);
if ($condition_satisfy) {
$email_sent = wp_mail($email_fields['dce_form_email_to'], $email_fields['dce_form_email_subject'], $dce_form_email_content, $headers . $cc_header . $bcc_header, $attachments);
do_action('elementor_pro/forms/mail_sent', $amail, $record);
if (!$email_sent) {
$ajax_handler->add_error_message(\ElementorPro\Modules\Forms\Classes\Ajax_Handler::get_default_message(\ElementorPro\Modules\Forms\Classes\Ajax_Handler::SERVER_ERROR, $amail));
}
}
if ($amail['dce_form_email_attachments'] && $amail['dce_form_email_attachments_delete']) {
$remove_uploaded_files = \true;
}
if (($amail['dce_form_pdf_attachments_delete'] ?? '') === 'yes') {
$remove_pdf_files = \true;
}
global $phpmailer;
if (isset($phpmailer) && $phpmailer !== NULL) {
$phpmailer->AltBody = '';
// clear the previous alt body for the next email.
}
remove_action('phpmailer_init', [$this, 'set_wp_mail_altbody']);
}
}
if ($remove_pdf_files) {
foreach ($all_pdf_attachments as $pdf_path) {
\unlink($pdf_path);
}
}
if ($remove_uploaded_files && $ajax_handler->is_success) {
if (!empty($fields) && \is_array($fields)) {
foreach ($fields as $akey => $adatas) {
$afield = Helper::get_field($akey, $settings);
if ($afield) {
if ($afield['field_type'] == 'upload') {
$files = Helper::str_to_array(',', $adatas);
if (!empty($files)) {
foreach ($files as $adata) {
if (\filter_var($adata, \FILTER_VALIDATE_URL)) {
$filename = Helper::url_to_path($adata);
if (\is_file($filename)) {
\unlink($filename);
}
}
}
}
}
}
}
}
}
}
public static function set_wp_mail_altbody($phpmailer)
{
if (isset($phpmailer) && $phpmailer !== NULL) {
$phpmailer->AltBody = self::$txt;
}
}
public function remove_attachment_tokens($dce_form_email_content, $fields)
{
$attachments_tokens = \explode(':attachment]', $dce_form_email_content);
foreach ($attachments_tokens as $akey => $avalue) {
$pieces = \explode('[form:', $avalue);
if (\count($pieces) > 2) {
$field = \end($pieces);
if (isset($fields[$field])) {
$dce_form_email_content = \str_replace('[form:' . $field . ':attachment]', '', $dce_form_email_content);
}
}
}
return $dce_form_email_content;
}
public function get_email_pdf_attachments($dce_form_email_content, $fields, $amail, $settings)
{
$attachments = array();
$pdf_attachment = '';
$pdf_form = '[form:pdf]';
$pos_pdf_token = \strpos($dce_form_email_content, $pdf_attachment);
$pos_pdf_form = \strpos($dce_form_email_content, $pdf_form);
if ($pos_pdf_token !== \false || $pos_pdf_form !== \false) {
// add PDF as attachment
global $dce_form;
if (isset($dce_form['pdf']) && isset($dce_form['pdf']['path'])) {
$pdf_path = $dce_form['pdf']['path'];
$attachments[] = $pdf_path;
}
$dce_form_email_content = \str_replace($pdf_attachment, '', $dce_form_email_content);
$dce_form_email_content = \str_replace($pdf_form, '', $dce_form_email_content);
}
$attachments_tokens = \explode(':attachment]', $dce_form_email_content);
foreach ($attachments_tokens as $akey => $avalue) {
$pieces = \explode('[form:', $avalue);
if (\count($pieces) > 1) {
$field = \end($pieces);
if (isset($fields[$field])) {
$files = Helper::str_to_array(',', $fields[$field]);
if (!empty($files)) {
foreach ($files as $adata) {
if (\filter_var($adata, \FILTER_VALIDATE_URL)) {
$file_path = Helper::url_to_path($adata);
if (\is_file($file_path)) {
if (!\in_array($file_path, $attachments)) {
$attachments[] = $file_path;
}
}
}
}
}
}
}
}
return $attachments;
}
public function get_email_upload_attachments($dce_form_email_content, $fields, $amail, $settings)
{
$attachments = [];
if ($amail['dce_form_email_attachments']) {
if (!empty($fields) && \is_array($fields)) {
foreach ($fields as $akey => $adatas) {
$afield = Helper::get_field($akey, $settings);
if ($afield) {
if ($afield['field_type'] == 'upload') {
$files = Helper::str_to_array(',', $adatas);
if (!empty($files)) {
foreach ($files as $adata) {
if (\filter_var($adata, \FILTER_VALIDATE_URL)) {
$file_path = Helper::url_to_path($adata);
if (\is_file($file_path)) {
if (!\in_array($file_path, $attachments)) {
$attachments[] = $file_path;
}
}
}
}
}
}
}
}
}
}
return $attachments;
}
/**
* @copyright Elegant Themes
* @link http://www.elegantthemes.com/
* @license GPLv2
*/
public function replace_content_shortcodes($email_content, $record, $line_break)
{
$all_fields_shortcode = '[all-fields]';
$text = $this->get_shortcode_value($all_fields_shortcode, $email_content, $record, $line_break);
$email_content = \str_replace($all_fields_shortcode, $text, $email_content);
$all_valued_fields_shortcode = '[all-fields|!empty]';
$text = $this->get_shortcode_value($all_valued_fields_shortcode, $email_content, $record, $line_break, \false);
$email_content = \str_replace($all_valued_fields_shortcode, $text, $email_content);
return $email_content;
}
/**
* @copyright Elegant Themes
* @link http://www.elegantthemes.com/
* @license GPLv2
*/
public function get_shortcode_value($shortcode, $email_content, $record, $line_break, $show_empty = \true)
{
$text = '';
if (\false !== \strpos($email_content, $shortcode)) {
foreach ($record->get('fields') as $field) {
$formatted = '';
if (!empty($field['title'])) {
$formatted = \sprintf('%s: %s', $field['title'], $field['value']);
} elseif (!empty($field['value'])) {
$formatted = \sprintf('%s', $field['value']);
}
if ('textarea' === $field['type'] && '
' === $line_break) {
$formatted = \str_replace(["\r\n", "\n", "\r"], '
', $formatted);
}
if (!$show_empty && empty($field['value'])) {
continue;
}
$text .= $formatted . $line_break;
}
}
return $text;
}
public static function add_dce_email_template_type()
{
// Add Email Template Type
$dce_email = 'Elementor\\Modules\\Library\\Documents\\Email';
\Elementor\Plugin::instance()->documents->register_document_type($dce_email::get_name_static(), \Elementor\Modules\Library\Documents\Email::get_class_full_name());
}
public function on_export($element)
{
return $element;
}
}
Fatal error: Uncaught Error: Class '\DynamicContentForElementor\Extensions\DynamicEmail' not found in /home/sportuga/public_html/wp-content/plugins/dynamic-content-for-elementor/class/extensions.php:47
Stack trace:
#0 /home/sportuga/public_html/wp-content/plugins/dynamic-content-for-elementor/class/extensions.php(17): DynamicContentForElementor\Extensions->load_extensions()
#1 /home/sportuga/public_html/wp-content/plugins/dynamic-content-for-elementor/core/plugin.php(220): DynamicContentForElementor\Extensions->__construct()
#2 /home/sportuga/public_html/wp-includes/class-wp-hook.php(324): DynamicContentForElementor\Plugin->add_dce_to_elementor('')
#3 /home/sportuga/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#4 /home/sportuga/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#5 /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php(658): do_action('elementor/init')
#6 /home/sportuga/public_html/wp-includes/class-wp-hook.php(324): Elementor\Plugin in /home/sportuga/public_html/wp-content/plugins/dynamic-content-for-elementor/class/extensions.php on line 47