2019-10-25 22:07:09 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2019-11-15 19:47:20 +02:00
|
|
|
* Helper functions for sending emails.
|
2019-10-25 22:07:09 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace WordPressDotOrg\FiveForTheFuture\Email;
|
|
|
|
|
2019-11-15 19:47:20 +02:00
|
|
|
use const WordPressDotOrg\FiveForTheFuture\PREFIX;
|
2019-10-25 22:07:09 +03:00
|
|
|
|
2019-11-15 19:47:20 +02:00
|
|
|
defined( 'WPINC' ) || die();
|
2019-11-07 21:53:39 +02:00
|
|
|
|
2019-10-25 22:07:09 +03:00
|
|
|
/**
|
|
|
|
* Wrap `wp_mail()` with shared functionality.
|
|
|
|
*
|
|
|
|
* @param string $to
|
|
|
|
* @param string $subject
|
|
|
|
* @param string $message
|
2019-11-01 03:39:57 +02:00
|
|
|
* @param int $pledge_id
|
2019-10-25 22:07:09 +03:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2019-11-01 03:39:57 +02:00
|
|
|
function send_email( $to, $subject, $message, $pledge_id ) {
|
2019-10-25 22:07:09 +03:00
|
|
|
$headers = array(
|
|
|
|
'From: WordPress - Five for the Future <donotreply@wordpress.org>',
|
|
|
|
'Reply-To: support@wordcamp.org',
|
|
|
|
);
|
|
|
|
|
2019-11-01 03:39:57 +02:00
|
|
|
$result = wp_mail( $to, $subject, $message, $headers );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Broadcast the results of an attempt to send an email.
|
|
|
|
*
|
|
|
|
* @param string $to
|
|
|
|
* @param string $subject
|
|
|
|
* @param string $message
|
|
|
|
* @param array $headers
|
|
|
|
* @param bool $result
|
|
|
|
* @param int $pledge_id
|
|
|
|
*/
|
2019-11-15 19:47:20 +02:00
|
|
|
do_action( PREFIX . '_email_result', $to, $subject, $message, $headers, $result, $pledge_id );
|
2019-11-01 03:39:57 +02:00
|
|
|
|
|
|
|
return $result;
|
2019-10-25 22:07:09 +03:00
|
|
|
}
|
|
|
|
|