mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- fix hooks comments
This commit is contained in:
+156
-187
@@ -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
|
||||
* <?php add_filter( 'um_email_templates_path_by_slug', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_templates_path_by_slug', 'my_email_templates_path_by_slug', 10, 1 );
|
||||
* @param {string} $paths email templates path.
|
||||
*
|
||||
* @return {string} email templates path.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_email_templates_path_by_slug
|
||||
*
|
||||
* @example <caption>Extends extend email templates path.</caption>
|
||||
* 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
|
||||
* <?php add_filter( 'um_locate_email_template', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_locate_email_template', 'my_locate_email_template', 10, 2 );
|
||||
* function my_email_template_body_attrs( $template, $template_name ) {
|
||||
* @param {string} $template email notification template path.
|
||||
* @param {string} $template_name email notification template name.
|
||||
*
|
||||
* @return {string} email notification template path.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_locate_email_template
|
||||
*
|
||||
* @example <caption>Change email notification template path.</caption>
|
||||
* 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
|
||||
* <?php add_filter( 'um_email_template_path', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_template_path', 'my_email_send_subject', 10, 3 );
|
||||
* @param {string} $located Template Location.
|
||||
* @param {string} $slug Template Key.
|
||||
* @param {array} $args Template settings.
|
||||
*
|
||||
* @return {string} email template location.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_email_template_path
|
||||
*
|
||||
* @example <caption>Change email template location.</caption>
|
||||
* function my_email_send_subject( $located, $slug, $args ) {
|
||||
* // your code here
|
||||
* return $located;
|
||||
* }
|
||||
* ?>
|
||||
* add_filter( 'um_email_template_path', 'my_email_send_subject', 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
|
||||
* <?php
|
||||
* add_action( 'um_before_email_template_part', 'my_before_email_template_part', 10, 3 );
|
||||
* @param {string} $slug Email template slug.
|
||||
* @param {string} $located Email template location.
|
||||
* @param {array} $args Email template arguments.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_before_email_template_part
|
||||
*
|
||||
* @example <caption>Action before email template loading.</caption>
|
||||
* 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
|
||||
* <?php
|
||||
* add_action( 'um_after_email_template_part', 'my_after_email_template_part', 10, 3 );
|
||||
* @param {string} $slug Email template slug.
|
||||
* @param {string} $located Email template location.
|
||||
* @param {array} $args Email template arguments.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_after_email_template_part
|
||||
*
|
||||
* @example <caption>Action after email template loading.</caption>
|
||||
* 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. '<html>' by default"},
|
||||
* {"var":"$slug","type":"string","desc":"Template Key"},
|
||||
* {"var":"$args","type":"array","desc":"Template settings"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_email_template_html_formatting', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_template_html_formatting', 'my_email_template_html_formatting', 10, 3 );
|
||||
* @param {string} $header Email notification header.
|
||||
* @param {string} $slug Email Template Key.
|
||||
* @param {array} $args Email Template settings.
|
||||
*
|
||||
* @return {bool} Email notification header.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_email_template_html_formatting
|
||||
*
|
||||
* @example <caption>Change email notification template header.</caption>
|
||||
* 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', '<html>', $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
|
||||
* <?php
|
||||
* add_action( 'um_before_email_template_body', 'my_before_email_template_body', 10, 2 );
|
||||
* @param {string} $slug Email Template Key.
|
||||
* @param {array} $args Email Template settings.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_email_template_html_formatting
|
||||
*
|
||||
* @example <caption>Action before email template body display.</caption>
|
||||
* 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
|
||||
* <?php add_filter( 'um_email_template_body_attrs', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_template_body_attrs', 'my_email_template_body_attrs', 10, 3 );
|
||||
* function my_email_template_body_attrs( $body_atts, $slug, $args ) {
|
||||
* @param {string} $body_atts Email notification body attributes.
|
||||
* @param {string} $slug Email Template Key.
|
||||
* @param {array} $args Email Template settings.
|
||||
*
|
||||
* @return {bool} Email notification body attributes.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_email_template_body_attrs
|
||||
*
|
||||
* @example <caption>Change email notification template body additional attributes.</caption>
|
||||
* function my_email_template_body_attrs( $header, $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' ) ) {
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php } else {
|
||||
<?php
|
||||
} else {
|
||||
|
||||
//strip tags in plain text email
|
||||
//important don't use HTML in plain text emails!
|
||||
$raw_email_template = $this->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
|
||||
* <?php add_filter( 'um_email_send_message_content', 'function_name', 10, 3 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_send_message_content', 'my_email_send_message_content', 10, 3 );
|
||||
* function my_email_send_message_content( $message, $template, $args ) {
|
||||
* @param {string} $message Message Content.
|
||||
* @param {string} $slug Template Key.
|
||||
* @param {array} $args Notification Arguments.
|
||||
*
|
||||
* @return {bool} Message Content.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_email_template_body_attrs
|
||||
*
|
||||
* @example <caption>Change email notification message content.</caption>
|
||||
* function my_email_template_body_attrs( $message, $slug, $args ) {
|
||||
* // your code here
|
||||
* return $message;
|
||||
* }
|
||||
* ?>
|
||||
* add_filter( 'um_email_template_body_attrs', 'my_email_template_body_attrs', 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 <caption>Disabling email notifications programmatically.</caption>
|
||||
* function my_um_disable_email_notification_sending( $disabled, $email, $template, $args ) {
|
||||
* // your code here
|
||||
* return $disabled;
|
||||
* }
|
||||
* add_filter( 'um_disable_email_notification_sending', 'my_um_disable_email_notification_sending', 10, 4 );
|
||||
*/
|
||||
$hook_disabled = apply_filters( 'um_disable_email_notification_sending', false, $email, $template, $args );
|
||||
if ( false !== $hook_disabled ) {
|
||||
@@ -443,26 +413,22 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->mail(), 'add_replace_placeholder' ), 10, 1 );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
* Filters email notification subject.
|
||||
*
|
||||
* @type filter
|
||||
* @title um_email_send_subject
|
||||
* @description Change email notification subject
|
||||
* @input_vars
|
||||
* [{"var":"$subject","type":"string","desc":"Subject"},
|
||||
* {"var":"$key","type":"string","desc":"Template Key"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_email_send_subject', 'function_name', 10, 2 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_email_send_subject', 'my_email_send_subject', 10, 2 );
|
||||
* @param {string} $subject Email Subject.
|
||||
* @param {string} $key Email template key.
|
||||
*
|
||||
* @return {string} Email Subject.
|
||||
*
|
||||
* @since 2.6.1
|
||||
* @hook um_email_send_subject
|
||||
*
|
||||
* @example <caption>Change email notification subject.</caption>
|
||||
* function my_email_send_subject( $subject, $key ) {
|
||||
* // your code here
|
||||
* return $paths;
|
||||
* return $subject;
|
||||
* }
|
||||
* ?>
|
||||
* add_filter( 'um_email_send_subject', 'my_email_send_subject', 10, 2 );
|
||||
*/
|
||||
$subject = apply_filters( 'um_email_send_subject', UM()->options()->get( $template . '_sub' ), $template );
|
||||
$subject = wp_unslash( um_convert_tags( $subject, $args ) );
|
||||
@@ -490,25 +456,21 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
*/
|
||||
public function get_template_filename( $template_name ) {
|
||||
/**
|
||||
* UM hook
|
||||
* Filters email notification template name.
|
||||
*
|
||||
* @type filter
|
||||
* @title um_change_email_template_file
|
||||
* @description Change email notification template path
|
||||
* @input_vars
|
||||
* [{"var":"$template_name","type":"string","desc":"Template Name"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_change_email_template_file', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_change_email_template_file', 'my_change_email_template_file', 10, 1 );
|
||||
* function my_change_email_template_file( $template, $template_name ) {
|
||||
* @param {string} $template_name Email template Name.
|
||||
*
|
||||
* @return {string} Email template Name.
|
||||
*
|
||||
* @since 2.0
|
||||
* @hook um_change_email_template_file
|
||||
*
|
||||
* @example <caption>Change email notification template path.</caption>
|
||||
* function my_change_email_template_file( $template_name ) {
|
||||
* // your code here
|
||||
* return $template;
|
||||
* return $template_name;
|
||||
* }
|
||||
* ?>
|
||||
* add_filter( 'um_change_email_template_file', 'my_change_email_template_file' );
|
||||
*/
|
||||
return apply_filters( 'um_change_email_template_file', $template_name );
|
||||
}
|
||||
@@ -568,16 +530,23 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters an expected path for email template in theme or plugin.
|
||||
* Filters expected path for email template in theme or plugin.
|
||||
*
|
||||
* @param {string} $template_path Expected template path.
|
||||
* @param {string} $location Where to search 'theme||plugin.
|
||||
* @param {string} $template_name_file Expected filename.
|
||||
*
|
||||
* @return {string} Email template path.
|
||||
*
|
||||
* @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.
|
||||
* @example <caption>Change expected path for email template in theme or plugin.</caption>
|
||||
* function my_um_email_get_template_file_path( $template_path, $location, $template_name_file ) {
|
||||
* // your code here
|
||||
* return $template_path;
|
||||
* }
|
||||
* add_filter( 'um_email_get_template_file_path', 'my_um_email_get_template_file_path' );
|
||||
*/
|
||||
return apply_filters( 'um_email_get_template_file_path', $template_path, $location, $template_name_file );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user