function style_mail($vars) { $options = $this->get_options(); $theme_options = $this->get_theme_options('default'); $template = $this->get_template($theme_options); extract($vars); $sender_plugin = Haet_Sender_Plugin::detect_plugin($vars); if (!$sender_plugin) { $use_template = true; } else { $use_template = $sender_plugin->use_template(); } //$message.='<pre>=====POST:'.print_r($_POST,true).'</pre>'; // $message.='SENDER-PLUGIN: <pre>'.print_r($sender_plugin,true).'</pre><br>'; // $message.='ACTIVE-PLUGINS: <pre>'.print_r(Haet_Sender_Plugin::get_active_plugins(),true).'</pre><br>'; $use_template = apply_filters('haet_mail_use_template', $use_template, array($to, $subject, $message, $headers, $attachments, $sender_plugin ? $sender_plugin->get_plugin_name() : null)); if ($use_template) { $message = preg_replace('/\\<http(.*)\\>/', '<a href="http$1">http$1</a>', $message); //replace links like <http://... with <a href="http://..." if ($sender_plugin) { $message = $sender_plugin->modify_content($message); $template = $sender_plugin->modify_template($template); } else { $message = wpautop($message); } $message = str_replace('{#mailcontent#}', $message, $template); $message = str_replace('{#mailsubject#}', $subject, $message); $message = stripslashes(str_replace('\\"', '', $message)); if (isset($sender_plugin)) { $message = $sender_plugin->modify_styled_mail($message); $message = str_replace('###plugin-class###', 'plugin-' . $sender_plugin->get_plugin_name(), $message); } $message = $this->inline_css($message); $has_html_header = false; if (is_array($headers)) { foreach ($headers as $header) { if (stripos($header, 'text/html')) { $has_html_header = true; } } } if (!$has_html_header) { $headers .= "\r\nContent-Type: text/html; charset=" . get_bloginfo('charset') . ";\r\n"; } } $use_sender = !$sender_plugin || $sender_plugin->use_sender(); $use_sender = apply_filters('haet_mail_use_sender', $use_sender, array($to, $subject, $message, $headers, $attachments, $sender_plugin ? $sender_plugin->get_plugin_name() : null)); if ($use_sender) { add_filter('wp_mail_from', array($this, 'set_mail_from_address'), 0); add_filter('wp_mail_from_name', array($this, 'set_mail_sender_name'), 0); } // Field values in Ninja Forms and of course also in other plugins are encoded and otherwise not suitable for subjects $subject = html_entity_decode($subject); return compact('to', 'subject', 'message', 'headers', 'attachments'); }
public static function hook_plugins() { $active_plugins = Haet_Sender_Plugin::get_active_plugins(); foreach ($active_plugins as $plugin) { $plugin['class']::plugin_actions_and_filters(); } }