How to define global functions in Winter CMS
7
I've seen this question asked over and over again, here's how to do this cleanly and easily with Winter...
Just add a file called "init.php" within your plugin's root:
init.php:
<?php
if (!function_exists('myGlobalFunction')) {
function myGlobalFunction()
{
return "Hello World!";
}
}
How do you call the global function from a settings model for example?
Since it's a global command, you just use
myGlobalFunction()
in the Settings model, using the example above.