mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-22 19:13:44 +03:00
XProfile: Return early when no contributors to avoid error.
This commit is contained in:
parent
bc867a344e
commit
f409dbd3a6
|
@ -46,14 +46,19 @@ function get_xprofile_contribution_data( array $user_ids ) {
|
||||||
*
|
*
|
||||||
* @param int $pledge_id
|
* @param int $pledge_id
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array|false
|
||||||
*/
|
*/
|
||||||
function get_aggregate_contributor_data_for_pledge( $pledge_id ) {
|
function get_aggregate_contributor_data_for_pledge( $pledge_id ) {
|
||||||
$contributors = Contributor\get_contributor_user_objects(
|
|
||||||
// TODO set to 'publish' when finished testing.
|
// TODO set to 'publish' when finished testing.
|
||||||
Contributor\get_pledge_contributors( $pledge_id, 'pending' )
|
$contributor_posts = Contributor\get_pledge_contributors( $pledge_id, 'pending' );
|
||||||
);
|
|
||||||
$user_ids = wp_list_pluck( $contributors, 'ID' );
|
// All of their contributors might have declined the invitation and had their posts deleted.
|
||||||
|
if ( ! $contributor_posts ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$contributor_users = Contributor\get_contributor_user_objects( $contributor_posts );
|
||||||
|
$user_ids = wp_list_pluck( $contributor_users, 'ID' );
|
||||||
|
|
||||||
$data = get_xprofile_contribution_data( $user_ids );
|
$data = get_xprofile_contribution_data( $user_ids );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue