Skip to content

Commit c04421f

Browse files
authored
Fix pledge activation URL (#245)
* Fix pledge activation URL The post id being sent by email contained the pledge ID instead of the ID for form page, this fixes that are restores the ability to confirm email address. * Fix unrelated PHPCS
1 parent d96a9ff commit c04421f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

plugins/wporg-5ftf/includes/pledge.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
add_action( 'pledge_footer', __NAMESPACE__ . '\render_manage_link_request' );
4040
add_action( 'wp_footer', __NAMESPACE__ . '\render_js_templates' );
4141

42-
// Misc
42+
// Misc.
4343
add_action( 'init', __NAMESPACE__ . '\schedule_cron_jobs' );
4444
add_action( '5ftf_send_update_reminders', __NAMESPACE__ . '\send_update_reminders' );
4545

@@ -250,7 +250,7 @@ function action_success_message() {
250250
* @return array The filtered list of post display states.
251251
*/
252252
function add_status_to_display( $post_states, $post ) {
253-
$showing_status = $_REQUEST['post_status'] ?? $showing_status = '';
253+
$showing_status = $_REQUEST['post_status'] ?? '';
254254

255255
$status = DEACTIVE_STATUS;
256256
if ( $showing_status !== $status && $status === $post->post_status ) {
@@ -350,6 +350,8 @@ function is_active_pledge( $post_id ) {
350350
* @return int|WP_Error Post ID on success. Otherwise WP_Error.
351351
*/
352352
function create_new_pledge( $name ) {
353+
// Grab the ID of the post we are on before inserting a pledge.
354+
$pledge_form_post_id = get_post()->ID;
353355
$args = array(
354356
'post_type' => CPT_ID,
355357
'post_title' => $name,
@@ -360,7 +362,7 @@ function create_new_pledge( $name ) {
360362
// The pledge's meta data is saved at this point via `save_pledge_meta()`, which is a `save_post` callback.
361363

362364
if ( ! is_wp_error( $pledge_id ) ) {
363-
Email\send_pledge_confirmation_email( $pledge_id, get_post()->ID );
365+
Email\send_pledge_confirmation_email( $pledge_id, $pledge_form_post_id );
364366
}
365367

366368
return $pledge_id;
@@ -452,7 +454,7 @@ function filter_query( $query ) {
452454
break;
453455

454456
default:
455-
$date = date( 'YmdH' );
457+
$date = gmdate( 'YmdH' );
456458
$query->set( 'orderby', "RAND($date)" );
457459
break;
458460
}
@@ -572,7 +574,7 @@ function schedule_cron_jobs() {
572574
/**
573575
* Periodically ask companies to review their pledge for accuracy.
574576
*/
575-
function send_update_reminders() : void {
577+
function send_update_reminders(): void {
576578
$resend_interval = 6 * MONTH_IN_SECONDS;
577579
$resend_threshold = time() - ( $resend_interval );
578580
$deactivation_date = time() + ( 2 * MONTH_IN_SECONDS );
@@ -608,7 +610,7 @@ function send_update_reminders() : void {
608610
'key' => '5ftf_inactive_deactivate_date',
609611
'compare' => 'NOT EXISTS',
610612
),
611-
)
613+
),
612614
) );
613615

614616
foreach ( $pledges as $pledge ) {

0 commit comments

Comments
 (0)