Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aristath
Created April 3, 2018 21:19
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 aristath/636f5ad9af81de144f3512d93ab3b786 to your computer and use it in GitHub Desktop.
Save aristath/636f5ad9af81de144f3512d93ab3b786 to your computer and use it in GitHub Desktop.
<?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