Add is_active_pledge to check post type & status

This commit is contained in:
Kelly Dwan 2019-12-09 17:45:49 -05:00
parent 6b65f9efbe
commit d737f70a7e
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
2 changed files with 12 additions and 1 deletions

View file

@ -123,7 +123,7 @@ function render_form_manage() {
if ( is_wp_error( $can_view_form ) ) {
$errors = array( $can_view_form->get_error_message() );
} else if ( ! in_array( get_post_status( $pledge_id ), array( 'pending', 'publish' ), true ) ) {
} else if ( ! Pledge\is_active_pledge( $pledge_id ) ) {
$errors = array(
sprintf(
__( 'This pledge has been removed from Five for the Future. If this was a mistake, please <a href="%s">contact us</a> to reactivate your pledge.', 'wporg-5ftf' ),

View file

@ -327,6 +327,17 @@ function populate_list_table_columns( $column, $post_id ) {
break;
}
}
/**
* Check if a post is an active pledge (pending or published).
*
* @param int $post_id The ID of a post to check.
*
* @return bool
*/
function is_active_pledge( $post_id ) {
return CPT_ID === get_post_type( $post_id ) &&
in_array( get_post_status( $post_id ), array( 'pending', 'publish' ), true );
}
/**
* Create a new pledge post.