From a460146958d320e710a1234ea8c5c31ea0c90b6c Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Tue, 23 May 2023 13:57:55 +0300 Subject: [PATCH] - alternative #1167, #1166 because there had been used already existing hook with other attributes; - added description for the "Enable menu icons in desktop view" option; --- includes/admin/core/class-admin-settings.php | 1 + includes/core/class-mail.php | 91 +++++++++++--------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index a3a090f1..e84ee6c0 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -422,6 +422,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'id' => 'profile_menu_icons', 'type' => 'checkbox', 'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ), + 'description' => __( '"Desktop view" means the profile block\'s width lower than 800px', 'ultimate-member' ), 'conditional' => array( 'profile_menu', '=', 1 ), ), ) diff --git a/includes/core/class-mail.php b/includes/core/class-mail.php index c025dd73..ac8f170f 100644 --- a/includes/core/class-mail.php +++ b/includes/core/class-mail.php @@ -43,7 +43,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) { */ public $message = ''; - /** * Mail constructor. */ @@ -53,7 +52,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) { add_action( 'plugins_loaded', array( &$this, 'init_paths' ), 99 ); } - /** * Mandrill compatibility * @@ -61,7 +59,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * @param string $message * @return bool */ - function mandrill_nl2br( $nl2br, $message = '' ) { + public function mandrill_nl2br( $nl2br, $message = '' ) { // text emails if ( ! UM()->options()->get( 'email_html' ) ) { $nl2br = true; @@ -70,11 +68,10 @@ if ( ! class_exists( 'um\core\Mail' ) ) { return $nl2br; } - /** * Init paths for email notifications */ - function init_paths() { + public function init_paths() { /** * UM hook * @@ -99,13 +96,12 @@ if ( ! class_exists( 'um\core\Mail' ) ) { $this->path_by_slug = apply_filters( 'um_email_templates_path_by_slug', $this->path_by_slug ); } - /** * Check blog ID on multisite, return '' if single site * * @return string */ - function get_blog_id() { + public function get_blog_id() { $blog_id = ''; if ( is_multisite() ) { $blog_id = '/' . get_current_blog_id(); @@ -114,7 +110,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) { return $blog_id; } - /** * Locate a template and return the path for inclusion. * @@ -122,25 +117,29 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * @param string $template_name * @return string */ - function locate_template( $template_name ) { + private 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' - ) ); + $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 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' - ) ); + $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 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'; + $path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email'; $template = trailingslashit( $path ) . $template_name . '.php'; } @@ -170,13 +169,12 @@ if ( ! class_exists( 'um\core\Mail' ) ) { return apply_filters( 'um_locate_email_template', $template, $template_name ); } - /** * @param $slug * @param $args * @return bool|string */ - function get_email_template( $slug, $args = array() ) { + public function get_email_template( $slug, $args = array() ) { $located = $this->locate_template( $slug ); /** @@ -476,7 +474,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * * @return mixed|void */ - function get_template_filename( $template_name ) { + public function get_template_filename( $template_name ) { /** * UM hook * @@ -501,7 +499,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) { return apply_filters( 'um_change_email_template_file', $template_name ); } - /** * Locate a template and return the path for inclusion. * @@ -509,15 +506,17 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * @param string $template_name * @return string */ - function template_in_theme( $template_name ) { + public function template_in_theme( $template_name ) { $template_name_file = $this->get_template_filename( $template_name ); $blog_id = $this->get_blog_id(); - // check if there is template at theme blog ID folder - $template = locate_template( array( - trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name_file . '.php' - ) ); + // check if there is a template at theme blog ID folder + $template = locate_template( + array( + trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name_file . '.php', + ) + ); // Return what we found. if ( get_template_directory() === get_stylesheet_directory() ) { @@ -527,9 +526,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) { } } - /** - * Method returns expected path for template + * Method returns an expected path for template * * @access public * @@ -538,34 +536,45 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * * @return string */ - function get_template_file( $location, $template_name ) { - $template_path = ''; + public function get_template_file( $location, $template_name ) { + $template_path = ''; $template_name_file = $this->get_template_filename( $template_name ); - switch( $location ) { + switch ( $location ) { case 'theme': //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 . '.php'; + $template_path = trailingslashit( get_stylesheet_directory() . '/ultimate-member/email' . $blog_id ) . $template_name_file . '.php'; break; case 'plugin': - $path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email'; + $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'; break; } - return $template_path; + /** + * Filters an expected path for email template in theme or plugin. + * + * @since 2.6.1 + * @hook um_email_get_template_file_path + * + * @param {string} $template_path Expected template path. + * @param {string} $location Where to search 'theme||plugin'. + * @param {string} $template_name_file Expected filename. + * + * @return {string} Expected template path. + */ + return apply_filters( 'um_email_get_template_file_path', $template_path, $location, $template_name_file ); } - /** - * Ajax copy template to the theme + * Copy template to the theme * * @param string $template * @return bool */ - function copy_email_template( $template ) { + public function copy_email_template( $template ) { $in_theme = $this->template_in_theme( $template ); if ( $in_theme ) { return false; @@ -588,7 +597,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) { } } - /** * UM Placeholders for site url, admin email, submit registration * @@ -596,7 +604,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * * @return array */ - function add_placeholder( $placeholders ) { + public function add_placeholder( $placeholders ) { $placeholders[] = '{user_profile_link}'; $placeholders[] = '{site_url}'; $placeholders[] = '{admin_email}'; @@ -607,7 +615,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) { return $placeholders; } - /** * UM Replace Placeholders for site url, admin email, submit registration * @@ -615,7 +622,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * * @return array */ - function add_replace_placeholder( $replace_placeholders ) { + public function add_replace_placeholder( $replace_placeholders ) { $replace_placeholders[] = um_user_profile_url(); $replace_placeholders[] = get_bloginfo( 'url' ); $replace_placeholders[] = um_admin_email();