Avoid PHP warning on Calendar edit page

Avoid PHP Warning:  Invalid argument supplied for foreach() in \wp-content\plugins\sportspress-pro\includes\sportspress\includes\class-sp-event.php on line 587

The error occurs on Calendar Edit page when there is an event without an assigned official.
This commit is contained in:
savvasha
2018-09-01 18:15:22 +03:00
committed by GitHub
parent bf50beb953
commit 7b04d13d58

View File

@@ -584,8 +584,11 @@ class SP_Event extends SP_Custom_Post{
if ( ! $include_empty && empty( $duty_appointments ) ) continue;
$appointed_officials = array();
foreach ( $duty_appointments as $duty_appointment ) {
$appointed_officials[ $duty_appointment ] = get_the_title( $duty_appointment );
if ( is_array( $duty_appointments ) ) {
foreach ( $duty_appointments as $duty_appointment ) {
$appointed_officials[ $duty_appointment ] = get_the_title( $duty_appointment );
}
}
if ( $include_empty && empty( $appointed_officials ) ) $appointed_officials[] = $placeholder;