Last active
July 2, 2023 06:36
-
-
Save jonschr/a350ca2ead02d941e527a7ff44f1b4e8 to your computer and use it in GitHub Desktop.
This file contains 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 | |
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