One of my recurring challenges with plugin development, is scoping variables.
If I have a plugin that creates variables, and want to use those variables in a variety of templates, sometimes those templates are in-scope, sometimes they are called via functions and so are out of scope.
My work-around is to use the $GLOBALS[] array to reference my variables.
I'd like to see some discussion on the pros and cons of that, and other approaches.
For example, what are the ramifications of storing my variables in the vBulletin $show array?
Another alternative is to add a plugin to each hook location where I want my variables, with "global $myvar" to force global scope.
I know this type of discussion is usually handled at vbulletin.org, but I find the community there less than helpful/mature/professional, so thought I'd try starting the discussion here.
If I have a plugin that creates variables, and want to use those variables in a variety of templates, sometimes those templates are in-scope, sometimes they are called via functions and so are out of scope.
My work-around is to use the $GLOBALS[] array to reference my variables.
I'd like to see some discussion on the pros and cons of that, and other approaches.
For example, what are the ramifications of storing my variables in the vBulletin $show array?
Another alternative is to add a plugin to each hook location where I want my variables, with "global $myvar" to force global scope.
I know this type of discussion is usually handled at vbulletin.org, but I find the community there less than helpful/mature/professional, so thought I'd try starting the discussion here.
Comment