Skip to content

Commit

Permalink
Bug fix: Check whether event_location property exists
Browse files Browse the repository at this point in the history
When an error is thrown, the stored event in the error doesn't have this property.
  • Loading branch information
joedolson committed Sep 11, 2024
1 parent 74e4be1 commit e59d968
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/my-calendar-locations.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ function mc_locations_fields( $has_data, $data, $context = 'location', $group_id
</div>';

$api_key = mc_get_option( 'gmap_api_key' );
$location = ( $has_data && 'event' === $context ) ? $data->event_location : false;
$location = ( $has_data && 'event' === $context && property_exists( $data, 'event_location' ) ) ? $data->event_location : false;
if ( $api_key && ! ( 'event' === $context && false === (bool) $location ) ) {
$return .= '<h3>' . __( 'Location Map', 'my-calendar' ) . '</h3>';
$map = mc_generate_map( $data, $context );
Expand Down Expand Up @@ -1223,10 +1223,10 @@ function mc_display_location_fields( $fields, $data, $context ) {
$return = '';
$location_id = false;
if ( is_object( $data ) && 'event' === $context ) {
$location_id = $data->event_location;
$location_id = ( property_exists( $data, 'event_location' ) ) ? $data->event_location : $location_id;
}
if ( is_object( $data ) && 'location' === $context ) {
$location_id = $data->location_id;
$location_id = ( property_exists( $data, 'event_location' ) ) ? $data->location_id : $location_id;
}

/**
Expand Down

0 comments on commit e59d968

Please sign in to comment.