Passing variable into a function that is only "called" by a hook?
-
Normally in PHP a function call accepts parameters and thus you can pass outside variables into the function:
//variable is declared $foo = 'bar'; //function is created function foobar($parameter) { echo $parameter; } //function is called with previously declared variable foobar($foo); Outputs: bar
However, when using WordPress Hooks the callback doesn’t accept parameters and thus I’m wondering if there’s another way to pass variables declared outside of the function’s scope into that function?
(‘global’ variables doesn’t seem to work: probably because all theme/plugin-functions are nested functions thus the parent level isn’t truly global)
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Passing variable into a function that is only "called" by a hook?’ is closed to new replies.