- used wp_mkdir to avoid the filesystem conflict;
This commit is contained in:
Nikita Sinelnikov
2022-12-13 15:52:57 +02:00
parent 0f8b87f288
commit 8b5bb5d784
2 changed files with 14 additions and 23 deletions
+6 -6
View File
@@ -3457,7 +3457,6 @@ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ?
* @return array
*/
function save_email_templates( $settings ) {
if ( empty( $settings['um_email_template'] ) ) {
return $settings;
}
@@ -3466,16 +3465,17 @@ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ?
$content = wp_kses_post( stripslashes( $settings[ $template ] ) );
$theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
if ( ! file_exists( $theme_template_path ) ) {
UM()->mail()->copy_email_template( $template );
}
$fp = fopen( $theme_template_path, "w" );
$result = fputs( $fp, $content );
fclose( $fp );
if ( file_exists( $theme_template_path ) ) {
$fp = fopen( $theme_template_path, "w" );
$result = fputs( $fp, $content );
fclose( $fp );
}
if ( $result !== false ) {
if ( isset( $result ) && $result !== false ) {
unset( $settings['um_email_template'] );
unset( $settings[ $template ] );
}
+8 -17
View File
@@ -552,28 +552,19 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* @return bool
*/
function copy_email_template( $template ) {
$in_theme = $this->template_in_theme( $template );
if ( $in_theme ) {
return false;
}
$plugin_template_path = $this->get_template_file( 'plugin', $template );
$theme_template_path = $this->get_template_file( 'theme', $template );
$plugin_template_path = wp_normalize_path( $this->get_template_file( 'plugin', $template ) );
$theme_template_path = wp_normalize_path( $this->get_template_file( 'theme', $template ) );
$template_filename = $this->get_template_filename( $template ) . '.php';
$temp_path = str_replace( trailingslashit( get_stylesheet_directory() ), '', $theme_template_path );
$temp_path = str_replace( '/', DIRECTORY_SEPARATOR, $temp_path );
$folders = explode( DIRECTORY_SEPARATOR, $temp_path );
$folders = array_splice( $folders, 0, count( $folders ) - 1 );
$cur_folder = '';
$theme_dir = trailingslashit( get_stylesheet_directory() );
foreach ( $folders as $folder ) {
$prev_dir = $cur_folder;
$cur_folder .= $folder . DIRECTORY_SEPARATOR;
if ( ! is_dir( $theme_dir . $cur_folder ) && wp_is_writable( $theme_dir . $prev_dir ) ) {
mkdir( $theme_dir . $cur_folder, 0777 );
}
$template_dir = wp_normalize_path( str_replace( $template_filename, '', $theme_template_path ) );
$result = wp_mkdir_p( $template_dir );
if ( ! $result ) {
return false;
}
if ( file_exists( $plugin_template_path ) && copy( $plugin_template_path, $theme_template_path ) ) {
@@ -621,4 +612,4 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
return $replace_placeholders;
}
}
}
}