diff --git a/includes/admin/core/packages/2.0.php b/includes/admin/core/packages/2.0.php
index c32f3fc4..d805fdc8 100644
--- a/includes/admin/core/packages/2.0.php
+++ b/includes/admin/core/packages/2.0.php
@@ -1133,4 +1133,37 @@ foreach ( $forms as $form_id ) {
update_post_meta( $form_id, "_um_{$form_type}_role", 'um_' . $role );
}
}
+}
+
+
+/**
+ * Transferring email templates to new logic
+ */
+$emails = UM()->config()->email_notifications;
+foreach ( $emails as $email_key => $value ) {
+
+ $in_theme = UM()->mail()->template_in_theme( $email_key, true );
+ $theme_template_path = UM()->mail()->get_template_file( 'theme', $email_key );
+
+ if ( ! $in_theme ) {
+ $setting_value = um_get_option( $email_key );
+
+ UM()->mail()->copy_email_template( $email_key );
+
+ $fp = fopen( $theme_template_path, "w" );
+ $result = fputs( $fp, $setting_value );
+ fclose( $fp );
+ } else {
+ $theme_template_path_html = UM()->mail()->get_template_file( 'theme', $email_key, true );
+
+ $setting_value = preg_replace( '/<\/body>|<\/head>||<\/html>|
|/' , '', file_get_contents( $theme_template_path_html ) );
+
+ if ( file_exists( $theme_template_path_html ) ) {
+ if ( copy( $theme_template_path_html, $theme_template_path ) ) {
+ $fp = fopen( $theme_template_path, "w" );
+ $result = fputs( $fp, $setting_value );
+ fclose( $fp );
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/includes/class-config.php b/includes/class-config.php
index 9df018c3..65e5a5f0 100644
--- a/includes/class-config.php
+++ b/includes/class-config.php
@@ -361,7 +361,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'admin_email' => get_bloginfo('admin_email'),
'mail_from' => get_bloginfo('name'),
'mail_from_addr' => get_bloginfo('admin_email'),
- 'email_html' => 0,
+ 'email_html' => 1,
'image_compression' => 60,
'image_max_width' => 1000,
'cover_min_width' => 1000,
diff --git a/includes/core/class-mail.php b/includes/core/class-mail.php
index e8424407..94835370 100644
--- a/includes/core/class-mail.php
+++ b/includes/core/class-mail.php
@@ -158,9 +158,10 @@ if ( ! class_exists( 'Mail' ) ) {
*
* @access public
* @param string $template_name
+ * @param bool $html
* @return string
*/
- function template_in_theme( $template_name ) {
+ function template_in_theme( $template_name, $html = false ) {
//WPML compatibility and multilingual email templates
$lang = get_locale();
$arr_english_lang = array( 'en', 'en_US', 'en_NZ', 'en_ZA', 'en_AU', 'en_GB' );
@@ -171,9 +172,11 @@ if ( ! class_exists( 'Mail' ) ) {
$lang .= '/';
}
+ $ext = ! $html ? '.php' : '.html';
+
// check if there is template at theme folder
$template = locate_template( array(
- trailingslashit( 'ultimate-member/email' ) . $lang . $template_name . '.php'
+ trailingslashit( 'ultimate-member/email' ) . $lang . $template_name . $ext
) );
// Return what we found.
@@ -187,17 +190,21 @@ if ( ! class_exists( 'Mail' ) ) {
* @access public
* @param string $location
* @param string $template_name
+ * @param bool $html
* @return string
*/
- function get_template_file( $location, $template_name ) {
+ function get_template_file( $location, $template_name, $html = false ) {
$template_path = '';
+
+ $ext = ! $html ? '.php' : '.html';
+
switch( $location ) {
case 'theme':
- $template_path = trailingslashit( get_stylesheet_directory() . '/ultimate-member/email' ) . $template_name . '.php';
+ $template_path = trailingslashit( get_stylesheet_directory() . '/ultimate-member/email' ) . $template_name . $ext;
break;
case 'plugin':
$path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email';
- $template_path = trailingslashit( $path ) . $template_name . '.php';
+ $template_path = trailingslashit( $path ) . $template_name . $ext;
break;
}