diff --git a/includes/core/class-mail.php b/includes/core/class-mail.php index b9f2b7c2..278a658a 100644 --- a/includes/core/class-mail.php +++ b/includes/core/class-mail.php @@ -73,25 +73,21 @@ if ( ! class_exists( 'um\core\Mail' ) ) { */ public function init_paths() { /** - * UM hook + * Filters extend email templates path. * - * @type filter - * @title um_email_templates_path_by_slug - * @description Extend email templates path - * @input_vars - * [{"var":"$paths","type":"array","desc":"Email slug -> Template Path"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * Extends email templates path. * function my_email_templates_path_by_slug( $paths ) { * // your code here * return $paths; * } - * ?> + * add_filter( 'um_email_templates_path_by_slug', 'my_email_templates_path_by_slug' ); */ $this->path_by_slug = apply_filters( 'um_email_templates_path_by_slug', $this->path_by_slug ); } @@ -145,26 +141,22 @@ if ( ! class_exists( 'um\core\Mail' ) ) { // Return what we found. /** - * UM hook + * Filters change email notification template path. * - * @type filter - * @title um_locate_email_template - * @description Change email notification template path - * @input_vars - * [{"var":"$template","type":"string","desc":"Template Path"}, - * {"var":"$template_name","type":"string","desc":"Template Name"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * Change email notification template path. + * function my_locate_email_template( $template, $template_name ) { * // your code here * return $template; * } - * ?> + * add_filter( 'um_locate_email_template', 'my_locate_email_template', 10, 2 ); */ return apply_filters( 'um_locate_email_template', $template, $template_name ); } @@ -178,27 +170,23 @@ if ( ! class_exists( 'um\core\Mail' ) ) { $located = $this->locate_template( $slug ); /** - * UM hook + * Filters change email template location. * - * @type filter - * @title um_email_template_path - * @description Change email template location - * @input_vars - * [{"var":"$located","type":"string","desc":"Template Location"}, - * {"var":"$slug","type":"string","desc":"Template Key"}, - * {"var":"$args","type":"array","desc":"Template settings"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * Change email template location. + * function my_email_template_path( $located, $slug, $args ) { * // your code here * return $located; * } - * ?> + * add_filter( 'um_email_template_path', 'my_email_template_path', 10, 3 ); */ $located = apply_filters( 'um_email_template_path', $located, $slug, $args ); @@ -209,49 +197,40 @@ if ( ! class_exists( 'um\core\Mail' ) ) { ob_start(); /** - * UM hook + * Action before email template loading. * - * @type action - * @title um_before_email_template_part - * @description Action before email template loading - * @input_vars - * [{"var":"$slug","type":"string","desc":"Email template slug"}, - * {"var":"$located","type":"string","desc":"Email template location"}, - * {"var":"$args","type":"array","desc":"Email template arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_before_email_template_part', 'function_name', 10, 3 ); - * @example - * Action before email template loading. * function my_before_email_template_part( $slug, $located, $args ) { * // your code here * } - * ?> + * add_filter( 'um_before_email_template_part', 'my_before_email_template_part', 10, 3 ); */ do_action( 'um_before_email_template_part', $slug, $located, $args ); include( $located ); + /** - * UM hook + * Action after email template loading. * - * @type action - * @title um_after_email_template_part - * @description Action after email template loading - * @input_vars - * [{"var":"$slug","type":"string","desc":"Email template slug"}, - * {"var":"$located","type":"string","desc":"Email template location"}, - * {"var":"$args","type":"array","desc":"Email template arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_email_template_part', 'function_name', 10, 3 ); - * @example - * Action after email template loading. * function my_after_email_template_part( $slug, $located, $args ) { * // your code here * } - * ?> + * add_filter( 'um_after_email_template_part', 'my_after_email_template_part', 10, 3 ); */ do_action( 'um_after_email_template_part', $slug, $located, $args ); @@ -266,80 +245,67 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * @param $args * @return mixed|string */ - function prepare_template( $slug, $args = array() ) { + public function prepare_template( $slug, $args = array() ) { ob_start(); if ( UM()->options()->get( 'email_html' ) ) { /** - * UM hook + * Filters change email notification template header. * - * @type filter - * @title um_email_template_html_formatting - * @description Change email notification template header - * @input_vars - * [{"var":"$header","type":"string","desc":"Email notification header. '' by default"}, - * {"var":"$slug","type":"string","desc":"Template Key"}, - * {"var":"$args","type":"array","desc":"Template settings"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * Change email notification template header. * function my_email_template_html_formatting( $header, $slug, $args ) { * // your code here * return $header; * } - * ?> + * add_filter( 'um_email_template_html_formatting', 'my_email_template_html_formatting', 10, 3 ); */ echo apply_filters( 'um_email_template_html_formatting', '', $slug, $args ); /** - * UM hook + * Action before email template body display. * - * @type action - * @title um_before_email_template_body - * @description Action before email template body display - * @input_vars - * [{"var":"$slug","type":"string","desc":"Email template slug"}, - * {"var":"$args","type":"array","desc":"Email template arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_before_email_template_body', 'function_name', 10, 2 ); - * @example - * Action before email template body display. * function my_before_email_template_body( $slug, $args ) { * // your code here * } - * ?> + * add_filter( 'um_before_email_template_body', 'my_before_email_template_body', 10, 2 ); */ do_action( 'um_before_email_template_body', $slug, $args ); /** - * UM hook + * Filters change email notification template body additional attributes. * - * @type filter - * @title um_email_template_body_attrs - * @description Change email notification template body additional attributes - * @input_vars - * [{"var":"$body_atts","type":"string","desc":"Email notification body attributes"}, - * {"var":"$slug","type":"string","desc":"Template Key"}, - * {"var":"$args","type":"array","desc":"Template settings"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * Change email notification template body additional attributes. * function my_email_template_body_attrs( $body_atts, $slug, $args ) { * // your code here * return $body_atts; * } - * ?> + * add_filter( 'um_email_template_body_attrs', 'my_email_template_body_attrs', 10, 3 ); */ $body_attrs = apply_filters( 'um_email_template_body_attrs', 'style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;"', $slug, $args ); ?> @@ -352,14 +318,15 @@ if ( ! class_exists( 'um\core\Mail' ) ) { - get_email_template( $slug, $args ); + $raw_email_template = $this->get_email_template( $slug, $args ); $plain_email_template = strip_tags( $raw_email_template ); - if( $plain_email_template !== $raw_email_template ){ - $plain_email_template = preg_replace( array('/ /mi', '/^\s+/mi'), array(' ', ''), $plain_email_template ); + if ( $plain_email_template !== $raw_email_template ) { + $plain_email_template = preg_replace( array( '/ /mi', '/^\s+/mi' ), array( ' ', '' ), $plain_email_template ); } echo $plain_email_template; @@ -368,27 +335,23 @@ if ( ! class_exists( 'um\core\Mail' ) ) { $message = ob_get_clean(); /** - * UM hook + * Filters change email notification message content. * - * @type filter - * @title um_email_send_message_content - * @description Change email notification message content - * @input_vars - * [{"var":"$message","type":"string","desc":"Message Content"}, - * {"var":"$template","type":"string","desc":"Template Key"}, - * {"var":"$args","type":"string","desc":"Notification Arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * Change email notification message content. + * function my_email_send_message_content( $message, $slug, $args ) { * // your code here * return $message; * } - * ?> + * add_filter( 'um_email_send_message_content', 'my_email_send_message_content', 10, 3 ); */ $message = apply_filters( 'um_email_send_message_content', $message, $slug, $args ); @@ -415,10 +378,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) { return; } /** - * Filters for disabling email notifications programmatically. - * - * @since 2.6.1 - * @hook um_disable_email_notification_sending + * Filters disabling email notifications programmatically. * * @param {bool} $disabled Does an email is disabled programmatically. By default it is false. * @param {string} $email Email address for sending. @@ -426,6 +386,16 @@ if ( ! class_exists( 'um\core\Mail' ) ) { * @param {array} $args Arguments for sending email. * * @return {bool} `true` if email is disabled programmatically. + * + * @since 2.6.1 + * @hook um_disable_email_notification_sending + * + * @example