39
39
add_action ( 'pledge_footer ' , __NAMESPACE__ . '\render_manage_link_request ' );
40
40
add_action ( 'wp_footer ' , __NAMESPACE__ . '\render_js_templates ' );
41
41
42
- // Misc
42
+ // Misc.
43
43
add_action ( 'init ' , __NAMESPACE__ . '\schedule_cron_jobs ' );
44
44
add_action ( '5ftf_send_update_reminders ' , __NAMESPACE__ . '\send_update_reminders ' );
45
45
@@ -250,7 +250,7 @@ function action_success_message() {
250
250
* @return array The filtered list of post display states.
251
251
*/
252
252
function add_status_to_display ( $ post_states , $ post ) {
253
- $ showing_status = $ _REQUEST ['post_status ' ] ?? $ showing_status = '' ;
253
+ $ showing_status = $ _REQUEST ['post_status ' ] ?? '' ;
254
254
255
255
$ status = DEACTIVE_STATUS ;
256
256
if ( $ showing_status !== $ status && $ status === $ post ->post_status ) {
@@ -350,6 +350,8 @@ function is_active_pledge( $post_id ) {
350
350
* @return int|WP_Error Post ID on success. Otherwise WP_Error.
351
351
*/
352
352
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 ;
353
355
$ args = array (
354
356
'post_type ' => CPT_ID ,
355
357
'post_title ' => $ name ,
@@ -360,7 +362,7 @@ function create_new_pledge( $name ) {
360
362
// The pledge's meta data is saved at this point via `save_pledge_meta()`, which is a `save_post` callback.
361
363
362
364
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 );
364
366
}
365
367
366
368
return $ pledge_id ;
@@ -452,7 +454,7 @@ function filter_query( $query ) {
452
454
break ;
453
455
454
456
default :
455
- $ date = date ( 'YmdH ' );
457
+ $ date = gmdate ( 'YmdH ' );
456
458
$ query ->set ( 'orderby ' , "RAND( $ date) " );
457
459
break ;
458
460
}
@@ -572,7 +574,7 @@ function schedule_cron_jobs() {
572
574
/**
573
575
* Periodically ask companies to review their pledge for accuracy.
574
576
*/
575
- function send_update_reminders () : void {
577
+ function send_update_reminders (): void {
576
578
$ resend_interval = 6 * MONTH_IN_SECONDS ;
577
579
$ resend_threshold = time () - ( $ resend_interval );
578
580
$ deactivation_date = time () + ( 2 * MONTH_IN_SECONDS );
@@ -608,7 +610,7 @@ function send_update_reminders() : void {
608
610
'key ' => '5ftf_inactive_deactivate_date ' ,
609
611
'compare ' => 'NOT EXISTS ' ,
610
612
),
611
- )
613
+ ),
612
614
) );
613
615
614
616
foreach ( $ pledges as $ pledge ) {
0 commit comments