mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- transferring emails to UM2.0 logic;
- first install email notifications settings;
This commit is contained in:
@@ -1134,3 +1134,36 @@ foreach ( $forms as $form_id ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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>|<\/html>|<body.*?>|<head.*?>/' , '', 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user