- 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;
This commit is contained in:
Mykyta Synelnikov
2023-05-23 13:57:55 +03:00
parent a6ed1b047f
commit a460146958
2 changed files with 50 additions and 42 deletions
@@ -422,6 +422,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'id' => 'profile_menu_icons', 'id' => 'profile_menu_icons',
'type' => 'checkbox', 'type' => 'checkbox',
'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ), '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 ), 'conditional' => array( 'profile_menu', '=', 1 ),
), ),
) )
+44 -37
View File
@@ -43,7 +43,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
*/ */
public $message = ''; public $message = '';
/** /**
* Mail constructor. * Mail constructor.
*/ */
@@ -53,7 +52,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
add_action( 'plugins_loaded', array( &$this, 'init_paths' ), 99 ); add_action( 'plugins_loaded', array( &$this, 'init_paths' ), 99 );
} }
/** /**
* Mandrill compatibility * Mandrill compatibility
* *
@@ -61,7 +59,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* @param string $message * @param string $message
* @return bool * @return bool
*/ */
function mandrill_nl2br( $nl2br, $message = '' ) { public function mandrill_nl2br( $nl2br, $message = '' ) {
// text emails // text emails
if ( ! UM()->options()->get( 'email_html' ) ) { if ( ! UM()->options()->get( 'email_html' ) ) {
$nl2br = true; $nl2br = true;
@@ -70,11 +68,10 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
return $nl2br; return $nl2br;
} }
/** /**
* Init paths for email notifications * Init paths for email notifications
*/ */
function init_paths() { public function init_paths() {
/** /**
* UM hook * 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 ); $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 * Check blog ID on multisite, return '' if single site
* *
* @return string * @return string
*/ */
function get_blog_id() { public function get_blog_id() {
$blog_id = ''; $blog_id = '';
if ( is_multisite() ) { if ( is_multisite() ) {
$blog_id = '/' . get_current_blog_id(); $blog_id = '/' . get_current_blog_id();
@@ -114,7 +110,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
return $blog_id; return $blog_id;
} }
/** /**
* Locate a template and return the path for inclusion. * Locate a template and return the path for inclusion.
* *
@@ -122,23 +117,27 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* @param string $template_name * @param string $template_name
* @return string * @return string
*/ */
function locate_template( $template_name ) { private function locate_template( $template_name ) {
// check if there is template at theme folder // check if there is template at theme folder
$blog_id = $this->get_blog_id(); $blog_id = $this->get_blog_id();
//get template file from current blog ID folder //get template file from current blog ID folder
$template = locate_template( array( $template = locate_template(
trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name . '.php' 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 ) { if ( is_multisite() && ! $template ) {
$template = locate_template( array( $template = locate_template(
trailingslashit( 'ultimate-member/email' ) . $template_name . '.php' 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 ) { 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'; $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 ); return apply_filters( 'um_locate_email_template', $template, $template_name );
} }
/** /**
* @param $slug * @param $slug
* @param $args * @param $args
* @return bool|string * @return bool|string
*/ */
function get_email_template( $slug, $args = array() ) { public function get_email_template( $slug, $args = array() ) {
$located = $this->locate_template( $slug ); $located = $this->locate_template( $slug );
/** /**
@@ -476,7 +474,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* *
* @return mixed|void * @return mixed|void
*/ */
function get_template_filename( $template_name ) { public function get_template_filename( $template_name ) {
/** /**
* UM hook * UM hook
* *
@@ -501,7 +499,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
return apply_filters( 'um_change_email_template_file', $template_name ); return apply_filters( 'um_change_email_template_file', $template_name );
} }
/** /**
* Locate a template and return the path for inclusion. * Locate a template and return the path for inclusion.
* *
@@ -509,15 +506,17 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* @param string $template_name * @param string $template_name
* @return string * @return string
*/ */
function template_in_theme( $template_name ) { public function template_in_theme( $template_name ) {
$template_name_file = $this->get_template_filename( $template_name ); $template_name_file = $this->get_template_filename( $template_name );
$blog_id = $this->get_blog_id(); $blog_id = $this->get_blog_id();
// check if there is template at theme blog ID folder // check if there is a template at theme blog ID folder
$template = locate_template( array( $template = locate_template(
trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name_file . '.php' array(
) ); trailingslashit( 'ultimate-member/email' . $blog_id ) . $template_name_file . '.php',
)
);
// Return what we found. // Return what we found.
if ( get_template_directory() === get_stylesheet_directory() ) { 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 * @access public
* *
@@ -538,7 +536,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* *
* @return string * @return string
*/ */
function get_template_file( $location, $template_name ) { public function get_template_file( $location, $template_name ) {
$template_path = ''; $template_path = '';
$template_name_file = $this->get_template_filename( $template_name ); $template_name_file = $this->get_template_filename( $template_name );
@@ -555,17 +553,28 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
break; 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 * @param string $template
* @return bool * @return bool
*/ */
function copy_email_template( $template ) { public function copy_email_template( $template ) {
$in_theme = $this->template_in_theme( $template ); $in_theme = $this->template_in_theme( $template );
if ( $in_theme ) { if ( $in_theme ) {
return false; return false;
@@ -588,7 +597,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
} }
} }
/** /**
* UM Placeholders for site url, admin email, submit registration * UM Placeholders for site url, admin email, submit registration
* *
@@ -596,7 +604,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* *
* @return array * @return array
*/ */
function add_placeholder( $placeholders ) { public function add_placeholder( $placeholders ) {
$placeholders[] = '{user_profile_link}'; $placeholders[] = '{user_profile_link}';
$placeholders[] = '{site_url}'; $placeholders[] = '{site_url}';
$placeholders[] = '{admin_email}'; $placeholders[] = '{admin_email}';
@@ -607,7 +615,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
return $placeholders; return $placeholders;
} }
/** /**
* UM Replace Placeholders for site url, admin email, submit registration * UM Replace Placeholders for site url, admin email, submit registration
* *
@@ -615,7 +622,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* *
* @return array * @return array
*/ */
function add_replace_placeholder( $replace_placeholders ) { public function add_replace_placeholder( $replace_placeholders ) {
$replace_placeholders[] = um_user_profile_url(); $replace_placeholders[] = um_user_profile_url();
$replace_placeholders[] = get_bloginfo( 'url' ); $replace_placeholders[] = get_bloginfo( 'url' );
$replace_placeholders[] = um_admin_email(); $replace_placeholders[] = um_admin_email();