Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi-file plugins
#5
Exactly, sorry for the poor phrasing, when saying "include" I actually meant the require() function as is already used now in plugins_function(). OWS_Matthew, plugins are "included" this way in every page, even though most of them won't use their functions.

Here's the example form plugin_functions.php:23

Code:
foreach ($pluginfiles as $fi)
{
    $pathExt = pathinfo($fi,PATHINFO_EXTENSION );
    $pathName= pathinfo($fi,PATHINFO_FILENAME );
    if ($pathExt=="php")
    {
        $pluginsLoaded=true;
        require_once(GSPLUGINPATH . $fi);
    }
}

Here's the modified code:

Code:
foreach ($pluginfiles as $fi)
{
    $pathExt = pathinfo($fi,PATHINFO_EXTENSION );
    $pathName= pathinfo($fi,PATHINFO_FILENAME );

    if (is_file(GSPLUGINPATH . $fi)){
        if($pathExt == "php"){
            $pluginsLoaded=true;
            require_once(GSPLUGINPATH . $fi);
        }
    } else {
        if($fi != "." && $fi != ".." && is_file(GSPLUGINPATH . $fi . '/plugin.php')){
            $pluginsLoaded=true;
            require_once(GSPLUGINPATH . $fi . '/plugin.php');
        }
    }
}

I added is_file to the first check to avoid requiring directories, and then to check for the existance of a "plugin.php" file.
Note that the slash '/' is supposed to be fine for Win* platforms, and the "." and ".." directories are excluded from the list.
Reply


Messages In This Thread
Multi-file plugins - by tankmiche - 2010-09-24, 19:03:36
Multi-file plugins - by Zegnåt - 2010-09-25, 00:00:26
Multi-file plugins - by JWH_Matthew - 2010-09-25, 02:19:51
Multi-file plugins - by Zegnåt - 2010-09-25, 02:49:55
Multi-file plugins - by tankmiche - 2010-09-25, 03:26:37
Multi-file plugins - by ccagle8 - 2010-09-25, 10:10:07
Multi-file plugins - by tankmiche - 2010-09-25, 17:05:54



Users browsing this thread: 1 Guest(s)