mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-21 10:33:44 +03:00
parent
9f47f83ef4
commit
83125dd8b2
|
@ -295,13 +295,13 @@ function process_my_pledges_form() {
|
||||||
wp_verify_nonce( $nonce, 'join_decline_organization' ) || wp_nonce_ays( 'join_decline_organization' );
|
wp_verify_nonce( $nonce, 'join_decline_organization' ) || wp_nonce_ays( 'join_decline_organization' );
|
||||||
|
|
||||||
$status = 'trash';
|
$status = 'trash';
|
||||||
$message = "Your have declined the invitation from {$pledge->post_title}.";
|
$message = "You have declined the pledge invitation from {$pledge->post_title}.";
|
||||||
|
|
||||||
} elseif ( filter_input( INPUT_POST, 'leave_organization' ) ) {
|
} elseif ( filter_input( INPUT_POST, 'leave_organization' ) ) {
|
||||||
wp_verify_nonce( $nonce, 'leave_organization' ) || wp_nonce_ays( 'leave_organization' );
|
wp_verify_nonce( $nonce, 'leave_organization' ) || wp_nonce_ays( 'leave_organization' );
|
||||||
|
|
||||||
$status = 'trash';
|
$status = 'trash';
|
||||||
$message = "Your have left the {$pledge->post_title} pledge.";
|
$message = "You have left the {$pledge->post_title} pledge.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'publish' === $status ) {
|
if ( 'publish' === $status ) {
|
||||||
|
|
|
@ -24,24 +24,26 @@ function render_form_new() {
|
||||||
$action = isset( $_GET['action'] ) ? filter_input( INPUT_GET, 'action' ) : filter_input( INPUT_POST, 'action' );
|
$action = isset( $_GET['action'] ) ? filter_input( INPUT_GET, 'action' ) : filter_input( INPUT_POST, 'action' );
|
||||||
$data = get_form_submission();
|
$data = get_form_submission();
|
||||||
$messages = [];
|
$messages = [];
|
||||||
|
$pledge = null;
|
||||||
$complete = false;
|
$complete = false;
|
||||||
$directory_url = get_permalink( get_page_by_path( 'pledges' ) );
|
$directory_url = get_permalink( get_page_by_path( 'pledges' ) );
|
||||||
$view = 'form-pledge-new.php';
|
$view = 'form-pledge-new.php';
|
||||||
|
|
||||||
if ( 'Submit Pledge' === $action ) {
|
if ( 'Submit Pledge' === $action ) {
|
||||||
$processed = process_form_new();
|
$pledge_id = process_form_new();
|
||||||
|
|
||||||
if ( is_wp_error( $processed ) ) {
|
if ( is_wp_error( $pledge_id ) ) {
|
||||||
$messages = array_merge( $messages, $processed->get_error_messages() );
|
$messages = array_merge( $messages, $pledge_id->get_error_messages() );
|
||||||
} elseif ( 'success' === $processed ) {
|
} elseif ( is_int( $pledge_id ) ) {
|
||||||
$complete = true;
|
$complete = true;
|
||||||
}
|
}
|
||||||
} else if ( 'confirm_pledge_email' === $action ) {
|
} elseif ( 'confirm_pledge_email' === $action ) {
|
||||||
$view = 'form-pledge-confirm-email.php';
|
$view = 'form-pledge-confirm-email.php';
|
||||||
$pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT );
|
$pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT );
|
||||||
$unverified_token = filter_input( INPUT_GET, 'auth_token', FILTER_SANITIZE_STRING );
|
$unverified_token = filter_input( INPUT_GET, 'auth_token', FILTER_SANITIZE_STRING );
|
||||||
$email_confirmed = process_pledge_confirmation_email( $pledge_id, $action, $unverified_token );
|
$email_confirmed = process_pledge_confirmation_email( $pledge_id, $action, $unverified_token );
|
||||||
} else if ( filter_input( INPUT_GET, 'resend_pledge_confirmation' ) ) {
|
$pledge = get_post( $pledge_id );
|
||||||
|
} elseif ( filter_input( INPUT_GET, 'resend_pledge_confirmation' ) ) {
|
||||||
$pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT );
|
$pledge_id = filter_input( INPUT_GET, 'pledge_id', FILTER_VALIDATE_INT );
|
||||||
$complete = true;
|
$complete = true;
|
||||||
|
|
||||||
|
@ -58,11 +60,11 @@ function render_form_new() {
|
||||||
/**
|
/**
|
||||||
* Process a submission from the New Pledge form.
|
* Process a submission from the New Pledge form.
|
||||||
*
|
*
|
||||||
* @return string|WP_Error String "success" if the form processed correctly. Otherwise WP_Error.
|
* @return int|WP_Error The post ID of the new pledge if the form processed correctly. Otherwise WP_Error.
|
||||||
*/
|
*/
|
||||||
function process_form_new() {
|
function process_form_new() {
|
||||||
$submission = get_form_submission();
|
$submission = get_form_submission();
|
||||||
$has_error = check_invalid_submission( $submission );
|
$has_error = check_invalid_submission( $submission );
|
||||||
if ( $has_error ) {
|
if ( $has_error ) {
|
||||||
return $has_error;
|
return $has_error;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +76,7 @@ function process_form_new() {
|
||||||
|
|
||||||
$logo_attachment_id = upload_image( $_FILES['org-logo'] );
|
$logo_attachment_id = upload_image( $_FILES['org-logo'] );
|
||||||
if ( is_wp_error( $logo_attachment_id ) ) {
|
if ( is_wp_error( $logo_attachment_id ) ) {
|
||||||
return $logo_attachment_id;
|
//return $logo_attachment_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = sanitize_meta(
|
$name = sanitize_meta(
|
||||||
|
@ -93,13 +95,13 @@ function process_form_new() {
|
||||||
Contributor\add_pledge_contributors( $new_pledge_id, $contributors );
|
Contributor\add_pledge_contributors( $new_pledge_id, $contributors );
|
||||||
|
|
||||||
// Attach logo to the pledge.
|
// Attach logo to the pledge.
|
||||||
wp_update_post( array(
|
/*wp_update_post( array(
|
||||||
'ID' => $logo_attachment_id,
|
'ID' => $logo_attachment_id,
|
||||||
'post_parent' => $new_pledge_id,
|
'post_parent' => $new_pledge_id,
|
||||||
) );
|
) );
|
||||||
set_post_thumbnail( $new_pledge_id, $logo_attachment_id );
|
set_post_thumbnail( $new_pledge_id, $logo_attachment_id );*/
|
||||||
|
|
||||||
return 'success';
|
return $new_pledge_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,16 +170,15 @@ function send_contributor_confirmation_emails( $pledge_id, $contributor_id = nul
|
||||||
* because there's no expiration.
|
* because there's no expiration.
|
||||||
*/
|
*/
|
||||||
$message =
|
$message =
|
||||||
"Hi $name, {$pledge->post_title} has created a Five for the Future pledge on WordPress.org and listed you as one of " .
|
"Howdy $name, {$pledge->post_title} has created a Five for the Future pledge on WordPress.org and listed you as one of the contributors that they sponsor to contribute to the WordPress open source project. You can view their pledge at:" . "\n\n" .
|
||||||
"the contributors that they pay to contribute back to WordPress. You can view their pledge at: " . "\n\n" .
|
|
||||||
get_permalink( $pledge_id ) . "\n\n" .
|
get_permalink( $pledge_id ) . "\n\n" .
|
||||||
// todo ^ page not found? probably just because https://github.com/WordPress/five-for-the-future/issues/9 isn't ready yet
|
|
||||||
|
"To confirm that they're sponsoring your contributions, please review your pledges at:" . "\n\n" .
|
||||||
|
|
||||||
"To confirm that they're paying you to contribute, please review your pledges at:" . "\n\n" .
|
|
||||||
get_permalink( get_page_by_path( 'my-pledges' ) ) . "\n\n" .
|
get_permalink( get_page_by_path( 'my-pledges' ) ) . "\n\n" .
|
||||||
|
|
||||||
"If they aren't paying you to contribute, then you can ignore this email and you won't be listed as one " .
|
"If they aren't sponsoring your contributions, then you can ignore this email, and you won't be listed on their pledge."
|
||||||
'of their contributors.'
|
|
||||||
;
|
;
|
||||||
|
|
||||||
$user = get_user_by( 'login', $contributor->post_title );
|
$user = get_user_by( 'login', $contributor->post_title );
|
||||||
|
|
|
@ -155,13 +155,13 @@ function send_pledge_confirmation_email( $pledge_id, $action_page_id ) {
|
||||||
$pledge = get_post( $pledge_id );
|
$pledge = get_post( $pledge_id );
|
||||||
|
|
||||||
$message =
|
$message =
|
||||||
'Thanks for committing to help keep WordPress sustainable! Please confirm this email address ' .
|
'Thanks for pledging your time to contribute to WordPress! Please confirm this email address in order to publish your pledge:' . "\n\n" .
|
||||||
'in order to publish your pledge:' . "\n\n" .
|
|
||||||
Email\get_authentication_url( $pledge_id, 'confirm_pledge_email', $action_page_id )
|
Email\get_authentication_url( $pledge_id, 'confirm_pledge_email', $action_page_id )
|
||||||
;
|
;
|
||||||
|
|
||||||
// todo include a notice that the link will expire in X hours, so they know what to expect
|
// todo include a notice that the link will expire in X hours, so they know what to expect
|
||||||
// need to make that value DRY across all emails with links
|
// need to make that value DRY across all emails with links
|
||||||
// should probably say that on the front end form success message as well, so they know to go check their email now instead of after lunch.
|
// should probably say that on the front end form success message as well, so they know to go check their email now instead of after lunch.
|
||||||
|
|
||||||
return Email\send_email(
|
return Email\send_email(
|
||||||
|
|
|
@ -1,20 +1,42 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace WordPressDotOrg\FiveForTheFuture\View;
|
namespace WordPressDotOrg\FiveForTheFuture\View;
|
||||||
|
|
||||||
/**
|
use WP_Post;
|
||||||
* @var bool $email_confirmed
|
|
||||||
* @var string $directory_url
|
|
||||||
* @var int $pledge_id
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool $email_confirmed
|
||||||
|
* @var string $directory_url
|
||||||
|
* @var int $pledge_id
|
||||||
|
* @var WP_Post|null $pledge
|
||||||
|
*/
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ( true === $email_confirmed ) : ?>
|
<?php if ( true === $email_confirmed ) : ?>
|
||||||
|
|
||||||
<div class="notice notice-success notice-alt">
|
<div class="notice notice-success notice-alt">
|
||||||
<p>
|
<p>
|
||||||
Thank you for confirming your address! We've emailed confirmation links to your contributors, and your pledge will show up in <a href="<?php echo esc_url( $directory_url ); ?>">the directory</a> once one of them confirms their participation.
|
<?php
|
||||||
|
printf(
|
||||||
|
wp_kses_post( __( "Thank you for confirming your address! We've emailed confirmation links to the contributors you mentioned, and your pledge will show up in <a href=\"%s\">the directory</a> once one contributor confirms their participation.", 'wporg' ) ),
|
||||||
|
esc_url( $directory_url )
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?php if ( $pledge instanceof WP_Post ) : ?>
|
||||||
|
<p>
|
||||||
|
<?php echo wp_kses_post( sprintf(
|
||||||
|
__( 'In the meantime, your pledge will be visible here: %s', 'wporg' ),
|
||||||
|
sprintf(
|
||||||
|
'<a href="%1$s">%1$s</a>',
|
||||||
|
esc_url( get_permalink( $pledge ) )
|
||||||
|
)
|
||||||
|
) ); ?>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?php esc_html_e( "Thanks again for pledging your organization's resources to contribute to WordPress! We can do great things together!", 'wporg' ); ?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace WordPressDotOrg\FiveForTheFuture\View;
|
namespace WordPressDotOrg\FiveForTheFuture\View;
|
||||||
|
|
||||||
use function WordPressDotOrg\FiveForTheFuture\get_views_path;
|
use function WordPressDotOrg\FiveForTheFuture\get_views_path;
|
||||||
|
use WP_Post;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $messages
|
* @var array $messages
|
||||||
* @var bool $complete
|
* @var bool $complete
|
||||||
* @var string $directory_url
|
* @var string $directory_url
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- TODO Reveal this once managing an existing pledge is actually possible.
|
<!-- TODO Reveal this once managing an existing pledge is actually possible.
|
||||||
|
@ -30,21 +30,23 @@ use function WordPressDotOrg\FiveForTheFuture\get_views_path;
|
||||||
<?php if ( true === $complete ) : ?>
|
<?php if ( true === $complete ) : ?>
|
||||||
|
|
||||||
<div class="notice notice-success notice-alt">
|
<div class="notice notice-success notice-alt">
|
||||||
<p><?php esc_html_e( "Thanks for pledging to Five for the Future! Your new pledge profile has been created, and we’ve emailed you a link to confirm your address. Once that's done, we'll also email confirmation links to your contributors.", 'wporg' ); ?></p>
|
<p>
|
||||||
|
<?php esc_html_e( "Thanks for pledging to Five for the Future! Your new pledge profile has been created, and we've emailed you a link to confirm your address. Once that's done, we'll also email confirmation links to the contributors you named in your pledge.", 'wporg' ); ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?php echo wp_kses_post( sprintf(
|
<?php echo wp_kses_post( sprintf(
|
||||||
__( 'After those steps are completed, your pledge will appear in <a href="%s">the directory</a>.', 'wporg' ),
|
__( "After those steps are completed (and at least one contributor confirms), your pledge will appear in <a href=\"%s\">the directory</a>. Once each contributor has confirmed, they'll appear on your pledge as well.", 'wporg' ),
|
||||||
esc_url( $directory_url )
|
esc_url( $directory_url )
|
||||||
) ); ?>
|
) ); ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?php echo wp_kses_post(
|
<?php echo wp_kses_post(
|
||||||
__( 'Do you want to hire additional employees to contribute to WordPress? <a href="https://jobs.wordpress.net">Post a job listing on jobs.wordpress.net</a>.', 'wporg' )
|
sprintf(
|
||||||
// todo ask mel about moving this outside the `notice-success`, since it's not really part of the success notification, and distracts from it.
|
__( 'Do you want to hire additional employees to contribute to WordPress? <a href="%s">Consider posting a job listing on jobs.wordpress.net</a>.', 'wporg' ),
|
||||||
// many users have notification fatigue and no longer trust them or pay attention to them, because they're so often misused for non-critical information,
|
'https://jobs.wordpress.net'
|
||||||
// and the jobs thing is more of an "ad" in this context than something directly related to the process the user wants to complete
|
)
|
||||||
); ?>
|
); ?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue