Totally Zenned
- Join Date:
- Oct 2008
- Location:
- Croatia
- Posts:
- 1,808
- Plugin Contributions:
- 22
Encapsulated Plugins - frontend is_enabled() check
Unless I'm missing something obvious, it seems like there's no frontend function available to check if a certain plugin is installed and enabled?
I have built an Encapsulated Plugin that runs on both frontend and backend (Testimonials). Everything is fine, but I'd like to add a "centerbox" to the home page with some testimonials displayed there. Since there are no hooks to attach it to (@drbyte looking at you - remember the solution I had presented?), I'll just modify the template file. However, I'd like it to be dynamic and displayed only if the plugin is installed and enabled. In case the plugin gets disabled, the centerbox would need to be disabled as well. Turns out there's no function available (at least to my knowledge) that would allow me to check if a certain plugin is installed/enabled or not.
Am I missing something here? If not, I'm happy to PR:
function is_zc_plugin_enabled($plugin_key) {
global $db;
// Querying the correct plugin_control table
$sql = "SELECT status
FROM " . TABLE_PLUGIN_CONTROL . "
WHERE unique_key = :pluginKey:
LIMIT 1";
$sql = $db->bindVars($sql, ':pluginKey:', $plugin_key, 'string');
$check_plugin = $db->Execute($sql);
// If the record exists AND its status is 1, it is installed and enabled
if ($check_plugin->RecordCount() > 0 && (int)$check_plugin->fields['status'] === 1) {
return true;
}
return false;
}
My site - Pro ZC Help
My portfolio | My plugins