Skip to content

Instantly share code, notes, and snippets.

@jonschr
Last active July 2, 2023 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonschr/a350ca2ead02d941e527a7ff44f1b4e8 to your computer and use it in GitHub Desktop.
Save jonschr/a350ca2ead02d941e527a7ff44f1b4e8 to your computer and use it in GitHub Desktop.
<?php
function show_takeout_info() {
$food_drink = get_field( 'food_drink' );
// bail if no takeout info
if ( !isset( $food_drink['take_out'] ) )
return;
// bail if takeout is not yes
if ( $food_drink['take_out'] != 'yes' )
return;
// get the phone number
if ( isset( $food_drink['takeout_phone'] ) ) {
$takeout_phone = $food_drink['takeout_phone'];
} else {
$takeout_phone = null;
}
// get the website
if ( isset( $food_drink['takeout_website'] ) ) {
$takeout_website = $food_drink['takeout_website'];
} else {
$takeout_website = null;
}
// bail if we don't have either a phone or websit
if ( !$takeout_phone && !$takeout_website )
return;
// markup
echo '<h3 class="thing-to-do">Take Out</h3>';
if ( $takeout_phone && $takeout_website ) {
printf( '<p>To place a takeout order, call %s or visit %s</p>', $takeout_phone, $takeout_website );
} elseif ( $takeout_phone && !$takeout_website ) {
printf( '<p>To place a takeout order, call %s</p>', $takeout_phone );
} elseif ( !$takeout_phone && $takeout_website ) {
printf( '<p>To place a takeout order, visit %s</p>', $takeout_website );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment