# wp-ultimate-post-grid/2.8.2/helpers/addon_loader.php

WP Ultimate Post Grid, version 2.8.2. 39 lines.

- Page: https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.8.2/code/helpers/addon_loader.php
- Raw: https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.8.2/raw/helpers/addon_loader.php
- Modified: 2015-04-15T08:46:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.8.2/code/helpers/addon_loader.php#L10-L20`.

```php
<?php

class WPUPG_Addon_Loader {

    public function __construct()
    {
    }

    /**
     * Loop all addons in the provided directory
     */
    public function load_addons( $dir )
    {
        if( !is_dir( $dir ) ) {
            return;
        }

        $contents = scandir( $dir );

        foreach( $contents as $content ) {
            if( $content != '.' && $content != '..' ) {
                $this->load_addon( $dir, $content );
            }
        }
    }

    /**
     * Include an addon, addon itself should handle initialization
     */
    public function load_addon( $dir, $addon )
    {
        $dir = rtrim( $dir, '/' );
        $file = $dir . '/' . $addon . '/' . $addon . '.php';

        if( is_file( $file ) ) {
            include_once( $file );
        }
    }
}
```
