mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-02 01:01:18 +03:00
Plugin: Add helper function for getting contributor user objects
This commit is contained in:
parent
9ea44532c2
commit
f0cec6e5a9
|
@ -3,7 +3,7 @@ namespace WordPressDotOrg\FiveForTheFuture\Contributor;
|
|||
|
||||
use WordPressDotOrg\FiveForTheFuture;
|
||||
use WordPressDotOrg\FiveForTheFuture\Pledge;
|
||||
use WP_Error, WP_Post;
|
||||
use WP_Error, WP_Post, WP_User;
|
||||
|
||||
defined( 'WPINC' ) || die();
|
||||
|
||||
|
@ -175,3 +175,16 @@ function get_pledge_contributors( $pledge_id, $status = 'publish' ) {
|
|||
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user objects that correspond with pledge contributor posts.
|
||||
*
|
||||
* @param WP_Post[] $contributor_posts
|
||||
*
|
||||
* @return WP_User[]
|
||||
*/
|
||||
function get_contributor_user_objects( array $contributor_posts ) {
|
||||
return array_map( function( WP_Post $post ) {
|
||||
return get_user_by( 'login', $post->post_title );
|
||||
}, $contributor_posts );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue