improved readability of get_summary by using ternary operator

This commit is contained in:
ruru4143 2024-09-29 11:43:59 +02:00
parent f99f009e2e
commit 7c9424526d

View file

@ -158,13 +158,9 @@ final class GatherPress extends Event {
* @return string $summary The custom event summary. * @return string $summary The custom event summary.
*/ */
public function get_summary(): string { public function get_summary(): string {
if ( $this->wp_object->excerpt ) { $excerpt = $this->wp_object->post_excerpt
$excerpt = $this->wp_object->post_excerpt; ?: get_post_meta( $this->wp_object->ID, 'event-summary', true )
} elseif ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) { ?: $this->get_content();
$excerpt = get_post_meta( $this->wp_object->ID, 'event-summary', true );
} else {
$excerpt = $this->get_content();
}
$address = get_post_meta( $this->wp_object->ID, 'event-location', true ); $address = get_post_meta( $this->wp_object->ID, 'event-location', true );
$start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true ); $start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true );