WP_Debug_Data::get_wp_mu_plugins()private staticWP 6.7.0

Gets the WordPress MU plugins section of the debug data.

Method of the class: WP_Debug_Data{}

No Hooks.

Return

Array.

Usage

$result = WP_Debug_Data::get_wp_mu_plugins(): array;

Changelog

Since 6.7.0 Introduced.

WP_Debug_Data::get_wp_mu_plugins() code WP 6.8

private static function get_wp_mu_plugins(): array {
	// List must use plugins if there are any.
	$mu_plugins = get_mu_plugins();
	$fields     = array();

	foreach ( $mu_plugins as $plugin_path => $plugin ) {
		$plugin_version = $plugin['Version'];
		$plugin_author  = $plugin['Author'];

		$plugin_version_string       = __( 'No version or author information is available.' );
		$plugin_version_string_debug = 'author: (undefined), version: (undefined)';

		if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
			/* translators: 1: Plugin version number. 2: Plugin author name. */
			$plugin_version_string       = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
			$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
		} else {
			if ( ! empty( $plugin_author ) ) {
				/* translators: %s: Plugin author name. */
				$plugin_version_string       = sprintf( __( 'By %s' ), $plugin_author );
				$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
			}

			if ( ! empty( $plugin_version ) ) {
				/* translators: %s: Plugin version number. */
				$plugin_version_string       = sprintf( __( 'Version %s' ), $plugin_version );
				$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
			}
		}

		$fields[ sanitize_text_field( $plugin['Name'] ) ] = array(
			'label' => $plugin['Name'],
			'value' => $plugin_version_string,
			'debug' => $plugin_version_string_debug,
		);
	}

	return array(
		'label'      => __( 'Must Use Plugins' ),
		'show_count' => true,
		'fields'     => $fields,
	);
}