-
Notifications
You must be signed in to change notification settings - Fork 1
Plugin.php_Hints_and_Tips
This article aims to provide some hints and tips that can be employed in a plugins plugin.php
file.
Normally, these variables are set directly in the plugin.php
file.
Using the code outlined below, the values required can be obtained from the myplugin
_sql.php
file. This file, when provided, also allows the website administrator to run a database check against the plugin tables to ensure they are set up correctly. So, creating an sql file serves two purposes and helps maintain the integrity of the plugin.
This applies 2.0 release only
Whenever plugin.php is called from one of the core tasks (installer/upgrader/uninstaller/plugin scanner) the array variable $plug is set. Fields which are present depend on the circumstances. In most cases the relevant entries from the plugin_table database entry are included if the plugin has been installed.
In many cases $plug['plug_action'] is set to indicate the current action:
- 'scan' - plugin scanner
- 'install' - a fresh install is to be performed
This information is sometimes relevant to assist plugin.php in determining the values to return.
To check whether a plugin is installed, call:
e107::isInstalled($plugname);
where $plugname is the plugin name (directory name).
The function returns TRUE if installed, FALSE otherwise.
This applies to 0.7.9 and above
All installed plugins are entered into the $pref['plug_installed'] array - the array index is the path of the plugin (as a directory name) and the data is the current version.
So, the contents of a typical array might be:
This information can be used in two ways:
- To check whether a plugin is installed, use isset($pref['plug_installed']['calendar_menu']) for example.
- To test the installed version of a plugin. Note that the version string text will be exactly as specified in plugin.php.
Read Wiki article integrate with e107 for safety tips.