I don't know if it's realy an issue or not, so I post on the forum before create a ticket.
in my themes, I use extensionEnabled('plugin_name') rather class_exists('class_name') or function_exists('function_name').
with that, I have an issue with cacheManager after a new install.
in my themeoption.php file, I have these lines to support cacheManager plugin :
`
if (extensionEnabled('cacheManager')) {
$me = basename(dirname(__FILE__));
cacheManager::deleteThemeCacheSizes($me);
cacheManager::addThemeCacheSize($me, getThemeOption('thumb_size'), NULL, NULL, getThemeOption('thumb_crop_width'), getThemeOption('thumb_crop_height'), NULL, NULL, true);
if (getOption('use_galleriffic')) {
cacheManager::addThemeCacheSize($me, 85, NULL, NULL, 85, 85, NULL, NULL, true);
cacheManager::addThemeCacheSize($me, 525, NULL, NULL, NULL, NULL, NULL, NULL, false);
}
cacheManager::addThemeCacheSize($me, getThemeOption('image_size'), NULL, NULL, NULL, NULL, NULL, NULL, false);
}
`
after a new install, when I go first to options/theme, I have this fatal error :
`Fatal error: Class 'cacheManager' not found in /home2/avbo7291/public_html/zenphoto_test/themes/zpArdoise/themeoptions.php on line 57`
(line 57 is the line 3 of the code above)
If I go firt on plugins tabs and apply without any other actinos, I have no issue.
so, despite cacheManager plugin is loaded, cacheManager class is not loaded.
is there a way to avoid this behaviour?
is it an issue of cacheManager or extensionEnabled?
Comments
For instance, the cacheManager plugin may be enabled but will never get loaded on the front end.
In my example above, if I use `class_exists()`, the test will be KO and cache values will not be generated.
Don't you think that all classes of enabled admin plugins should be loaded when we are in admin?
it is not clear for me.
For the other two it depends what you use. Some plugins just consists of procedural functions you should check first. Others may be based on a class. If you use a method of their class somewhere you have to check if the class exists as there is no function to check.
So the most secure is to check for function or class actually.
So, I wish to understand:
-how and when plugin classes are loaded, for admin and theme plugins?
-why classes of enabled admin plugins are not loaded when we are in admin tabs?
class_exists() means that, well, the class does exist, whether or not `extensionEnabled()` is true. Extensions may be loaded even if not enabled. For instance the colorbox plugin may be loaded by the user_login-out plugin even if not enabled.
So if you want to use functionality of a plugin you check if the functionality exists (`class_exists()` or `function_exists(`)) If you want to know if the use has selected the plugin you use `extensionEnabled()`.
You should be using `class_exists()` for the cacheManager settings because that is the convention for themes. These settings should be made even if the cacheManager plugin is not enabled, that is the convention as demonstrated by the Zenphoto provided themes.