you can create a hook to make communication between different parts :
in your theme :
add_filter("MY_THEME/creating_something", function ($return, $args1, $args2) {
error_log("calling creating_something in " . __FILE__);
if ($args2 > 2) {
$return = 100 * $args1 + $args2;
}
return $return;
}, 10, 3); // 3 is for the 3 arguments of the anonymous function
and everywhere else you can use it like that :
$result = apply_filters("MY_THEME/creating_something", 45, 0, 0);
// return 45
$result = apply_filters("MY_THEME/creating_something", 45, 30, 9);
// return 3009
in my example, 10
is the common priority for hooks. you can use different priority if, e.g., you want to override this filter in you development environment, you can do that :
add_filter("MY_THEME/creating_something", function ($return, $args1, $args2) {
return "It's dev here";
}, 500, 3);