mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 10:05:43 +03:00
Organize email & authentication code (#101)
* Split Auth functionality out to new file
* Move email-related code into the email file
* Use `assertFalse` for boolean assertions
* Add `can_manage_pledge` to check user or token against a given pledge
Pulled out of e9763f6678
* Remove duplicate test
This commit is contained in:
parent
03949905c0
commit
f32d26ef47
7 changed files with 360 additions and 274 deletions
|
@ -7,7 +7,7 @@
|
|||
namespace WordPressDotOrg\FiveForTheFuture\Pledge;
|
||||
|
||||
use WordPressDotOrg\FiveForTheFuture;
|
||||
use WordPressDotOrg\FiveForTheFuture\{ Contributor, Email };
|
||||
use WordPressDotOrg\FiveForTheFuture\{ Auth, Contributor, Email };
|
||||
use WP_Error, WP_Query;
|
||||
|
||||
use const WordPressDotOrg\FiveForTheFuture\PledgeMeta\META_PREFIX;
|
||||
|
@ -189,37 +189,12 @@ function create_new_pledge( $name ) {
|
|||
// The pledge's meta data is saved at this point via `save_pledge_meta()`, which is a `save_post` callback.
|
||||
|
||||
if ( ! is_wp_error( $pledge_id ) ) {
|
||||
send_pledge_confirmation_email( $pledge_id, get_post()->ID );
|
||||
Email\send_pledge_confirmation_email( $pledge_id, get_post()->ID );
|
||||
}
|
||||
|
||||
return $pledge_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Email pledge manager to confirm their email address.
|
||||
*
|
||||
* @param int $pledge_id The ID of the pledge.
|
||||
* @param int $action_page_id The ID of the page that the user will be taken back to, in order to process their
|
||||
* confirmation request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function send_pledge_confirmation_email( $pledge_id, $action_page_id ) {
|
||||
$pledge = get_post( $pledge_id );
|
||||
|
||||
$message = sprintf(
|
||||
"Thanks for pledging your organization's time to contribute to the WordPress open source project! Please confirm this email address in order to publish your pledge:\n\n%s",
|
||||
Email\get_authentication_url( $pledge_id, 'confirm_pledge_email', $action_page_id )
|
||||
);
|
||||
|
||||
return Email\send_email(
|
||||
$pledge->{'5ftf_org-pledge-email'},
|
||||
'Please confirm your email address',
|
||||
$message,
|
||||
$pledge_id
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter query for archive & search pages to ensure we're only showing the expected data.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue