I have a function which returns a value that I'd like to check via another one. I can not echo it in the first function as far as I know, as it's used in a wordpress filter for body_class and outputted there.
So, how do I check what the returned value is in another function?
An example of the first function that returns $class, which is what I want to check:
function layout_class( $class ) {
// There is lots of more functionality here for the $layout variable
$layout = 'col-3cm';
$class[] = $layout;
return $class;
}
add_filter( 'body_class', 'layout_class' );
Now, this class decides whether or not to load a secondary sidebar template. So I would like to do:
function sidebar_dual() {
$layout = layout_class();
if (
( $layout == 'col-3cm' ) ||
( $layout == 'col-3cl' ) ||
( $layout == 'col-3cr' )
)
{ get_template_part('sidebar-2'); }
}
Since I can't echo out the first function, and don't want to write another function as it is quite big - how do I approach it? Is there an easy way to check a return value, similar to echo?