Contributors: Check if a pledge exists before displaying the pledge name

If somehow a pledge is deleted, the contributors listing in wp-admin shows an error trying to display the linked pledge.
This commit is contained in:
Kelly Dwan 2019-10-25 16:21:33 -04:00
parent 5ffca9420f
commit f47024efda
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D

View file

@ -100,6 +100,11 @@ function populate_list_table_columns( $column, $post_id ) {
$contributor = get_post( $post_id ); $contributor = get_post( $post_id );
$pledge = get_post( $contributor->post_parent ); $pledge = get_post( $contributor->post_parent );
if ( ! $pledge ) {
esc_html_e( 'Unattached', 'wordpressorg' );
break;
}
$pledge_name = get_the_title( $pledge ); $pledge_name = get_the_title( $pledge );
if ( current_user_can( 'edit_post', $pledge->ID ) ) { if ( current_user_can( 'edit_post', $pledge->ID ) ) {