Edit File by line
/home/barbar84/public_h.../wp-inclu...
File: pluggable.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* These functions can be replaced via plugins. If plugins do not redefine these
[2] Fix | Delete
* functions, then these will be used instead.
[3] Fix | Delete
*
[4] Fix | Delete
* @package WordPress
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! function_exists( 'wp_set_current_user' ) ) :
[8] Fix | Delete
/**
[9] Fix | Delete
* Changes the current user by ID or name.
[10] Fix | Delete
*
[11] Fix | Delete
* Set $id to null and specify a name if you do not know a user's ID.
[12] Fix | Delete
*
[13] Fix | Delete
* Some WordPress functionality is based on the current user and not based on
[14] Fix | Delete
* the signed in user. Therefore, it opens the ability to edit and perform
[15] Fix | Delete
* actions on users who aren't signed in.
[16] Fix | Delete
*
[17] Fix | Delete
* @since 2.0.3
[18] Fix | Delete
*
[19] Fix | Delete
* @global WP_User $current_user The current user object which holds the user data.
[20] Fix | Delete
*
[21] Fix | Delete
* @param int $id User ID
[22] Fix | Delete
* @param string $name User's username
[23] Fix | Delete
* @return WP_User Current user User object
[24] Fix | Delete
*/
[25] Fix | Delete
function wp_set_current_user( $id, $name = '' ) {
[26] Fix | Delete
global $current_user;
[27] Fix | Delete
[28] Fix | Delete
// If `$id` matches the current user, there is nothing to do.
[29] Fix | Delete
if ( isset( $current_user )
[30] Fix | Delete
&& ( $current_user instanceof WP_User )
[31] Fix | Delete
&& ( $id == $current_user->ID )
[32] Fix | Delete
&& ( null !== $id )
[33] Fix | Delete
) {
[34] Fix | Delete
return $current_user;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
$current_user = new WP_User( $id, $name );
[38] Fix | Delete
[39] Fix | Delete
setup_userdata( $current_user->ID );
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Fires after the current user is set.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 2.0.1
[45] Fix | Delete
*/
[46] Fix | Delete
do_action( 'set_current_user' );
[47] Fix | Delete
[48] Fix | Delete
return $current_user;
[49] Fix | Delete
}
[50] Fix | Delete
endif;
[51] Fix | Delete
[52] Fix | Delete
if ( ! function_exists( 'wp_get_current_user' ) ) :
[53] Fix | Delete
/**
[54] Fix | Delete
* Retrieve the current user object.
[55] Fix | Delete
*
[56] Fix | Delete
* Will set the current user, if the current user is not set. The current user
[57] Fix | Delete
* will be set to the logged-in person. If no user is logged-in, then it will
[58] Fix | Delete
* set the current user to 0, which is invalid and won't have any permissions.
[59] Fix | Delete
*
[60] Fix | Delete
* @since 2.0.3
[61] Fix | Delete
*
[62] Fix | Delete
* @see _wp_get_current_user()
[63] Fix | Delete
* @global WP_User $current_user Checks if the current user is set.
[64] Fix | Delete
*
[65] Fix | Delete
* @return WP_User Current WP_User instance.
[66] Fix | Delete
*/
[67] Fix | Delete
function wp_get_current_user() {
[68] Fix | Delete
return _wp_get_current_user();
[69] Fix | Delete
}
[70] Fix | Delete
endif;
[71] Fix | Delete
[72] Fix | Delete
if ( ! function_exists( 'get_userdata' ) ) :
[73] Fix | Delete
/**
[74] Fix | Delete
* Retrieve user info by user ID.
[75] Fix | Delete
*
[76] Fix | Delete
* @since 0.71
[77] Fix | Delete
*
[78] Fix | Delete
* @param int $user_id User ID
[79] Fix | Delete
* @return WP_User|false WP_User object on success, false on failure.
[80] Fix | Delete
*/
[81] Fix | Delete
function get_userdata( $user_id ) {
[82] Fix | Delete
return get_user_by( 'id', $user_id );
[83] Fix | Delete
}
[84] Fix | Delete
endif;
[85] Fix | Delete
[86] Fix | Delete
if ( ! function_exists( 'get_user_by' ) ) :
[87] Fix | Delete
/**
[88] Fix | Delete
* Retrieve user info by a given field
[89] Fix | Delete
*
[90] Fix | Delete
* @since 2.8.0
[91] Fix | Delete
* @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter.
[92] Fix | Delete
*
[93] Fix | Delete
* @param string $field The field to retrieve the user with. id | ID | slug | email | login.
[94] Fix | Delete
* @param int|string $value A value for $field. A user ID, slug, email address, or login name.
[95] Fix | Delete
* @return WP_User|false WP_User object on success, false on failure.
[96] Fix | Delete
*/
[97] Fix | Delete
function get_user_by( $field, $value ) {
[98] Fix | Delete
$userdata = WP_User::get_data_by( $field, $value );
[99] Fix | Delete
[100] Fix | Delete
if ( ! $userdata ) {
[101] Fix | Delete
return false;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
$user = new WP_User;
[105] Fix | Delete
$user->init( $userdata );
[106] Fix | Delete
[107] Fix | Delete
return $user;
[108] Fix | Delete
}
[109] Fix | Delete
endif;
[110] Fix | Delete
[111] Fix | Delete
if ( ! function_exists( 'cache_users' ) ) :
[112] Fix | Delete
/**
[113] Fix | Delete
* Retrieve info for user lists to prevent multiple queries by get_userdata()
[114] Fix | Delete
*
[115] Fix | Delete
* @since 3.0.0
[116] Fix | Delete
*
[117] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[118] Fix | Delete
*
[119] Fix | Delete
* @param array $user_ids User ID numbers list
[120] Fix | Delete
*/
[121] Fix | Delete
function cache_users( $user_ids ) {
[122] Fix | Delete
global $wpdb;
[123] Fix | Delete
[124] Fix | Delete
$clean = _get_non_cached_ids( $user_ids, 'users' );
[125] Fix | Delete
[126] Fix | Delete
if ( empty( $clean ) ) {
[127] Fix | Delete
return;
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
$list = implode( ',', $clean );
[131] Fix | Delete
[132] Fix | Delete
$users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );
[133] Fix | Delete
[134] Fix | Delete
$ids = array();
[135] Fix | Delete
foreach ( $users as $user ) {
[136] Fix | Delete
update_user_caches( $user );
[137] Fix | Delete
$ids[] = $user->ID;
[138] Fix | Delete
}
[139] Fix | Delete
update_meta_cache( 'user', $ids );
[140] Fix | Delete
}
[141] Fix | Delete
endif;
[142] Fix | Delete
[143] Fix | Delete
if ( ! function_exists( 'wp_mail' ) ) :
[144] Fix | Delete
/**
[145] Fix | Delete
* Sends an email, similar to PHP's mail function.
[146] Fix | Delete
*
[147] Fix | Delete
* A true return value does not automatically mean that the user received the
[148] Fix | Delete
* email successfully. It just only means that the method used was able to
[149] Fix | Delete
* process the request without any errors.
[150] Fix | Delete
*
[151] Fix | Delete
* The default content type is `text/plain` which does not allow using HTML.
[152] Fix | Delete
* However, you can set the content type of the email by using the
[153] Fix | Delete
* {@see 'wp_mail_content_type'} filter.
[154] Fix | Delete
*
[155] Fix | Delete
* The default charset is based on the charset used on the blog. The charset can
[156] Fix | Delete
* be set using the {@see 'wp_mail_charset'} filter.
[157] Fix | Delete
*
[158] Fix | Delete
* @since 1.2.1
[159] Fix | Delete
*
[160] Fix | Delete
* @global PHPMailer\PHPMailer\PHPMailer $phpmailer
[161] Fix | Delete
*
[162] Fix | Delete
* @param string|string[] $to Array or comma-separated list of email addresses to send message.
[163] Fix | Delete
* @param string $subject Email subject.
[164] Fix | Delete
* @param string $message Message contents.
[165] Fix | Delete
* @param string|string[] $headers Optional. Additional headers.
[166] Fix | Delete
* @param string|string[] $attachments Optional. Paths to files to attach.
[167] Fix | Delete
* @return bool Whether the email was sent successfully.
[168] Fix | Delete
*/
[169] Fix | Delete
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
[170] Fix | Delete
// Compact the input, apply the filters, and extract them back out.
[171] Fix | Delete
[172] Fix | Delete
/**
[173] Fix | Delete
* Filters the wp_mail() arguments.
[174] Fix | Delete
*
[175] Fix | Delete
* @since 2.2.0
[176] Fix | Delete
*
[177] Fix | Delete
* @param array $args {
[178] Fix | Delete
* Array of the `wp_mail()` arguments.
[179] Fix | Delete
*
[180] Fix | Delete
* @type string|string[] $to Array or comma-separated list of email addresses to send message.
[181] Fix | Delete
* @type string $subject Email subject.
[182] Fix | Delete
* @type string $message Message contents.
[183] Fix | Delete
* @type string|string[] $headers Additional headers.
[184] Fix | Delete
* @type string|string[] $attachments Paths to files to attach.
[185] Fix | Delete
* }
[186] Fix | Delete
*/
[187] Fix | Delete
$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
[188] Fix | Delete
[189] Fix | Delete
/**
[190] Fix | Delete
* Filters whether to preempt sending an email.
[191] Fix | Delete
*
[192] Fix | Delete
* Returning a non-null value will short-circuit {@see wp_mail()}, returning
[193] Fix | Delete
* that value instead. A boolean return value should be used to indicate whether
[194] Fix | Delete
* the email was successfully sent.
[195] Fix | Delete
*
[196] Fix | Delete
* @since 5.7.0
[197] Fix | Delete
*
[198] Fix | Delete
* @param null|bool $return Short-circuit return value.
[199] Fix | Delete
* @param array $atts {
[200] Fix | Delete
* Array of the `wp_mail()` arguments.
[201] Fix | Delete
*
[202] Fix | Delete
* @type string|string[] $to Array or comma-separated list of email addresses to send message.
[203] Fix | Delete
* @type string $subject Email subject.
[204] Fix | Delete
* @type string $message Message contents.
[205] Fix | Delete
* @type string|string[] $headers Additional headers.
[206] Fix | Delete
* @type string|string[] $attachments Paths to files to attach.
[207] Fix | Delete
* }
[208] Fix | Delete
*/
[209] Fix | Delete
$pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts );
[210] Fix | Delete
[211] Fix | Delete
if ( null !== $pre_wp_mail ) {
[212] Fix | Delete
return $pre_wp_mail;
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
if ( isset( $atts['to'] ) ) {
[216] Fix | Delete
$to = $atts['to'];
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
if ( ! is_array( $to ) ) {
[220] Fix | Delete
$to = explode( ',', $to );
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
if ( isset( $atts['subject'] ) ) {
[224] Fix | Delete
$subject = $atts['subject'];
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
if ( isset( $atts['message'] ) ) {
[228] Fix | Delete
$message = $atts['message'];
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
if ( isset( $atts['headers'] ) ) {
[232] Fix | Delete
$headers = $atts['headers'];
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
if ( isset( $atts['attachments'] ) ) {
[236] Fix | Delete
$attachments = $atts['attachments'];
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
if ( ! is_array( $attachments ) ) {
[240] Fix | Delete
$attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
[241] Fix | Delete
}
[242] Fix | Delete
global $phpmailer;
[243] Fix | Delete
[244] Fix | Delete
// (Re)create it, if it's gone missing.
[245] Fix | Delete
if ( ! ( $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ) ) {
[246] Fix | Delete
require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
[247] Fix | Delete
require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
[248] Fix | Delete
require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
[249] Fix | Delete
$phpmailer = new PHPMailer\PHPMailer\PHPMailer( true );
[250] Fix | Delete
[251] Fix | Delete
$phpmailer::$validator = static function ( $email ) {
[252] Fix | Delete
return (bool) is_email( $email );
[253] Fix | Delete
};
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
// Headers.
[257] Fix | Delete
$cc = array();
[258] Fix | Delete
$bcc = array();
[259] Fix | Delete
$reply_to = array();
[260] Fix | Delete
[261] Fix | Delete
if ( empty( $headers ) ) {
[262] Fix | Delete
$headers = array();
[263] Fix | Delete
} else {
[264] Fix | Delete
if ( ! is_array( $headers ) ) {
[265] Fix | Delete
// Explode the headers out, so this function can take
[266] Fix | Delete
// both string headers and an array of headers.
[267] Fix | Delete
$tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
[268] Fix | Delete
} else {
[269] Fix | Delete
$tempheaders = $headers;
[270] Fix | Delete
}
[271] Fix | Delete
$headers = array();
[272] Fix | Delete
[273] Fix | Delete
// If it's actually got contents.
[274] Fix | Delete
if ( ! empty( $tempheaders ) ) {
[275] Fix | Delete
// Iterate through the raw headers.
[276] Fix | Delete
foreach ( (array) $tempheaders as $header ) {
[277] Fix | Delete
if ( strpos( $header, ':' ) === false ) {
[278] Fix | Delete
if ( false !== stripos( $header, 'boundary=' ) ) {
[279] Fix | Delete
$parts = preg_split( '/boundary=/i', trim( $header ) );
[280] Fix | Delete
$boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
[281] Fix | Delete
}
[282] Fix | Delete
continue;
[283] Fix | Delete
}
[284] Fix | Delete
// Explode them out.
[285] Fix | Delete
list( $name, $content ) = explode( ':', trim( $header ), 2 );
[286] Fix | Delete
[287] Fix | Delete
// Cleanup crew.
[288] Fix | Delete
$name = trim( $name );
[289] Fix | Delete
$content = trim( $content );
[290] Fix | Delete
[291] Fix | Delete
switch ( strtolower( $name ) ) {
[292] Fix | Delete
// Mainly for legacy -- process a "From:" header if it's there.
[293] Fix | Delete
case 'from':
[294] Fix | Delete
$bracket_pos = strpos( $content, '<' );
[295] Fix | Delete
if ( false !== $bracket_pos ) {
[296] Fix | Delete
// Text before the bracketed email is the "From" name.
[297] Fix | Delete
if ( $bracket_pos > 0 ) {
[298] Fix | Delete
$from_name = substr( $content, 0, $bracket_pos - 1 );
[299] Fix | Delete
$from_name = str_replace( '"', '', $from_name );
[300] Fix | Delete
$from_name = trim( $from_name );
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
$from_email = substr( $content, $bracket_pos + 1 );
[304] Fix | Delete
$from_email = str_replace( '>', '', $from_email );
[305] Fix | Delete
$from_email = trim( $from_email );
[306] Fix | Delete
[307] Fix | Delete
// Avoid setting an empty $from_email.
[308] Fix | Delete
} elseif ( '' !== trim( $content ) ) {
[309] Fix | Delete
$from_email = trim( $content );
[310] Fix | Delete
}
[311] Fix | Delete
break;
[312] Fix | Delete
case 'content-type':
[313] Fix | Delete
if ( strpos( $content, ';' ) !== false ) {
[314] Fix | Delete
list( $type, $charset_content ) = explode( ';', $content );
[315] Fix | Delete
$content_type = trim( $type );
[316] Fix | Delete
if ( false !== stripos( $charset_content, 'charset=' ) ) {
[317] Fix | Delete
$charset = trim( str_replace( array( 'charset=', '"' ), '', $charset_content ) );
[318] Fix | Delete
} elseif ( false !== stripos( $charset_content, 'boundary=' ) ) {
[319] Fix | Delete
$boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset_content ) );
[320] Fix | Delete
$charset = '';
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
// Avoid setting an empty $content_type.
[324] Fix | Delete
} elseif ( '' !== trim( $content ) ) {
[325] Fix | Delete
$content_type = trim( $content );
[326] Fix | Delete
}
[327] Fix | Delete
break;
[328] Fix | Delete
case 'cc':
[329] Fix | Delete
$cc = array_merge( (array) $cc, explode( ',', $content ) );
[330] Fix | Delete
break;
[331] Fix | Delete
case 'bcc':
[332] Fix | Delete
$bcc = array_merge( (array) $bcc, explode( ',', $content ) );
[333] Fix | Delete
break;
[334] Fix | Delete
case 'reply-to':
[335] Fix | Delete
$reply_to = array_merge( (array) $reply_to, explode( ',', $content ) );
[336] Fix | Delete
break;
[337] Fix | Delete
default:
[338] Fix | Delete
// Add it to our grand headers array.
[339] Fix | Delete
$headers[ trim( $name ) ] = trim( $content );
[340] Fix | Delete
break;
[341] Fix | Delete
}
[342] Fix | Delete
}
[343] Fix | Delete
}
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
// Empty out the values that may be set.
[347] Fix | Delete
$phpmailer->clearAllRecipients();
[348] Fix | Delete
$phpmailer->clearAttachments();
[349] Fix | Delete
$phpmailer->clearCustomHeaders();
[350] Fix | Delete
$phpmailer->clearReplyTos();
[351] Fix | Delete
$phpmailer->Body = '';
[352] Fix | Delete
$phpmailer->AltBody = '';
[353] Fix | Delete
[354] Fix | Delete
// Set "From" name and email.
[355] Fix | Delete
[356] Fix | Delete
// If we don't have a name from the input headers.
[357] Fix | Delete
if ( ! isset( $from_name ) ) {
[358] Fix | Delete
$from_name = 'WordPress';
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
/*
[362] Fix | Delete
* If we don't have an email from the input headers, default to wordpress@$sitename
[363] Fix | Delete
* Some hosts will block outgoing mail from this address if it doesn't exist,
[364] Fix | Delete
* but there's no easy alternative. Defaulting to admin_email might appear to be
[365] Fix | Delete
* another option, but some hosts may refuse to relay mail from an unknown domain.
[366] Fix | Delete
* See https://core.trac.wordpress.org/ticket/5007.
[367] Fix | Delete
*/
[368] Fix | Delete
if ( ! isset( $from_email ) ) {
[369] Fix | Delete
// Get the site domain and get rid of www.
[370] Fix | Delete
$sitename = wp_parse_url( network_home_url(), PHP_URL_HOST );
[371] Fix | Delete
if ( 'www.' === substr( $sitename, 0, 4 ) ) {
[372] Fix | Delete
$sitename = substr( $sitename, 4 );
[373] Fix | Delete
}
[374] Fix | Delete
[375] Fix | Delete
$from_email = 'wordpress@' . $sitename;
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
/**
[379] Fix | Delete
* Filters the email address to send from.
[380] Fix | Delete
*
[381] Fix | Delete
* @since 2.2.0
[382] Fix | Delete
*
[383] Fix | Delete
* @param string $from_email Email address to send from.
[384] Fix | Delete
*/
[385] Fix | Delete
$from_email = apply_filters( 'wp_mail_from', $from_email );
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Filters the name to associate with the "from" email address.
[389] Fix | Delete
*
[390] Fix | Delete
* @since 2.3.0
[391] Fix | Delete
*
[392] Fix | Delete
* @param string $from_name Name associated with the "from" email address.
[393] Fix | Delete
*/
[394] Fix | Delete
$from_name = apply_filters( 'wp_mail_from_name', $from_name );
[395] Fix | Delete
[396] Fix | Delete
try {
[397] Fix | Delete
$phpmailer->setFrom( $from_email, $from_name, false );
[398] Fix | Delete
} catch ( PHPMailer\PHPMailer\Exception $e ) {
[399] Fix | Delete
$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
[400] Fix | Delete
$mail_error_data['phpmailer_exception_code'] = $e->getCode();
[401] Fix | Delete
[402] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[403] Fix | Delete
do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
[404] Fix | Delete
[405] Fix | Delete
return false;
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
// Set mail's subject and body.
[409] Fix | Delete
$phpmailer->Subject = $subject;
[410] Fix | Delete
$phpmailer->Body = $message;
[411] Fix | Delete
[412] Fix | Delete
// Set destination addresses, using appropriate methods for handling addresses.
[413] Fix | Delete
$address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' );
[414] Fix | Delete
[415] Fix | Delete
foreach ( $address_headers as $address_header => $addresses ) {
[416] Fix | Delete
if ( empty( $addresses ) ) {
[417] Fix | Delete
continue;
[418] Fix | Delete
}
[419] Fix | Delete
[420] Fix | Delete
foreach ( (array) $addresses as $address ) {
[421] Fix | Delete
try {
[422] Fix | Delete
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>".
[423] Fix | Delete
$recipient_name = '';
[424] Fix | Delete
[425] Fix | Delete
if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) {
[426] Fix | Delete
if ( count( $matches ) == 3 ) {
[427] Fix | Delete
$recipient_name = $matches[1];
[428] Fix | Delete
$address = $matches[2];
[429] Fix | Delete
}
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
switch ( $address_header ) {
[433] Fix | Delete
case 'to':
[434] Fix | Delete
$phpmailer->addAddress( $address, $recipient_name );
[435] Fix | Delete
break;
[436] Fix | Delete
case 'cc':
[437] Fix | Delete
$phpmailer->addCc( $address, $recipient_name );
[438] Fix | Delete
break;
[439] Fix | Delete
case 'bcc':
[440] Fix | Delete
$phpmailer->addBcc( $address, $recipient_name );
[441] Fix | Delete
break;
[442] Fix | Delete
case 'reply_to':
[443] Fix | Delete
$phpmailer->addReplyTo( $address, $recipient_name );
[444] Fix | Delete
break;
[445] Fix | Delete
}
[446] Fix | Delete
} catch ( PHPMailer\PHPMailer\Exception $e ) {
[447] Fix | Delete
continue;
[448] Fix | Delete
}
[449] Fix | Delete
}
[450] Fix | Delete
}
[451] Fix | Delete
[452] Fix | Delete
// Set to use PHP's mail().
[453] Fix | Delete
$phpmailer->isMail();
[454] Fix | Delete
[455] Fix | Delete
// Set Content-Type and charset.
[456] Fix | Delete
[457] Fix | Delete
// If we don't have a content-type from the input headers.
[458] Fix | Delete
if ( ! isset( $content_type ) ) {
[459] Fix | Delete
$content_type = 'text/plain';
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
/**
[463] Fix | Delete
* Filters the wp_mail() content type.
[464] Fix | Delete
*
[465] Fix | Delete
* @since 2.3.0
[466] Fix | Delete
*
[467] Fix | Delete
* @param string $content_type Default wp_mail() content type.
[468] Fix | Delete
*/
[469] Fix | Delete
$content_type = apply_filters( 'wp_mail_content_type', $content_type );
[470] Fix | Delete
[471] Fix | Delete
$phpmailer->ContentType = $content_type;
[472] Fix | Delete
[473] Fix | Delete
// Set whether it's plaintext, depending on $content_type.
[474] Fix | Delete
if ( 'text/html' === $content_type ) {
[475] Fix | Delete
$phpmailer->isHTML( true );
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
// If we don't have a charset from the input headers.
[479] Fix | Delete
if ( ! isset( $charset ) ) {
[480] Fix | Delete
$charset = get_bloginfo( 'charset' );
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
/**
[484] Fix | Delete
* Filters the default wp_mail() charset.
[485] Fix | Delete
*
[486] Fix | Delete
* @since 2.3.0
[487] Fix | Delete
*
[488] Fix | Delete
* @param string $charset Default email charset.
[489] Fix | Delete
*/
[490] Fix | Delete
$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
[491] Fix | Delete
[492] Fix | Delete
// Set custom headers.
[493] Fix | Delete
if ( ! empty( $headers ) ) {
[494] Fix | Delete
foreach ( (array) $headers as $name => $content ) {
[495] Fix | Delete
// Only add custom headers not added automatically by PHPMailer.
[496] Fix | Delete
if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer' ), true ) ) {
[497] Fix | Delete
try {
[498] Fix | Delete
$phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function