[ Web Proxy ]
URL:
Viewing: https://developer.wordpress.org/reference/classes/wp_debug_data/get_wp_plugins_raw_data/ [Back]  [Original]

WP_Debug_Data::get_wp_plugins_raw_data() Method | Developer.WordPress.org Skip to content
WordPress.org

WP_Debug_Data::get_wp_plugins_raw_data(): array<string,

In this article

Table of Contents

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

Gets the raw plugin data for the WordPress active and inactive sections of the debug data.

Return

array<string, array<string, array<string, string>>> The raw plugin debug data for active and inactive plugins.

Source

private static function get_wp_plugins_raw_data(): array {
	// List all available plugins.
	$plugins        = get_plugins();
	$plugin_updates = get_plugin_updates();
	$transient      = get_site_transient( 'update_plugins' );

	$auto_updates = array();
	$fields       = array(
		'wp-plugins-active'   => array(),
		'wp-plugins-inactive' => array(),
	);

	$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' );

	if ( $auto_updates_enabled ) {
		$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
	}

	foreach ( $plugins as $plugin_path => $plugin ) {
		$plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive';

		$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 );
			}
		}

		if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
			/* translators: %s: Latest plugin version number. */
			$plugin_version_string       .= ' ' . sprintf( __( '(Latest version: %s)' ), $plugin_updates[ $plugin_path ]->update->new_version );
			$plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
		}

		if ( $auto_updates_enabled ) {
			if ( isset( $transient->response[ $plugin_path ] ) ) {
				$item = $transient->response[ $plugin_path ];
			} elseif ( isset( $transient->no_update[ $plugin_path ] ) ) {
				$item = $transient->no_update[ $plugin_path ];
			} else {
				$item = array(
					'id'            => $plugin_path,
					'slug'          => '',
					'plugin'        => $plugin_path,
					'new_version'   => '',
					'url'           => '',
					'package'       => '',
					'icons'         => array(),
					'banners'       => array(),
					'banners_rtl'   => array(),
					'tested'        => '',
					'requires_php'  => '',
					'compatibility' => new stdClass(),
				);
				$item = wp_parse_args( $plugin, $item );
			}

			$auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, (object) $item );

			if ( ! is_null( $auto_update_forced ) ) {
				$enabled = $auto_update_forced;
			} else {
				$enabled = in_array( $plugin_path, $auto_updates, true );
			}

			if ( $enabled ) {
				$auto_updates_string = __( 'Auto-updates enabled' );
			} else {
				$auto_updates_string = __( 'Auto-updates disabled' );
			}

			/**
			 * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.
			 *
			 * @since 5.5.0
			 *
			 * @param string $auto_updates_string The string output for the auto-updates column.
			 * @param string $plugin_path         The path to the plugin file.
			 * @param array  $plugin              An array of plugin data.
			 * @param bool   $enabled             Whether auto-updates are enabled for this item.
			 */
			$auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled );

			$plugin_version_string       .= ' | ' . $auto_updates_string;
			$plugin_version_string_debug .= ', ' . $auto_updates_string;
		}

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

	return $fields;
}

Hooks

apply_filters( ‘plugin_auto_update_debug_string’, string $auto_updates_string, string $plugin_path, array $plugin, bool $enabled )

Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.

UsesDescription
wp_is_auto_update_forced_for_item()wp-admin/includes/update.php

Checks whether auto-updates are forced for an item.

wp_is_auto_update_enabled_for_type()wp-admin/includes/update.php

Checks whether auto-updates are enabled.

get_plugin_updates()wp-admin/includes/update.php

Retrieves plugins with updates available.

is_plugin_active()wp-admin/includes/plugin.php

Determines whether a plugin is active.

get_plugins()wp-admin/includes/plugin.php

Checks the plugins directory and retrieve all plugin files with plugin data.

__()wp-includes/l10n.php

Retrieves the translation of $text.

sanitize_text_field()wp-includes/formatting.php

Sanitizes a string from user input or from the database.

wp_parse_args()wp-includes/functions.php

Merges user defined arguments into defaults array.

apply_filters()wp-includes/plugin.php

Calls the callback functions that have been added to a filter hook.

get_site_transient()wp-includes/option.php

Retrieves the value of a site transient.

get_site_option()wp-includes/option.php

Retrieve an option value for the current network based on name of option.

Show 6 moreShow less
Used byDescription
WP_Debug_Data::get_wp_plugins_active()wp-admin/includes/class-wp-debug-data.php

Gets the WordPress active plugins section of the debug data.

WP_Debug_Data::get_wp_plugins_inactive()wp-admin/includes/class-wp-debug-data.php

Gets the WordPress inactive plugins section of the debug data.

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.


Web Proxy Viewer  |  New URL  |  Original Page