Skip to content

Instantly share code, notes, and snippets.

@matgargano
Created March 19, 2014 18:27
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 matgargano/9648111 to your computer and use it in GitHub Desktop.
Save matgargano/9648111 to your computer and use it in GitHub Desktop.
// theme code
$contestants = apply_filters('contestants', 'name');
if ( is_array( $contestants ) ) {
foreach($contestants as $contestant){
echo "hello " . $contestant . '<br>';
}
} elseif ( is_string($contestants)){
echo 'hello ' . $contestant . '<br>';
}
// if I add filter like this:
add_filter( 'contestants', function(){
return array('Tom','Dick','Harry');
});
// it will return :
// hello Tom
// hello Dick
// hello Harry
// if I add filter like this:
add_filter( 'contestants', function(){
return 'Chris';
});
// it will return :
// hello Chris
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment