here $softhopper_pick; is Redux Global variable.
We know that to get redux value need to call redux Global variable. And sometimes in Wordpress post looping need to call $post etc global variable outside of a function or class. But themeforest reviewer said to me All global variables should be within a function or class.
I searched in google but I got no solution. If anyone know the solution please inform me.
I don’t know how Redux stores its options but I use get_theme_mod() to get values saved by options framework (SMOF), alternatively it can be get_option().
It can be something like this: $value = get_theme_mod( 'option_name' ); if ( ! empty( $value ) { echo $value; // or do anything else }
Hello Webdenim,
Thanks your help, Temporary I solve this problem like this:-
$softhopper_pick = get_option(‘softhopper_pick’); // here softhopper_pick is the redux global option name;
But I don’t yet understand why reviewer soft reject this issue.
Wordpress theme standard is… Uhmm… How should I put it? Stupid as !@#$. Don’t use global, except inside functions or classes? Oh ok, fine, seems justifiable, but there is an inci tinci tiny problem. The footer.php file for example is included from WITHIN A FUNCTION called get_footer. Thus does it make any sense to you? Cause it sure doesn’t to me…
Meeh fine, lets take another example…
Hook me up baby… o.O
No really, use an overloaded action / filter system, so that you can hook up together and dance a bit and just break someone else’s ( !@#$ ) code, while your at it. A classic do{ } while(); in terms of php.
God I’m pissed… Do any of these reviewers actually have any idea about code optimization and PHP itself? I mean I’m no expert on all of the matters, but some of the things that are required by WordPress to make a theme are just plain old stupid.
I didn’t mean to trash anyone, but god I had to get it out.
Regarding your original question… I did it with a do action and made the logic inside the function.
For example, I’m using global variables to pass some information from a template ( single.php ) to a “template part” ( get_template_part() ). How would I go about putting that in a function?