I am trying to do something pretty out there with a PHP function.
I want to call a function but based on the area of the site, I want it to call a different function. This occurs in WP theme activation, but each theme that calls the function has different unique extras. Alas, I digress:
$mb_theme_action_mbinout = function() {
// this is code is for testing
$mb_locations = array();
for ($i = 1; $i <= 10; ++$i) {
$mb_locations[] = array(
'a' => 'Test item ' . $i,
'b' => 'loc0' . $i,
'c' => 'group1'
);
}
var_dump( $mb_locations );
};
$theme = function() {
echo 'mb_theme_action_' . get_option('stylesheet'); // output: mb_theme_action_mbinout
};
$theme();
The above doesn't work, but I have also tried:
$theme = 'mb_theme_action_' . get_option('stylesheet');
$theme();
// also
$$theme();
I know this is not conventional, but was wondering if there was a way for it to work? It would only be called once.