Created
April 3, 2018 21:19
-
-
Save aristath/636f5ad9af81de144f3512d93ab3b786 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 | |
/** | |
* Returns the URL for an option. | |
* If no option is defined, return all. | |
* | |
* @param string $option The key of the item for which we want to get the URL. | |
* @return string|array Returns string if $option is defined. Returns array if option is false. | |
*/ | |
function my_cool_theme_get_radiobutton_option( $option = false ) { | |
$options = array( | |
'option-1' => 'url1', | |
'option-2' => 'url2', | |
'option-3' => 'url3', | |
'option-4' => 'url4', | |
'option-5' => 'url5', | |
); | |
// If not option is defined, return the whole array. | |
if ( ! $option ) { | |
return $options; | |
} | |
// If the defined option does not exist, return a fallback URL. | |
if ( ! isset( $options[ $option ] ) ) { | |
return 'fallback-url-here'; | |
} | |
// If we got this far, we're all good. Just return the desired URL. | |
return $options[ $option ]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment