Last active
November 7, 2018 10:49
-
-
Save emohamed/28782aa3ee48b9c232134a5ac98dcae4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Container::make( 'block', 'Flight Details' ) | |
->add_fields( [ | |
Field::make( 'text', 'crb_from', 'From' ), | |
Field::make( 'text', 'crb_to', 'To' ), | |
Field::make( 'date_time', 'crb_departure_time', 'Departure Time' ), | |
Field::make( 'date_time', 'crb_arrival_time', 'Arrival Time' ), | |
Field::make( 'text', 'crb_duration', 'Duration' ), | |
]) | |
->set_block_render_function(function ($flight) { | |
$format = 'm d, H:i(Y)'; | |
$departure = date($format, strtotime($flight->departure_time)); | |
$arrival = date($format, strtotime($flight->arrival_time)); | |
?> | |
<section class="flight"> | |
<h2>Flight from <?php echo esc_html($flight->from) ?> to <?php echo esc_html($flight->to) ?></h2> | |
<p class="flight__departure">Departure: <?php echo $departure ?></p> | |
<p class="flight__arrival">Arrival: <?php echo $arrival ?></p> | |
<p class="flight__duration"><?php echo esc_html($flight->duation) ?></p> | |
</section> | |
<?php | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment