= self::MAX_ITEMS ) { break; } } return $rows; } /** * Build plain questions from the event fields. * * @param array $event Event fields. * @return array Eventin FAQ rows. */ private static function fallback( array $event ): array { $title = trim( (string) ( $event['title'] ?? '' ) ); $date = Event_Description_Builder::date_line( $event ); $place = Event_Description_Builder::place_line( $event ); $name = '' !== $title ? $title : __( 'This event', 'aisentic' ); $when = '' !== $date ? sprintf( /* translators: 1: event title, 2: date and time line. */ __( '%1$s runs on %2$s.', 'aisentic' ), $name, $date ) : __( 'The date will be confirmed before this event goes live.', 'aisentic' ); $where = '' !== $place ? sprintf( /* translators: %s: event place. */ __( 'It takes place at %s.', 'aisentic' ), $place ) : __( 'The place will be confirmed before this event goes live.', 'aisentic' ); return [ self::row( __( 'When does this event take place?', 'aisentic' ), $when ), self::row( __( 'Where does this event take place?', 'aisentic' ), $where ), self::row( __( 'How do I get a ticket?', 'aisentic' ), __( 'Pick a ticket on this page and book it. You get a confirmation by email.', 'aisentic' ) ), ]; } /** * Build one Eventin FAQ row. * * @param string $question Question text. * @param string $answer Answer text. * @return array */ private static function row( string $question, string $answer ): array { return [ 'etn_faq_title' => sanitize_text_field( $question ), 'etn_faq_content' => wp_kses_post( $answer ), 'etn_faq_enabled' => true, ]; } }