1.5K | Posts |
64.5K | Downloads |
16 | Plugins |
Works but is hackish:
$eval = \gp\tool::function_exists('eval'); if( $eval ){ $template_file = file_exists($page->theme_dir.'/'.$page->theme_color.'/template.php') ? $page->theme_dir.'/'.$page->theme_color.'/template.php' : $page->theme_dir.'/template.php'; if( file_exists($template_file) ){ $template_php = file_get_contents($template_file); preg_match('#\$GP_MENU_CLASSES\s(.*?)\s*\);#is', $template_php, $matches); if( count($matches) ){ eval($matches[0]); } msg('$GP_MENU_CLASSES = ' . pre($GP_MENU_CLASSES) ); } }
Is there any better way to get $GP_MENU_CLASSES from within a plugin gadget (without the need of editing the template.php)?
Thx!
2K | Posts |
311K | Downloads |
16 | Themes |
18 | Plugins |
1.5K | Posts |
64.5K | Downloads |
16 | Plugins |
1.5K | Posts |
64.5K | Downloads |
16 | Plugins |
2K | Posts |
311K | Downloads |
16 | Themes |
18 | Plugins |
1.5K | Posts |
64.5K | Downloads |
16 | Plugins |
Thanks! A mini-addon for testing: TestGMC.zip
2K | Posts |
311K | Downloads |
16 | Themes |
18 | Plugins |
Here's what's happening.
Gadget content is generated before it's actually added to a webpage. ( Generated in PrepGadgetContent() which is called by gpOutput::GetHead() )
Themes that I have made place the definition of $GP_MENU_CLASSES after the call to gpOutput::GetHead().
So, for $GP_MENU_CLASSES to be available, it should really be set in the settings.php file instead of the template.php file of a theme.
1.5K | Posts |
64.5K | Downloads |
16 | Plugins |
I already thought it must be something like that. Hmm.
Actually it would have been cool to know the exact menu classes on PHP side in the gadget, but on the other hand I at least know if $GP_MENU_ELEMENTS is 'BootstrapMenu" or not, which is a key puzzle piece. I'll probably get the other pieces togehter with some 'forensics'. Although regexing the values out of template.php and using eval() works it's unreliable (e.g. Suhosin etc.) and not exactly performance-wise. Funnily the most efficient way was checking the theme name against a handwritten LUT.
Thanks for checking!
A new release for Typesetter is in the works with a lot of improvements including the ... Read More
Typesetter 5.1Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More
More News
What CMS: Find out what CMS a site is using.
Who Hosts This: Find out who is hosting any web site
WordPress Theme Detect: Find out which theme a WordPress site is using