Skip to main content
deleted 54 characters in body
Source Link
zanderwar
  • 421
  • 2
  • 8
/**
 * Load plugins specified by the array $load, containing the leading filenames in the /src/plugins/ folder
 * All plugins must be proceeded with *.plugin.php where the asterisk is the name of the respective plugin
 *
 * @since 0.1
 * @param array $load e.g: array("Users", "Products", "Pages")
 * @return bool Returns __true__ if successful or __false__ on error.void
 */
public function __construct($load) {
    
    $this->plugin_dir = $_SERVER['DOCUMENT_ROOT'] . "/PlugCMS/src/plugins";
    
    require_once($this->plugin_dir . "/Users.default.php"); // Included by default, and is required to gain access to the dashboard
    require_once($this->plugin_dir . "/Pages.default.php"); // You can remove this but you will need to remove the pageLoader.php mod_rewrite rule from .htaccess to get control of the front-end back.
    
    if (is_dir($this->plugin_dir)) {            
        if (is_array($load)) {
        
            $count = count($load);
            
            for ($i=0; $i < $count; $i++) {
                
                $filename = $this->plugin_dir . "/" . $load[$i] . ".plugin.php";
                
                if (file_exists($filename)) {
                
                    if (@require_once($filename)) {
                        $this->load_output['active'][] = $load[$i];
                    }
                    else
                    {
                        $this->load_output['failed'][] = $load[$i];
                    }
                
                }
                else
                {
                    $this->load_output['failed'][] = $load[$i];
                }
            }
            
        }
        else
        {
            $this->load_output['error'][] = "Error: $load must be an array";
        }   
    }
    else
    {
        $this->load_output['error'][] = "PlugCMS has detected the default plugin directory is missing ({$this->plugin_dir}). Please check the installation and try again..";
    }

}
/**
 * Load plugins specified by the array $load, containing the leading filenames in the /src/plugins/ folder
 * All plugins must be proceeded with *.plugin.php where the asterisk is the name of the respective plugin
 *
 * @since 0.1
 * @param array $load e.g: array("Users", "Products", "Pages")
 * @return bool Returns __true__ if successful or __false__ on error.
 */
public function __construct($load) {
    
    $this->plugin_dir = $_SERVER['DOCUMENT_ROOT'] . "/PlugCMS/src/plugins";
    
    require_once($this->plugin_dir . "/Users.default.php"); // Included by default, and is required to gain access to the dashboard
    require_once($this->plugin_dir . "/Pages.default.php"); // You can remove this but you will need to remove the pageLoader.php mod_rewrite rule from .htaccess to get control of the front-end back.
    
    if (is_dir($this->plugin_dir)) {            
        if (is_array($load)) {
        
            $count = count($load);
            
            for ($i=0; $i < $count; $i++) {
                
                $filename = $this->plugin_dir . "/" . $load[$i] . ".plugin.php";
                
                if (file_exists($filename)) {
                
                    if (@require_once($filename)) {
                        $this->load_output['active'][] = $load[$i];
                    }
                    else
                    {
                        $this->load_output['failed'][] = $load[$i];
                    }
                
                }
                else
                {
                    $this->load_output['failed'][] = $load[$i];
                }
            }
            
        }
        else
        {
            $this->load_output['error'][] = "Error: $load must be an array";
        }   
    }
    else
    {
        $this->load_output['error'][] = "PlugCMS has detected the default plugin directory is missing ({$this->plugin_dir}). Please check the installation and try again..";
    }

}
/**
 * Load plugins specified by the array $load, containing the leading filenames in the /src/plugins/ folder
 * All plugins must be proceeded with *.plugin.php where the asterisk is the name of the respective plugin
 *
 * @since 0.1
 * @param array $load e.g: array("Users", "Products", "Pages")
 * @return void
 */
public function __construct($load) {
    
    $this->plugin_dir = $_SERVER['DOCUMENT_ROOT'] . "/PlugCMS/src/plugins";
    
    require_once($this->plugin_dir . "/Users.default.php"); // Included by default, and is required to gain access to the dashboard
    require_once($this->plugin_dir . "/Pages.default.php"); // You can remove this but you will need to remove the pageLoader.php mod_rewrite rule from .htaccess to get control of the front-end back.
    
    if (is_dir($this->plugin_dir)) {            
        if (is_array($load)) {
        
            $count = count($load);
            
            for ($i=0; $i < $count; $i++) {
                
                $filename = $this->plugin_dir . "/" . $load[$i] . ".plugin.php";
                
                if (file_exists($filename)) {
                
                    if (@require_once($filename)) {
                        $this->load_output['active'][] = $load[$i];
                    }
                    else
                    {
                        $this->load_output['failed'][] = $load[$i];
                    }
                
                }
                else
                {
                    $this->load_output['failed'][] = $load[$i];
                }
            }
            
        }
        else
        {
            $this->load_output['error'][] = "Error: $load must be an array";
        }   
    }
    else
    {
        $this->load_output['error'][] = "PlugCMS has detected the default plugin directory is missing ({$this->plugin_dir}). Please check the installation and try again..";
    }

}
Make title reflect what the code does.
Link
rolfl
  • 97.5k
  • 17
  • 218
  • 418

Trying to optimise my fairly standard plugin loader, any tips on improvement? Pluggin' in Plugins

edited title
Link
zanderwar
  • 421
  • 2
  • 8

PHP: Can't seem Trying to get better at optimisingoptimise my codefairly standard plugin loader, looking for constructiveany tips on improvement?

Tweeted twitter.com/#!/StackCodeReview/status/525278773428494340
Formatting, etc.
Source Link
rolfl
  • 97.5k
  • 17
  • 218
  • 418
Loading
Source Link
zanderwar
  • 421
  • 2
  • 8
Loading