Skip to main content
correct spelling, fix grammar
Source Link
Mayeenul Islam
  • 12.9k
  • 21
  • 85
  • 169

My autoloader class is responsible for loading must-use plugins that do not sit in the root of the mu-plugins folder. To locate them, I need to use the get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy looks like this:

|-- /mu-plugins
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?).

$plugins = array();
foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
    if (dirname($plugin_file) != '.') { // skip files directly at root
        $plugins[] = $plugin_file;
    }
}

Nevertheless, it works (as I've tested it).

I hope all makes sense. :) Thanks in advance!

My autoloader class is responsible for loading must-use plugins that do not sit in the root of the mu-plugins folder. To locate them, I need to use the get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy looks like this:

|-- /mu-plugins
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?).

$plugins = array();
foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
    if (dirname($plugin_file) != '.') { // skip files directly at root
        $plugins[] = $plugin_file;
    }
}

Nevertheless, it works (as I've tested it).

I hope all makes sense. :) Thanks in advance!

My autoloader class is responsible for loading must-use plugins that do not sit in the root of the mu-plugins folder. To locate them, I need to use the get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy looks like this:

|-- /mu-plugins
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?).

$plugins = array();
foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
    if (dirname($plugin_file) != '.') { // skip files directly at root
        $plugins[] = $plugin_file;
    }
}

Nevertheless, it works (as I've tested it).

I hope all makes sense. :)

My autoloader class is responsible for loading must-use plugins, that doesdo not sit onin the root MUof the mu-plugins folder. To locate themethem, I need to use the get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy goes aslooks like this:

|-- MU /mu-plugins folder
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?).

$plugins = array();
foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
    if (dirname($plugin_file) != '.') { // skip files directly at root
        $plugins[] = $plugin_file;
    }
}

Nevertheless, it works (as I've tested it).

I hope all makes sense. :) Thanks in advance!

My autoloader class is responsible for loading must-use plugins, that does not sit on the root MU folder. To locate theme, I need to use get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy goes as this:

|-- MU plugins folder
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?).

$plugins = array();
foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
    if (dirname($plugin_file) != '.') { // skip files directly at root
        $plugins[] = $plugin_file;
    }
}

Nevertheless, it works (as I've tested it).

I hope all makes sense. :) Thanks in advance!

My autoloader class is responsible for loading must-use plugins that do not sit in the root of the mu-plugins folder. To locate them, I need to use the get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy looks like this:

|-- /mu-plugins
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?).

$plugins = array();
foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
    if (dirname($plugin_file) != '.') { // skip files directly at root
        $plugins[] = $plugin_file;
    }
}

Nevertheless, it works (as I've tested it).

I hope all makes sense. :) Thanks in advance!

Tweeted twitter.com/#!/StackWordPress/status/462959126536912896
added 237 characters in body
Source Link

My autoloader class is responsible for loading must-use plugins, that does not sit on the root MU folder. To locate theme, I need to use get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy goes as this:

|-- MU plugins folder
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?).

$plugins = array();
foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
    if (dirname($plugin_file) != '.') { // skip files directly at root
        $plugins[] = $plugin_file;
    }
}

Nevertheless, it works (as I've tested it).

I hope all makes sense. :) Thanks in advance!

My autoloader class is responsible for loading must-use plugins, that does not sit on the root MU folder. To locate theme, I need to use get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy goes as this:

|-- MU plugins folder
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?). Nevertheless, it works (as I've tested it).

I hope all makes sense. :) Thanks in advance!

My autoloader class is responsible for loading must-use plugins, that does not sit on the root MU folder. To locate theme, I need to use get_plugins() function. According to Codex, the function accepts one parameter:

$plugin_folder (string) (optional): Relative path to single plugin folder.

My file hierarchy goes as this:

|-- MU plugins folder
|   |-- autoload.php                    // only includes wpmu/autoload.php
|   |-- /wpmu
|   |   |-- autoload.php                // uses **get_plugins()** and autoloads other MU plugins
|   |-- /mu-plugin-to-autoload-A
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded
|   |-- /mu-plugin-to-autoload-B
|   |   |-- plugin-file-to-autoload.php // this plugin file should be autoloaded

I thought I should go at it this way:

// array to store plugins
$plugins = [];
// get mu-plugin folders
$plugin_dirs = glob(WPMU_PLUGIN_DIR . '/*' , GLOB_ONLYDIR);
// loop through mu-plugin folders
foreach ($plugin_dirs as $plugin_dir) {
    $plugins[] = get_plugins($plugin_dir);
}

However get_plugins() function returns an empty array.

I want to achieve similar functionality as Sébastien Lavoie did in his Gist on GitHub. Its script should sit on the root of WPMU folder, as it uses get_plugins('/../mu-plugins'), which I do not understand at all (does it move back and forth to wpmu plugins folder?).

$plugins = array();
foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
    if (dirname($plugin_file) != '.') { // skip files directly at root
        $plugins[] = $plugin_file;
    }
}

Nevertheless, it works (as I've tested it).

I hope all makes sense. :) Thanks in advance!

Source Link
Loading