logger->error($error);
return $error;
}
self::$block_dirs[] = $dir;
return true;
}
/**
* @param string $open
* @param string $inner
* @param string $close
* @param string[] $markers
*
* @return string
*/
static function wrap_html_element($open, $inner, $close, $markers = array('', '')) {
return $open . $markers[0] . $inner . $markers[1] . $close;
}
/**
* @param string $block
* @param string[] $markers
*
* @return string
*/
static function unwrap_html_element($block, $markers = array('', '')) {
if (self::_has_markers($block, $markers)) {
self::_escape_markers($markers);
$pattern = sprintf('/%s(.*?)%s/s', $markers[0], $markers[1]);
$matches = array();
preg_match($pattern, $block, $matches);
return $matches[1];
}
return $block;
}
/**
* @param string $block
* @param string[] $markers
*
* @return bool
*/
private static function _has_markers($block, $markers = array('', '')) {
self::_escape_markers($markers);
$pattern = sprintf('/%s(.*?)%s/s', $markers[0], $markers[1]);
return preg_match($pattern, $block);
}
static function get_html_open($email) {
$open = "\n";
$open .= "\n
\n{email_subject}\n";
$open .= "\n\n";
$open .= "\n";
$open .= "\n";
$open .= "\n";
$open .= '';
$open .= "\n";
$open .= self::get_html_preheader( $email );
return $open;
}
static private function get_html_preheader( $email ) {
if ( empty ( $email->options['preheader'] ) ) {
return "";
}
$preheader_text = $email->options['preheader'];
$html = "$preheader_text
";
$html .= "\n";
return $html;
}
static function get_html_close($email) {
return "\n";
}
/**
*
* @param TNP_Email $email
* @return string
*/
static function get_main_wrapper_open($email) {
if (!isset($email->options['composer_background'])) {
$bgcolor = '#ffffff';
} else {
$bgcolor = $email->options['composer_background'];
}
return "\n\n" .
"\n" .
"| ";
}
/**
*
* @param TNP_Email $email
* @return string
*/
static function get_main_wrapper_close($email) {
return "\n\n" .
" | \n" .
"
\n" .
"
\n\n";
}
/**
* Remove , and unnecessary envelopes for editing with composer
*
* @param string $html_email
*
* @return string
*/
static function unwrap_email($html_email) {
if (self::_has_markers($html_email)) {
$html_email = self::unwrap_html_element($html_email);
} else {
//KEEP FOR OLD EMAIL COMPATIBILITY
// Extracts only the body part
$x = strpos($html_email, '', $x);
$y = strpos($html_email, '');
$html_email = substr($html_email, $x + 1, $y - $x - 1);
}
/* Cleans up uncorrectly stored newsletter bodies */
$html_email = preg_replace('/