BP_Email:: __construct (字符串email_type美元)
构造函数。
描述
设置电子邮件类型和默认“从”和“回复到”的名称和地址。
参数
- email_type美元
-
(字符串)(必需)特定类型的电子邮件的唯一标识符。
源
文件:bp-core /类/ class-bp-email.php
Public function __construct($email_type) {$this->type = $email_type;//不总是设置SERVER_NAME(例如CLI)。如果(!($_SERVER['SERVER_NAME']) {$domain = strtolower($_SERVER['SERVER_NAME']);If (substr($domain, 0, 4) === 'www.') {$domain = substr($domain, 4);}} elseif (function_exists('gethostname') && gethostname() !== false) {$domain = gethostname();} elseif (php_uname('n') !== false) {$domain = php_uname('n');} else {$domain = 'localhost.localdomain';} //在进入数据库时,在sanitize_option()中使用esc_html进行转义。$from_name = wp_specialchars_decode(bp_get_option('blogname'), ENT_QUOTES); $from_address = "wordpress@$domain"; /** This filter is documented in wp-includes/pluggable.php */ $from_address = apply_filters( 'wp_mail_from', $from_address ); /** This filter is documented in wp-includes/pluggable.php */ $from_name = apply_filters( 'wp_mail_from_name', $from_name ); $this->set_from( $from_address, $from_name ); $this->set_reply_to( bp_get_option( 'admin_email' ), $from_name ); /** * Fires inside __construct() method for BP_Email class. * * @since BuddyPress 2.5.0 * * @param string $email_type Unique identifier for this type of email. * @param BP_Email $this Current instance of the email type class. */ do_action( 'bp_email', $email_type, $this ); }
更新日志
版本 | 描述 |
---|---|
BuddyPress 2.5.0 | 介绍了。 |