diff --git a/plugins/wporg-5ftf/includes/contributor.php b/plugins/wporg-5ftf/includes/contributor.php index 0008059..2be510b 100644 --- a/plugins/wporg-5ftf/includes/contributor.php +++ b/plugins/wporg-5ftf/includes/contributor.php @@ -178,10 +178,11 @@ function add_pledge_contributors( $pledge_id, $contributors ) { */ function remove_contributor( $contributor_post_id ) { $contributor = get_post( $contributor_post_id ); + $old_status = $contributor->post_status; $pledge_id = $contributor->post_parent; $result = wp_trash_post( $contributor_post_id ); - if ( $result && 'publish' === $contributor->post_status ) { + if ( $result && 'publish' === $old_status ) { Email\send_contributor_removed_email( $pledge_id, $contributor ); } @@ -422,21 +423,21 @@ function process_my_pledges_form() { wp_verify_nonce( $unverified_nonce, $nonce_action ) || wp_nonce_ays( $nonce_action ); $new_status = 'publish'; - $message = "You have joined the pledge from {$pledge->post_title}."; + $message = "You have joined the pledge from $pledge->post_title."; } elseif ( filter_input( INPUT_POST, 'decline_invitation' ) ) { $nonce_action = 'join_decline_organization_' . $contributor_post_id; wp_verify_nonce( $unverified_nonce, $nonce_action ) || wp_nonce_ays( $nonce_action ); $new_status = 'trash'; - $message = "You have declined the pledge invitation from {$pledge->post_title}."; + $message = "You have declined the pledge invitation from $pledge->post_title."; } elseif ( filter_input( INPUT_POST, 'leave_organization' ) ) { $nonce_action = 'leave_organization_' . $contributor_post_id; wp_verify_nonce( $unverified_nonce, $nonce_action ) || wp_nonce_ays( $nonce_action ); $new_status = 'trash'; - $message = "You have left the {$pledge->post_title} pledge."; + $message = "You have left the $pledge->post_title pledge."; } if ( 'publish' === $new_status && 'publish' !== $contributor_post->post_status ) { diff --git a/plugins/wporg-5ftf/includes/email.php b/plugins/wporg-5ftf/includes/email.php index 18456ad..4274530 100644 --- a/plugins/wporg-5ftf/includes/email.php +++ b/plugins/wporg-5ftf/includes/email.php @@ -8,7 +8,7 @@ namespace WordPressDotOrg\FiveForTheFuture\Email; use WordPressDotOrg\FiveForTheFuture\{ Auth, Contributor }; use const WordPressDotOrg\FiveForTheFuture\PREFIX; use const WordPressDotOrg\FiveForTheFuture\PledgeMeta\META_PREFIX; -use WP_Error; +use WP_Post, WP_Error; defined( 'WPINC' ) || die(); diff --git a/plugins/wporg-5ftf/includes/pledge.php b/plugins/wporg-5ftf/includes/pledge.php index 40c5f4d..ff33d79 100755 --- a/plugins/wporg-5ftf/includes/pledge.php +++ b/plugins/wporg-5ftf/includes/pledge.php @@ -7,8 +7,8 @@ namespace WordPressDotOrg\FiveForTheFuture\Pledge; use WordPressDotOrg\FiveForTheFuture; -use WordPressDotOrg\FiveForTheFuture\{ Auth, Contributor, Email }; -use WP_Error, WP_Query; +use WordPressDotOrg\FiveForTheFuture\{ Contributor, Email }; +use WP_Post, WP_Error, WP_Query; use const WordPressDotOrg\FiveForTheFuture\PledgeMeta\META_PREFIX; @@ -206,16 +206,18 @@ function handle_activation_action( $post_id ) { if ( 'deactivate' === $action ) { deactivate( $post_id, false, 'Site admin deactivated via wp-admin list table.' ); - wp_safe_redirect( add_query_arg( 'deactivated', 1, $sendback ) ); - exit(); + $url = add_query_arg( 'deactivated', 1, $sendback ); + } else { wp_update_post( array( 'ID' => $post_id, 'post_status' => 'publish', ) ); - wp_safe_redirect( add_query_arg( 'reactivated', 1, $sendback ) ); - exit(); + $url = add_query_arg( 'reactivated', 1, $sendback ); } + + wp_safe_redirect( $url ); + exit(); } /** @@ -244,11 +246,7 @@ function action_success_message() { * @return array The filtered list of post display states. */ function add_status_to_display( $post_states, $post ) { - if ( isset( $_REQUEST['post_status'] ) ) { - $showing_status = $_REQUEST['post_status']; - } else { - $showing_status = ''; - } + $showing_status = $_REQUEST['post_status'] ?? $showing_status = ''; $status = DEACTIVE_STATUS; if ( $showing_status !== $status && $status === $post->post_status ) { @@ -310,15 +308,16 @@ function add_list_table_columns( $columns ) { function populate_list_table_columns( $column, $post_id ) { switch ( $column ) { case 'contributor_counts': - $contribs = Contributor\get_pledge_contributors( $post_id, 'all' ); - $confirmed = sprintf( - _n( '%s confirmed', '%s confirmed', count( $contribs['publish'] ), 'wporg-5ftf' ), - number_format_i18n( count( $contribs['publish'] ) ) + $contributors = Contributor\get_pledge_contributors( $post_id, 'all' ); + $confirmed = sprintf( + _n( '%s confirmed', '%s confirmed', count( $contributors['publish'] ), 'wporg-5ftf' ), + number_format_i18n( count( $contributors['publish'] ) ) ); - $unconfirmed = sprintf( - _n( '%s unconfirmed', '%s unconfirmed', count( $contribs['pending'] ), 'wporg-5ftf' ), - number_format_i18n( count( $contribs['pending'] ) ) + $unconfirmed = sprintf( + _n( '%s unconfirmed', '%s unconfirmed', count( $contributors['pending'] ), 'wporg-5ftf' ), + number_format_i18n( count( $contributors['pending'] ) ) ); + printf( '%s
%s', esc_html( $confirmed ), esc_html( $unconfirmed ) ); break; case 'domain': @@ -424,7 +423,7 @@ function filter_query( $query ) { if ( $query->is_archive && CPT_ID === $query->get( 'post_type' ) ) { // Archives should only show pledges with contributors. $query->set( 'meta_query', $meta_queries ); - $order = isset( $_GET['order'] ) ? $_GET['order'] : ''; + $order = $_GET['order'] ?? ''; switch ( $order ) { case 'alphabetical':