mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-12 21:35:44 +03:00
Contributors: Add Contributors CPT and related admin UI
This commit is contained in:
parent
aaf8b1a712
commit
75428a3c95
4 changed files with 158 additions and 36 deletions
|
@ -240,40 +240,6 @@ function has_existing_pledge( $key, $key_type, int $current_pledge_id = 0 ) {
|
|||
return ! empty( $matching_pledge );
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Move this to the contributor cpt include file.
|
||||
*
|
||||
* @param int $pledge_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_pledge_contributors( $pledge_id = 0 ) {
|
||||
$contributors = array();
|
||||
|
||||
// Get POST'd submission, if it exists.
|
||||
$submission = filter_input( INPUT_POST, 'org-pledge-contributors', FILTER_SANITIZE_STRING );
|
||||
|
||||
// Get existing pledge, if it exists.
|
||||
$pledge = get_post( $pledge_id );
|
||||
|
||||
if ( ! empty( $submission ) ) {
|
||||
$contributors = array_map( 'sanitize_user', explode( ',', $submission ) );
|
||||
} elseif ( $pledge instanceof WP_Post ) {
|
||||
// TODO the Contributor post type is being introduced in a separate PR. These details may change.
|
||||
|
||||
$contributor_posts = get_posts( array(
|
||||
'post_type' => '',
|
||||
'post_status' => array( 'pending', 'publish' ),
|
||||
'post_parent' => $pledge_id,
|
||||
'numberposts' => -1,
|
||||
) );
|
||||
|
||||
$contributors = wp_list_pluck( $contributor_posts, 'post_title' );
|
||||
}
|
||||
|
||||
return $contributors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure each item in a list of usernames is valid and corresponds to a user.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue