mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-01 16:51:18 +03:00
Add is_active_pledge
to check post type & status
This commit is contained in:
parent
6b65f9efbe
commit
d737f70a7e
|
@ -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' ),
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue