Commit 4aef3f2c by Scott Vivian

Refactor qa_load_plugin_files to use qa_addon_metadata

parent 3973ffd6
...@@ -311,28 +311,29 @@ ...@@ -311,28 +311,29 @@
{ {
global $qa_plugin_directory, $qa_plugin_urltoroot; global $qa_plugin_directory, $qa_plugin_urltoroot;
$pluginfiles=glob(QA_PLUGIN_DIR.'*/qa-plugin.php'); $pluginfiles = glob(QA_PLUGIN_DIR.'*/qa-plugin.php');
foreach ($pluginfiles as $pluginfile) foreach ($pluginfiles as $pluginfile) {
if (file_exists($pluginfile)) { // limit plugin parsing to first 8kB
$contents=file_get_contents($pluginfile); $contents = file_get_contents($pluginfile, false, NULL, -1, 8192);
$metadata = qa_addon_metadata($contents, 'Plugin');
if (preg_match('/Plugin[ \t]*Minimum[ \t]*Question2Answer[ \t]*Version\:[ \t]*([0-9\.]+)\s/i', $contents, $matches)) // skip plugin which requires a later version of Q2A
if (qa_qa_version_below($matches[1])) if (isset($metadata['min_q2a']) && qa_qa_version_below($metadata['min_q2a']))
continue; // skip plugin which requires a later version of Q2A continue;
// skip plugin which requires a later version of PHP
if (isset($metadata['min_php']) && qa_php_version_below($metadata['min_php']))
continue;
if (preg_match('/Plugin[ \t]*Minimum[ \t]*PHP[ \t]*Version\:[ \t]*([0-9\.]+)\s/i', $contents, $matches)) // these variables are utilized in the qa_register_plugin_* functions
if (qa_php_version_below($matches[1])) $qa_plugin_directory = dirname($pluginfile).'/';
continue; // skip plugin which requires a later version of PHP $qa_plugin_urltoroot = substr($qa_plugin_directory, strlen(QA_BASE_DIR));
$qa_plugin_directory=dirname($pluginfile).'/'; require_once $pluginfile;
$qa_plugin_urltoroot=substr($qa_plugin_directory, strlen(QA_BASE_DIR)); }
require_once $pluginfile;
$qa_plugin_directory=null; $qa_plugin_directory = null;
$qa_plugin_urltoroot=null; $qa_plugin_urltoroot = null;
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment