Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

wp_get_mu_plugins() WordPress Function

The wp_get_mu_plugins() function is used to retrieve all the active mu-plugins (must-use plugins) on a WordPress site. This function returns an array of all the mu-plugins, which can be looped through and used as needed.

wp_get_mu_plugins() #

Retrieve an array of must-use plugin files.


Description

The default directory is wp-content/mu-plugins. To change the default directory manually, define WPMU_PLUGIN_DIR and WPMU_PLUGIN_URL in wp-config.php.


Top ↑

Return

(string[]) Array of absolute paths of files to include.


Top ↑

Source

File: wp-includes/load.php

function wp_get_mu_plugins() {
	$mu_plugins = array();
	if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
		return $mu_plugins;
	}
	$dh = opendir( WPMU_PLUGIN_DIR );
	if ( ! $dh ) {
		return $mu_plugins;
	}
	while ( ( $plugin = readdir( $dh ) ) !== false ) {
		if ( '.php' === substr( $plugin, -4 ) ) {
			$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
		}
	}
	closedir( $dh );
	sort( $mu_plugins );

	return $mu_plugins;
}

Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.