Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Created April 11, 2013 08:53
Show Gist options
  • Save jdevalk/5361844 to your computer and use it in GitHub Desktop.
Save jdevalk/5361844 to your computer and use it in GitHub Desktop.
<?php
// If you have a function with a default argument:
function bla ( $echo = true ) {
if ( !$echo )
return 'bla';
else
echo 'bla';
}
// And you then hook this function:
add_action( 'wp_head', 'bla' );
// $echo remains unset and thus !$echo == true and the function returns instead of echos...
// Solutiuon, of course, is to change
if ( !$echo )
return 'bla';
// Into
if ( $echo === false )
return 'bla';
// But it takes some debugging to get there :)
@ramondelafuente
Copy link

By default, wp_head() does nothing but call do_action('wp_head')

It's probably bad form, but if -in your template- you replace:
wp_head();

with:
do_action('wp_head', true);

Your parameter will be passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment