From cf3835d5e2cd3bd2f53c52c6fd1f60a84ba6490f Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Wed, 30 May 2018 11:09:37 +0300 Subject: [PATCH 1/5] - deprecated old functions; --- includes/core/class-mail.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/core/class-mail.php b/includes/core/class-mail.php index 330c8290..2b70c166 100644 --- a/includes/core/class-mail.php +++ b/includes/core/class-mail.php @@ -500,6 +500,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) { /** * Ajax copy template to the theme * + * @deprecated since 2.0.17 + * * @param bool $template * @return bool */ @@ -538,6 +540,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) { /** * Delete Email Notification Template + * + * @deprecated since 2.0.17 */ function delete_email_template() { $template = $_POST['email_key']; From ca40103d9b4da35493207c4c0d788248b985a3ff Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Wed, 30 May 2018 18:34:24 +0300 Subject: [PATCH 2/5] - multisite email templates; --- includes/admin/core/class-admin-settings.php | 7 +++-- includes/core/class-mail.php | 31 ++++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 29ff98fc..51c9993e 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -2526,11 +2526,12 @@ Use Only Cookies: mail()->get_template_file( 'theme', $template ); @@ -2545,7 +2546,7 @@ Use Only Cookies: get_blog_id(); + $template = locate_template( array( - trailingslashit( 'ultimate-member/email' ) . $template_name . '.php' + trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name . '.php' ) ); //if there isn't template at theme folder get template file from plugin dir @@ -446,9 +449,11 @@ if ( ! class_exists( 'um\core\Mail' ) ) { $template_name_file = $this->get_template_filename( $template_name ); $ext = ! $html ? '.php' : '.html'; + $blog_id = $this->get_blog_id(); + // check if there is template at theme folder $template = locate_template( array( - trailingslashit( 'ultimate-member/email' ) . $template_name_file . $ext + trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name_file . $ext ) ); // Return what we found. @@ -456,6 +461,21 @@ if ( ! class_exists( 'um\core\Mail' ) ) { } + /** + * Check blog ID on multisite, return '' if single site + * + * @return string + */ + function get_blog_id() { + $blog_id = ''; + if ( is_multisite() ) { + $blog_id = '/' . get_current_blog_id(); + } + + return $blog_id; + } + + /** * Method returns expected path for template * @@ -473,7 +493,10 @@ if ( ! class_exists( 'um\core\Mail' ) ) { switch( $location ) { case 'theme': - $template_path = trailingslashit( get_stylesheet_directory() . '/ultimate-member/email' ). $template_name_file . $ext; + //save email template in blog ID folder if we use multisite + $blog_id = $this->get_blog_id(); + + $template_path = trailingslashit( get_stylesheet_directory() . '/ultimate-member/email' . $blog_id ). $template_name_file . $ext; break; case 'plugin': $path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email'; @@ -488,8 +511,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) { /** * Ajax copy template to the theme * - * @deprecated since 2.0.17 - * * @param bool $template * @return bool */ From 1f2c65a6586bf5d46efc40bf27fa7974d1e13e8b Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Wed, 6 Jun 2018 18:08:27 +0300 Subject: [PATCH 3/5] - fixed getting email templates for Network active themes; --- includes/core/class-mail.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/includes/core/class-mail.php b/includes/core/class-mail.php index 6a629a69..e355594e 100644 --- a/includes/core/class-mail.php +++ b/includes/core/class-mail.php @@ -366,13 +366,20 @@ if ( ! class_exists( 'um\core\Mail' ) ) { */ function locate_template( $template_name ) { // check if there is template at theme folder - $blog_id = $this->get_blog_id(); + //get template file from current blog ID folder $template = locate_template( array( trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name . '.php' ) ); + //if there isn't template at theme folder for current blog ID get template file from theme folder + if ( is_multisite() && ! $template ) { + $template = locate_template( array( + trailingslashit( 'ultimate-member/email' ) . $template_name . '.php' + ) ); + } + //if there isn't template at theme folder get template file from plugin dir if ( ! $template ) { $path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email'; @@ -451,11 +458,18 @@ if ( ! class_exists( 'um\core\Mail' ) ) { $blog_id = $this->get_blog_id(); - // check if there is template at theme folder + // check if there is template at theme blog ID folder $template = locate_template( array( trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name_file . $ext ) ); + //if there isn't template at theme folder for current blog ID get template file from theme folder + if ( is_multisite() && ! $template ) { + $template = locate_template( array( + trailingslashit( 'ultimate-member/email' ) . $template_name_file . $ext + ) ); + } + // Return what we found. return ! $template ? false : true; } From d856188e60cf9b99c6fcbbc640a4d305bfe6d6fc Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 7 Jun 2018 01:01:42 +0300 Subject: [PATCH 4/5] - fixed email templates for multisite; - fixed upgrade script to 2.0.x version for multisites; --- .../admin/assets/css/um-admin-settings.css | 8 - includes/admin/assets/js/um-admin-settings.js | 38 --- includes/admin/core/class-admin-enqueue.php | 1 - includes/admin/core/class-admin-forms.php | 5 - includes/admin/core/class-admin-settings.php | 10 +- .../packages/2.0-beta1/email_templates.php | 232 ++++++++++++++++-- includes/core/class-mail.php | 227 ++++++++--------- 7 files changed, 311 insertions(+), 210 deletions(-) diff --git a/includes/admin/assets/css/um-admin-settings.css b/includes/admin/assets/css/um-admin-settings.css index f26d9a8a..113d921d 100644 --- a/includes/admin/assets/css/um-admin-settings.css +++ b/includes/admin/assets/css/um-admin-settings.css @@ -240,14 +240,6 @@ th.column-email.column-primary { } */ -.email_template_wrapper .reset_email_template { - display: none; -} - -.email_template_wrapper.in_theme .reset_email_template { - display: block; -} - .um_setting_ajax_button_response.complete { color:darkgreen; font-style: italic; diff --git a/includes/admin/assets/js/um-admin-settings.js b/includes/admin/assets/js/um-admin-settings.js index 654c92a9..27533528 100644 --- a/includes/admin/assets/js/um-admin-settings.js +++ b/includes/admin/assets/js/um-admin-settings.js @@ -1,42 +1,4 @@ jQuery( document ).ready( function() { - /** - * Email templates - */ - /*jQuery( 'body' ).on( 'click', '.copy_email_template', function() { - var obj = jQuery(this); - - jQuery.ajax({ - url: php_data.copy_email_template, - type: 'POST', - data: { email_key : obj.parents('.email_template_wrapper').data('key') }, - success: function(data){ - obj.parents('.email_template_wrapper').addClass('in_theme'); - }, - error: function(data){ - alert('Something went wrong'); - } - }); - });*/ - - jQuery( 'body' ).on( 'click', '.reset_email_template', function() { - var obj = jQuery(this); - - jQuery.ajax({ - url: php_data.delete_email_template, - type: 'POST', - data: { email_key : obj.parents('.email_template_wrapper').data('key') }, - success: function(data){ - obj.parents('.email_template_wrapper').removeClass('in_theme'); - }, - error: function(data){ - alert('Something went wrong'); - } - }); - }); - - - - /** * Licenses */ diff --git a/includes/admin/core/class-admin-enqueue.php b/includes/admin/core/class-admin-enqueue.php index f88469e7..b4ff56c6 100644 --- a/includes/admin/core/class-admin-enqueue.php +++ b/includes/admin/core/class-admin-enqueue.php @@ -156,7 +156,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { wp_enqueue_script( 'um_admin_settings' ); $localize_data = array( - 'delete_email_template' => UM()->get_ajax_route( 'um\core\Mail', 'delete_email_template' ), 'onbeforeunload_text' => __( 'Are sure, maybe some settings not saved', 'ultimate-member' ), 'texts' => array( 'remove' => __( 'Remove', 'ultimate-member' ), diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php index 6b6fb523..23765394 100644 --- a/includes/admin/core/class-admin-forms.php +++ b/includes/admin/core/class-admin-forms.php @@ -1040,11 +1040,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { ob_start(); ?>