protected function loadPlugins()
    {
        if (
            !defined('WP_PLUGIN_DIR') ||
            !defined('WPMU_PLUGIN_DIR') ||
            !is_blog_installed()
        ) {
            return;
        }

        $cache = get_site_option('wordplate_autoloader_plugin_cache');

        if ($cache !== false && isset($cache['files'])) {
            $cacheFiles = $cache['files'];

            foreach ($cacheFiles as $file) {
                // Check if plugin have been removed.
                if (!file_exists(WPMU_PLUGIN_DIR.'/'.$file)) {
                    $cache = false; // Invalidate cache.
                    break;
                }
            }
        } else {
            $cache = false; // Invalidate cache.
            $cacheFiles = [];
        }

        // Required for 'get_plugins' & 'get_mu_plugins' functions.
        require_once ABSPATH.'wp-admin/includes/plugin.php';

        $this->relativePath = UrlGenerator::getRelativePath(
            WP_PLUGIN_DIR.'/',
            WPMU_PLUGIN_DIR.'/'
        );

        $this->autoloadPlugins = get_plugins('/'.$this->relativePath);
        $this->mustUsePlugins = get_mu_plugins();

        // Remove duplicate plugins.
        $this->plugins = array_diff_key($this->autoloadPlugins, $this->mustUsePlugins);

        $this->files = array_keys($this->plugins);

        // Add relativePath before filename
        $this->relativeFiles = preg_filter('/^/', $this->relativePath, $this->files);

        $this->activate = array_diff($this->files, $cacheFiles);

        // Check if plugin have been added.
        if ($this->activate) {
            $cache = false; // Invalidate cache.
        }

        if ($cache === false) {
            // Update cache.
            update_site_option('wordplate_autoloader_plugin_cache', [
                'files' => $this->files,
            ]);
        }

        // Load already activated plugins
        $activated = array_diff($this->files, $this->activate);
        foreach ($activated as $file) {
            include_once WPMU_PLUGIN_DIR.'/'.$file;
        }

        add_action('after_setup_theme', function () {
            $this->activatePlugins();
        });
    }
protected function loadPlugins()
    {
        if (
            !defined('WP_PLUGIN_DIR') ||
            !defined('WPMU_PLUGIN_DIR') ||
            !is_blog_installed()
        ) {
            return;
        }

        $cache = get_site_option('wordplate_autoloader_plugin_cache');

        if ($cache !== false && isset($cache['files'])) {
            $cacheFiles = $cache['files'];

            foreach ($cacheFiles as $file) {
                // Check if plugin have been removed.
                if (!file_exists(WPMU_PLUGIN_DIR.'/'.$file)) {
                    $cache = false; // Invalidate cache.
                    break;
                }
            }
        } else {
            $cache = false; // Invalidate cache.
            $cacheFiles = [];
        }

        // Required for 'get_plugins' & 'get_mu_plugins' functions.
        require_once ABSPATH.'wp-admin/includes/plugin.php';

        $this->relativePath = UrlGenerator::getRelativePath(
            WP_PLUGIN_DIR.'/',
            WPMU_PLUGIN_DIR.'/'
        );

        $this->autoloadPlugins = get_plugins('/'.$this->relativePath);
        $this->mustUsePlugins = get_mu_plugins();

        // Remove duplicate plugins.
        $this->plugins = array_diff_key($this->autoloadPlugins, $this->mustUsePlugins);

        $this->files = array_keys($this->plugins);

        // Add relativePath before filename
        $this->relativeFiles = preg_filter('/^/', $this->relativePath, $this->files);

        $this->activate = array_diff($this->files, $cacheFiles);

        // Check if plugin have been added.
        if ($this->activate) {
            $cache = false; // Invalidate cache.
        }

        if ($cache === false) {
            // Update cache.
            update_site_option('wordplate_autoloader_plugin_cache', [
                'files' => $this->files,
            ]);
        }

        // Load already activated plugins
        $activated = array_diff($this->files, $this->activate);
        foreach ($activated as $file) {
            include_once WPMU_PLUGIN_DIR.'/'.$file;
        }

        add_action('after_setup_theme', function () {
            $this->activatePlugins();
        });
    }
protected function loadPlugins ( ) { if ( ! defined ( 'WP_PLUGIN_DIR' ) || ! defined ( 'WPMU_PLUGIN_DIR' ) || ! is_blog_installed ( ) ) { return ; } $ cache = get_site_option ( 'wordplate_autoloader_plugin_cache' ) ; if ( $ cache !== false && isset ( $ cache [ 'files' ] ) ) { $ cacheFiles = $ cache [ 'files' ] ; foreach ( $ cacheFiles as $ file ) { // Check if plugin have been removed. if ( ! file_exists ( WPMU_PLUGIN_DIR . '/' . $ file ) ) { $ cache = false ; // Invalidate cache. break ; } } } else { $ cache = false ; // Invalidate cache. $ cacheFiles = [ ] ; } // Required for 'get_plugins' & 'get_mu_plugins' functions. require_once ABSPATH . 'wp-admin/includes/plugin.php' ; $ this -> relativePath = UrlGenerator :: getRelativePath ( WP_PLUGIN_DIR . '/' , WPMU_PLUGIN_DIR . '/' ) ; $ this -> autoloadPlugins = get_plugins ( '/' . $ this -> relativePath ) ; $ this -> mustUsePlugins = get_mu_plugins ( ) ; // Remove duplicate plugins. $ this -> plugins = array_diff_key ( $ this -> autoloadPlugins , $ this -> mustUsePlugins ) ; $ this -> files = array_keys ( $ this -> plugins ) ; // Add relativePath before filename $ this -> relativeFiles = preg_filter ( '/^/' , $ this -> relativePath , $ this -> files ) ; $ this -> activate = array_diff ( $ this -> files , $ cacheFiles ) ; // Check if plugin have been added. if ( $ this -> activate ) { $ cache = false ; // Invalidate cache. } if ( $ cache === false ) { // Update cache. update_site_option ( 'wordplate_autoloader_plugin_cache' , [ 'files' => $ this -> files , ] ) ; } // Load already activated plugins $ activated = array_diff ( $ this -> files , $ this -> activate ) ; foreach ( $ activated as $ file ) { include_once WPMU_PLUGIN_DIR . '/' . $ file ; } add_action ( 'after_setup_theme' , function ( ) { $ this -> activatePlugins ( ) ; } ) ; }
Check if plugins changed & load plugins.

@return void
Check if plugins changed & load plugins .