wp/wp-admin/includes/class-wp-debug-data.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    25 	 *
    25 	 *
    26 	 * @since 5.2.0
    26 	 * @since 5.2.0
    27 	 * @since 5.3.0 Added database charset, database collation,
    27 	 * @since 5.3.0 Added database charset, database collation,
    28 	 *              and timezone information.
    28 	 *              and timezone information.
    29 	 * @since 5.5.0 Added pretty permalinks support information.
    29 	 * @since 5.5.0 Added pretty permalinks support information.
       
    30 	 * @since 6.7.0 Modularized into separate theme-oriented methods.
    30 	 *
    31 	 *
    31 	 * @throws ImagickException
    32 	 * @throws ImagickException
    32 	 * @global wpdb  $wpdb               WordPress database abstraction object.
       
    33 	 * @global array $_wp_theme_features
       
    34 	 *
    33 	 *
    35 	 * @return array The debug data for the site.
    34 	 * @return array The debug data for the site.
    36 	 */
    35 	 */
    37 	public static function debug_data() {
    36 	public static function debug_data() {
    38 		global $wpdb, $_wp_theme_features;
    37 		/*
    39 
    38 		 * Set up the array that holds all debug information.
    40 		// Save few function calls.
    39 		 *
    41 		$upload_dir             = wp_upload_dir();
    40 		 * When iterating through the debug data, the ordering of the sections
    42 		$permalink_structure    = get_option( 'permalink_structure' );
    41 		 * occurs in insertion-order of the assignments into this array.
    43 		$is_ssl                 = is_ssl();
    42 		 *
    44 		$is_multisite           = is_multisite();
    43 		 * This is the single assignment of the sections before filtering. Null-entries will
    45 		$users_can_register     = get_option( 'users_can_register' );
    44 		 * be automatically be removed.
    46 		$blog_public            = get_option( 'blog_public' );
    45 		 */
    47 		$default_comment_status = get_option( 'default_comment_status' );
    46 		$info = array(
    48 		$environment_type       = wp_get_environment_type();
    47 			'wp-core'             => self::get_wp_core(),
    49 		$core_version           = get_bloginfo( 'version' );
    48 			'wp-paths-sizes'      => self::get_wp_paths_sizes(),
    50 		$core_updates           = get_core_updates();
    49 			'wp-dropins'          => self::get_wp_dropins(),
    51 		$core_update_needed     = '';
    50 			'wp-active-theme'     => self::get_wp_active_theme(),
    52 
    51 			'wp-parent-theme'     => self::get_wp_parent_theme(),
    53 		if ( is_array( $core_updates ) ) {
    52 			'wp-themes-inactive'  => self::get_wp_themes_inactive(),
    54 			foreach ( $core_updates as $core => $update ) {
    53 			'wp-mu-plugins'       => self::get_wp_mu_plugins(),
    55 				if ( 'upgrade' === $update->response ) {
    54 			'wp-plugins-active'   => self::get_wp_plugins_active(),
    56 					/* translators: %s: Latest WordPress version number. */
    55 			'wp-plugins-inactive' => self::get_wp_plugins_inactive(),
    57 					$core_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $update->version );
    56 			'wp-media'            => self::get_wp_media(),
    58 				} else {
    57 			'wp-server'           => self::get_wp_server(),
    59 					$core_update_needed = '';
    58 			'wp-database'         => self::get_wp_database(),
    60 				}
    59 			'wp-constants'        => self::get_wp_constants(),
    61 			}
    60 			'wp-filesystem'       => self::get_wp_filesystem(),
    62 		}
    61 		);
    63 
    62 
    64 		// Set up the array that holds all debug information.
    63 		/*
    65 		$info = array();
    64 		 * Remove null elements from the array. The individual methods are
    66 
    65 		 * allowed to return `null`, which communicates that the category
    67 		$info['wp-core'] = array(
    66 		 * of debug data isn't relevant and shouldn't be passed through.
    68 			'label'  => __( 'WordPress' ),
    67 		 */
    69 			'fields' => array(
    68 		$info = array_filter(
    70 				'version'                => array(
    69 			$info,
    71 					'label' => __( 'Version' ),
    70 			static function ( $section ) {
    72 					'value' => $core_version . $core_update_needed,
    71 				return isset( $section );
    73 					'debug' => $core_version,
    72 			}
    74 				),
    73 		);
    75 				'site_language'          => array(
       
    76 					'label' => __( 'Site Language' ),
       
    77 					'value' => get_locale(),
       
    78 				),
       
    79 				'user_language'          => array(
       
    80 					'label' => __( 'User Language' ),
       
    81 					'value' => get_user_locale(),
       
    82 				),
       
    83 				'timezone'               => array(
       
    84 					'label' => __( 'Timezone' ),
       
    85 					'value' => wp_timezone_string(),
       
    86 				),
       
    87 				'home_url'               => array(
       
    88 					'label'   => __( 'Home URL' ),
       
    89 					'value'   => get_bloginfo( 'url' ),
       
    90 					'private' => true,
       
    91 				),
       
    92 				'site_url'               => array(
       
    93 					'label'   => __( 'Site URL' ),
       
    94 					'value'   => get_bloginfo( 'wpurl' ),
       
    95 					'private' => true,
       
    96 				),
       
    97 				'permalink'              => array(
       
    98 					'label' => __( 'Permalink structure' ),
       
    99 					'value' => $permalink_structure ? $permalink_structure : __( 'No permalink structure set' ),
       
   100 					'debug' => $permalink_structure,
       
   101 				),
       
   102 				'https_status'           => array(
       
   103 					'label' => __( 'Is this site using HTTPS?' ),
       
   104 					'value' => $is_ssl ? __( 'Yes' ) : __( 'No' ),
       
   105 					'debug' => $is_ssl,
       
   106 				),
       
   107 				'multisite'              => array(
       
   108 					'label' => __( 'Is this a multisite?' ),
       
   109 					'value' => $is_multisite ? __( 'Yes' ) : __( 'No' ),
       
   110 					'debug' => $is_multisite,
       
   111 				),
       
   112 				'user_registration'      => array(
       
   113 					'label' => __( 'Can anyone register on this site?' ),
       
   114 					'value' => $users_can_register ? __( 'Yes' ) : __( 'No' ),
       
   115 					'debug' => $users_can_register,
       
   116 				),
       
   117 				'blog_public'            => array(
       
   118 					'label' => __( 'Is this site discouraging search engines?' ),
       
   119 					'value' => $blog_public ? __( 'No' ) : __( 'Yes' ),
       
   120 					'debug' => $blog_public,
       
   121 				),
       
   122 				'default_comment_status' => array(
       
   123 					'label' => __( 'Default comment status' ),
       
   124 					'value' => 'open' === $default_comment_status ? _x( 'Open', 'comment status' ) : _x( 'Closed', 'comment status' ),
       
   125 					'debug' => $default_comment_status,
       
   126 				),
       
   127 				'environment_type'       => array(
       
   128 					'label' => __( 'Environment type' ),
       
   129 					'value' => $environment_type,
       
   130 					'debug' => $environment_type,
       
   131 				),
       
   132 			),
       
   133 		);
       
   134 
       
   135 		if ( ! $is_multisite ) {
       
   136 			$info['wp-paths-sizes'] = array(
       
   137 				/* translators: Filesystem directory paths and storage sizes. */
       
   138 				'label'  => __( 'Directories and Sizes' ),
       
   139 				'fields' => array(),
       
   140 			);
       
   141 		}
       
   142 
       
   143 		$info['wp-dropins'] = array(
       
   144 			'label'       => __( 'Drop-ins' ),
       
   145 			'show_count'  => true,
       
   146 			'description' => sprintf(
       
   147 				/* translators: %s: wp-content directory name. */
       
   148 				__( 'Drop-ins are single files, found in the %s directory, that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ),
       
   149 				'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
       
   150 			),
       
   151 			'fields'      => array(),
       
   152 		);
       
   153 
       
   154 		$info['wp-active-theme'] = array(
       
   155 			'label'  => __( 'Active Theme' ),
       
   156 			'fields' => array(),
       
   157 		);
       
   158 
       
   159 		$info['wp-parent-theme'] = array(
       
   160 			'label'  => __( 'Parent Theme' ),
       
   161 			'fields' => array(),
       
   162 		);
       
   163 
       
   164 		$info['wp-themes-inactive'] = array(
       
   165 			'label'      => __( 'Inactive Themes' ),
       
   166 			'show_count' => true,
       
   167 			'fields'     => array(),
       
   168 		);
       
   169 
       
   170 		$info['wp-mu-plugins'] = array(
       
   171 			'label'      => __( 'Must Use Plugins' ),
       
   172 			'show_count' => true,
       
   173 			'fields'     => array(),
       
   174 		);
       
   175 
       
   176 		$info['wp-plugins-active'] = array(
       
   177 			'label'      => __( 'Active Plugins' ),
       
   178 			'show_count' => true,
       
   179 			'fields'     => array(),
       
   180 		);
       
   181 
       
   182 		$info['wp-plugins-inactive'] = array(
       
   183 			'label'      => __( 'Inactive Plugins' ),
       
   184 			'show_count' => true,
       
   185 			'fields'     => array(),
       
   186 		);
       
   187 
       
   188 		$info['wp-media'] = array(
       
   189 			'label'  => __( 'Media Handling' ),
       
   190 			'fields' => array(),
       
   191 		);
       
   192 
       
   193 		$info['wp-server'] = array(
       
   194 			'label'       => __( 'Server' ),
       
   195 			'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host&#8217;s assistance.' ),
       
   196 			'fields'      => array(),
       
   197 		);
       
   198 
       
   199 		$info['wp-database'] = array(
       
   200 			'label'  => __( 'Database' ),
       
   201 			'fields' => array(),
       
   202 		);
       
   203 
       
   204 		// Check if WP_DEBUG_LOG is set.
       
   205 		$wp_debug_log_value = __( 'Disabled' );
       
   206 
       
   207 		if ( is_string( WP_DEBUG_LOG ) ) {
       
   208 			$wp_debug_log_value = WP_DEBUG_LOG;
       
   209 		} elseif ( WP_DEBUG_LOG ) {
       
   210 			$wp_debug_log_value = __( 'Enabled' );
       
   211 		}
       
   212 
       
   213 		// Check CONCATENATE_SCRIPTS.
       
   214 		if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
       
   215 			$concatenate_scripts       = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
       
   216 			$concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
       
   217 		} else {
       
   218 			$concatenate_scripts       = __( 'Undefined' );
       
   219 			$concatenate_scripts_debug = 'undefined';
       
   220 		}
       
   221 
       
   222 		// Check COMPRESS_SCRIPTS.
       
   223 		if ( defined( 'COMPRESS_SCRIPTS' ) ) {
       
   224 			$compress_scripts       = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
       
   225 			$compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
       
   226 		} else {
       
   227 			$compress_scripts       = __( 'Undefined' );
       
   228 			$compress_scripts_debug = 'undefined';
       
   229 		}
       
   230 
       
   231 		// Check COMPRESS_CSS.
       
   232 		if ( defined( 'COMPRESS_CSS' ) ) {
       
   233 			$compress_css       = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' );
       
   234 			$compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
       
   235 		} else {
       
   236 			$compress_css       = __( 'Undefined' );
       
   237 			$compress_css_debug = 'undefined';
       
   238 		}
       
   239 
       
   240 		// Check WP_ENVIRONMENT_TYPE.
       
   241 		if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
       
   242 			$wp_environment_type = WP_ENVIRONMENT_TYPE;
       
   243 		} else {
       
   244 			$wp_environment_type = __( 'Undefined' );
       
   245 		}
       
   246 
       
   247 		$info['wp-constants'] = array(
       
   248 			'label'       => __( 'WordPress Constants' ),
       
   249 			'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
       
   250 			'fields'      => array(
       
   251 				'ABSPATH'             => array(
       
   252 					'label'   => 'ABSPATH',
       
   253 					'value'   => ABSPATH,
       
   254 					'private' => true,
       
   255 				),
       
   256 				'WP_HOME'             => array(
       
   257 					'label' => 'WP_HOME',
       
   258 					'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
       
   259 					'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
       
   260 				),
       
   261 				'WP_SITEURL'          => array(
       
   262 					'label' => 'WP_SITEURL',
       
   263 					'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
       
   264 					'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
       
   265 				),
       
   266 				'WP_CONTENT_DIR'      => array(
       
   267 					'label' => 'WP_CONTENT_DIR',
       
   268 					'value' => WP_CONTENT_DIR,
       
   269 				),
       
   270 				'WP_PLUGIN_DIR'       => array(
       
   271 					'label' => 'WP_PLUGIN_DIR',
       
   272 					'value' => WP_PLUGIN_DIR,
       
   273 				),
       
   274 				'WP_MEMORY_LIMIT'     => array(
       
   275 					'label' => 'WP_MEMORY_LIMIT',
       
   276 					'value' => WP_MEMORY_LIMIT,
       
   277 				),
       
   278 				'WP_MAX_MEMORY_LIMIT' => array(
       
   279 					'label' => 'WP_MAX_MEMORY_LIMIT',
       
   280 					'value' => WP_MAX_MEMORY_LIMIT,
       
   281 				),
       
   282 				'WP_DEBUG'            => array(
       
   283 					'label' => 'WP_DEBUG',
       
   284 					'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
       
   285 					'debug' => WP_DEBUG,
       
   286 				),
       
   287 				'WP_DEBUG_DISPLAY'    => array(
       
   288 					'label' => 'WP_DEBUG_DISPLAY',
       
   289 					'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ),
       
   290 					'debug' => WP_DEBUG_DISPLAY,
       
   291 				),
       
   292 				'WP_DEBUG_LOG'        => array(
       
   293 					'label' => 'WP_DEBUG_LOG',
       
   294 					'value' => $wp_debug_log_value,
       
   295 					'debug' => WP_DEBUG_LOG,
       
   296 				),
       
   297 				'SCRIPT_DEBUG'        => array(
       
   298 					'label' => 'SCRIPT_DEBUG',
       
   299 					'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
       
   300 					'debug' => SCRIPT_DEBUG,
       
   301 				),
       
   302 				'WP_CACHE'            => array(
       
   303 					'label' => 'WP_CACHE',
       
   304 					'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ),
       
   305 					'debug' => WP_CACHE,
       
   306 				),
       
   307 				'CONCATENATE_SCRIPTS' => array(
       
   308 					'label' => 'CONCATENATE_SCRIPTS',
       
   309 					'value' => $concatenate_scripts,
       
   310 					'debug' => $concatenate_scripts_debug,
       
   311 				),
       
   312 				'COMPRESS_SCRIPTS'    => array(
       
   313 					'label' => 'COMPRESS_SCRIPTS',
       
   314 					'value' => $compress_scripts,
       
   315 					'debug' => $compress_scripts_debug,
       
   316 				),
       
   317 				'COMPRESS_CSS'        => array(
       
   318 					'label' => 'COMPRESS_CSS',
       
   319 					'value' => $compress_css,
       
   320 					'debug' => $compress_css_debug,
       
   321 				),
       
   322 				'WP_ENVIRONMENT_TYPE' => array(
       
   323 					'label' => 'WP_ENVIRONMENT_TYPE',
       
   324 					'value' => $wp_environment_type,
       
   325 					'debug' => $wp_environment_type,
       
   326 				),
       
   327 				'WP_DEVELOPMENT_MODE' => array(
       
   328 					'label' => 'WP_DEVELOPMENT_MODE',
       
   329 					'value' => WP_DEVELOPMENT_MODE ? WP_DEVELOPMENT_MODE : __( 'Disabled' ),
       
   330 					'debug' => WP_DEVELOPMENT_MODE,
       
   331 				),
       
   332 				'DB_CHARSET'          => array(
       
   333 					'label' => 'DB_CHARSET',
       
   334 					'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
       
   335 					'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
       
   336 				),
       
   337 				'DB_COLLATE'          => array(
       
   338 					'label' => 'DB_COLLATE',
       
   339 					'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
       
   340 					'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
       
   341 				),
       
   342 			),
       
   343 		);
       
   344 
       
   345 		$is_writable_abspath            = wp_is_writable( ABSPATH );
       
   346 		$is_writable_wp_content_dir     = wp_is_writable( WP_CONTENT_DIR );
       
   347 		$is_writable_upload_dir         = wp_is_writable( $upload_dir['basedir'] );
       
   348 		$is_writable_wp_plugin_dir      = wp_is_writable( WP_PLUGIN_DIR );
       
   349 		$is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) );
       
   350 		$is_writable_fonts_dir          = wp_is_writable( wp_get_font_dir()['basedir'] );
       
   351 
       
   352 		$info['wp-filesystem'] = array(
       
   353 			'label'       => __( 'Filesystem Permissions' ),
       
   354 			'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ),
       
   355 			'fields'      => array(
       
   356 				'wordpress'  => array(
       
   357 					'label' => __( 'The main WordPress directory' ),
       
   358 					'value' => ( $is_writable_abspath ? __( 'Writable' ) : __( 'Not writable' ) ),
       
   359 					'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
       
   360 				),
       
   361 				'wp-content' => array(
       
   362 					'label' => __( 'The wp-content directory' ),
       
   363 					'value' => ( $is_writable_wp_content_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
   364 					'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
       
   365 				),
       
   366 				'uploads'    => array(
       
   367 					'label' => __( 'The uploads directory' ),
       
   368 					'value' => ( $is_writable_upload_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
   369 					'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
       
   370 				),
       
   371 				'plugins'    => array(
       
   372 					'label' => __( 'The plugins directory' ),
       
   373 					'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
   374 					'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
       
   375 				),
       
   376 				'themes'     => array(
       
   377 					'label' => __( 'The themes directory' ),
       
   378 					'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ),
       
   379 					'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
       
   380 				),
       
   381 				'fonts'      => array(
       
   382 					'label' => __( 'The fonts directory' ),
       
   383 					'value' => ( $is_writable_fonts_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
   384 					'debug' => ( $is_writable_fonts_dir ? 'writable' : 'not writable' ),
       
   385 				),
       
   386 			),
       
   387 		);
       
   388 
       
   389 		// Conditionally add debug information for multisite setups.
       
   390 		if ( is_multisite() ) {
       
   391 			$site_id = get_current_blog_id();
       
   392 
       
   393 			$info['wp-core']['fields']['site_id'] = array(
       
   394 				'label' => __( 'Site ID' ),
       
   395 				'value' => $site_id,
       
   396 				'debug' => $site_id,
       
   397 			);
       
   398 
       
   399 			$network_query = new WP_Network_Query();
       
   400 			$network_ids   = $network_query->query(
       
   401 				array(
       
   402 					'fields'        => 'ids',
       
   403 					'number'        => 100,
       
   404 					'no_found_rows' => false,
       
   405 				)
       
   406 			);
       
   407 
       
   408 			$site_count = 0;
       
   409 			foreach ( $network_ids as $network_id ) {
       
   410 				$site_count += get_blog_count( $network_id );
       
   411 			}
       
   412 
       
   413 			$info['wp-core']['fields']['site_count'] = array(
       
   414 				'label' => __( 'Site count' ),
       
   415 				'value' => $site_count,
       
   416 			);
       
   417 
       
   418 			$info['wp-core']['fields']['network_count'] = array(
       
   419 				'label' => __( 'Network count' ),
       
   420 				'value' => $network_query->found_networks,
       
   421 			);
       
   422 		}
       
   423 
       
   424 		$info['wp-core']['fields']['user_count'] = array(
       
   425 			'label' => __( 'User count' ),
       
   426 			'value' => get_user_count(),
       
   427 		);
       
   428 
       
   429 		// WordPress features requiring processing.
       
   430 		$wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) );
       
   431 
       
   432 		if ( ! is_wp_error( $wp_dotorg ) ) {
       
   433 			$info['wp-core']['fields']['dotorg_communication'] = array(
       
   434 				'label' => __( 'Communication with WordPress.org' ),
       
   435 				'value' => __( 'WordPress.org is reachable' ),
       
   436 				'debug' => 'true',
       
   437 			);
       
   438 		} else {
       
   439 			$info['wp-core']['fields']['dotorg_communication'] = array(
       
   440 				'label' => __( 'Communication with WordPress.org' ),
       
   441 				'value' => sprintf(
       
   442 					/* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
       
   443 					__( 'Unable to reach WordPress.org at %1$s: %2$s' ),
       
   444 					gethostbyname( 'wordpress.org' ),
       
   445 					$wp_dotorg->get_error_message()
       
   446 				),
       
   447 				'debug' => $wp_dotorg->get_error_message(),
       
   448 			);
       
   449 		}
       
   450 
       
   451 		// Remove accordion for Directories and Sizes if in Multisite.
       
   452 		if ( ! $is_multisite ) {
       
   453 			$loading = __( 'Loading&hellip;' );
       
   454 
       
   455 			$info['wp-paths-sizes']['fields'] = array(
       
   456 				'wordpress_path' => array(
       
   457 					'label' => __( 'WordPress directory location' ),
       
   458 					'value' => untrailingslashit( ABSPATH ),
       
   459 				),
       
   460 				'wordpress_size' => array(
       
   461 					'label' => __( 'WordPress directory size' ),
       
   462 					'value' => $loading,
       
   463 					'debug' => 'loading...',
       
   464 				),
       
   465 				'uploads_path'   => array(
       
   466 					'label' => __( 'Uploads directory location' ),
       
   467 					'value' => $upload_dir['basedir'],
       
   468 				),
       
   469 				'uploads_size'   => array(
       
   470 					'label' => __( 'Uploads directory size' ),
       
   471 					'value' => $loading,
       
   472 					'debug' => 'loading...',
       
   473 				),
       
   474 				'themes_path'    => array(
       
   475 					'label' => __( 'Themes directory location' ),
       
   476 					'value' => get_theme_root(),
       
   477 				),
       
   478 				'themes_size'    => array(
       
   479 					'label' => __( 'Themes directory size' ),
       
   480 					'value' => $loading,
       
   481 					'debug' => 'loading...',
       
   482 				),
       
   483 				'plugins_path'   => array(
       
   484 					'label' => __( 'Plugins directory location' ),
       
   485 					'value' => WP_PLUGIN_DIR,
       
   486 				),
       
   487 				'plugins_size'   => array(
       
   488 					'label' => __( 'Plugins directory size' ),
       
   489 					'value' => $loading,
       
   490 					'debug' => 'loading...',
       
   491 				),
       
   492 				'fonts_path'     => array(
       
   493 					'label' => __( 'Fonts directory location' ),
       
   494 					'value' => wp_get_font_dir()['basedir'],
       
   495 				),
       
   496 				'fonts_size'     => array(
       
   497 					'label' => __( 'Fonts directory size' ),
       
   498 					'value' => $loading,
       
   499 					'debug' => 'loading...',
       
   500 				),
       
   501 				'database_size'  => array(
       
   502 					'label' => __( 'Database size' ),
       
   503 					'value' => $loading,
       
   504 					'debug' => 'loading...',
       
   505 				),
       
   506 				'total_size'     => array(
       
   507 					'label' => __( 'Total installation size' ),
       
   508 					'value' => $loading,
       
   509 					'debug' => 'loading...',
       
   510 				),
       
   511 			);
       
   512 		}
       
   513 
       
   514 		// Get a list of all drop-in replacements.
       
   515 		$dropins = get_dropins();
       
   516 
       
   517 		// Get dropins descriptions.
       
   518 		$dropin_descriptions = _get_dropins();
       
   519 
       
   520 		// Spare few function calls.
       
   521 		$not_available = __( 'Not available' );
       
   522 
       
   523 		foreach ( $dropins as $dropin_key => $dropin ) {
       
   524 			$info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array(
       
   525 				'label' => $dropin_key,
       
   526 				'value' => $dropin_descriptions[ $dropin_key ][0],
       
   527 				'debug' => 'true',
       
   528 			);
       
   529 		}
       
   530 
       
   531 		// Populate the media fields.
       
   532 		$info['wp-media']['fields']['image_editor'] = array(
       
   533 			'label' => __( 'Active editor' ),
       
   534 			'value' => _wp_image_editor_choose(),
       
   535 		);
       
   536 
       
   537 		// Get ImageMagic information, if available.
       
   538 		if ( class_exists( 'Imagick' ) ) {
       
   539 			// Save the Imagick instance for later use.
       
   540 			$imagick             = new Imagick();
       
   541 			$imagemagick_version = $imagick->getVersion();
       
   542 		} else {
       
   543 			$imagemagick_version = __( 'Not available' );
       
   544 		}
       
   545 
       
   546 		$info['wp-media']['fields']['imagick_module_version'] = array(
       
   547 			'label' => __( 'ImageMagick version number' ),
       
   548 			'value' => ( is_array( $imagemagick_version ) ? $imagemagick_version['versionNumber'] : $imagemagick_version ),
       
   549 		);
       
   550 
       
   551 		$info['wp-media']['fields']['imagemagick_version'] = array(
       
   552 			'label' => __( 'ImageMagick version string' ),
       
   553 			'value' => ( is_array( $imagemagick_version ) ? $imagemagick_version['versionString'] : $imagemagick_version ),
       
   554 		);
       
   555 
       
   556 		$imagick_version = phpversion( 'imagick' );
       
   557 
       
   558 		$info['wp-media']['fields']['imagick_version'] = array(
       
   559 			'label' => __( 'Imagick version' ),
       
   560 			'value' => ( $imagick_version ) ? $imagick_version : __( 'Not available' ),
       
   561 		);
       
   562 
       
   563 		if ( ! function_exists( 'ini_get' ) ) {
       
   564 			$info['wp-media']['fields']['ini_get'] = array(
       
   565 				'label' => __( 'File upload settings' ),
       
   566 				'value' => sprintf(
       
   567 					/* translators: %s: ini_get() */
       
   568 					__( 'Unable to determine some settings, as the %s function has been disabled.' ),
       
   569 					'ini_get()'
       
   570 				),
       
   571 				'debug' => 'ini_get() is disabled',
       
   572 			);
       
   573 		} else {
       
   574 			// Get the PHP ini directive values.
       
   575 			$file_uploads        = ini_get( 'file_uploads' );
       
   576 			$post_max_size       = ini_get( 'post_max_size' );
       
   577 			$upload_max_filesize = ini_get( 'upload_max_filesize' );
       
   578 			$max_file_uploads    = ini_get( 'max_file_uploads' );
       
   579 			$effective           = min( wp_convert_hr_to_bytes( $post_max_size ), wp_convert_hr_to_bytes( $upload_max_filesize ) );
       
   580 
       
   581 			// Add info in Media section.
       
   582 			$info['wp-media']['fields']['file_uploads']        = array(
       
   583 				'label' => __( 'File uploads' ),
       
   584 				'value' => $file_uploads ? __( 'Enabled' ) : __( 'Disabled' ),
       
   585 				'debug' => $file_uploads,
       
   586 			);
       
   587 			$info['wp-media']['fields']['post_max_size']       = array(
       
   588 				'label' => __( 'Max size of post data allowed' ),
       
   589 				'value' => $post_max_size,
       
   590 			);
       
   591 			$info['wp-media']['fields']['upload_max_filesize'] = array(
       
   592 				'label' => __( 'Max size of an uploaded file' ),
       
   593 				'value' => $upload_max_filesize,
       
   594 			);
       
   595 			$info['wp-media']['fields']['max_effective_size']  = array(
       
   596 				'label' => __( 'Max effective file size' ),
       
   597 				'value' => size_format( $effective ),
       
   598 			);
       
   599 			$info['wp-media']['fields']['max_file_uploads']    = array(
       
   600 				'label' => __( 'Max number of files allowed' ),
       
   601 				'value' => number_format( $max_file_uploads ),
       
   602 			);
       
   603 		}
       
   604 
       
   605 		// If Imagick is used as our editor, provide some more information about its limitations.
       
   606 		if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
       
   607 			$limits = array(
       
   608 				'area'   => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),
       
   609 				'disk'   => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ),
       
   610 				'file'   => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ),
       
   611 				'map'    => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ),
       
   612 				'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ),
       
   613 				'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ),
       
   614 				'time'   => ( defined( 'imagick::RESOURCETYPE_TIME' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_TIME ) : $not_available ),
       
   615 			);
       
   616 
       
   617 			$limits_debug = array(
       
   618 				'imagick::RESOURCETYPE_AREA'   => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ),
       
   619 				'imagick::RESOURCETYPE_DISK'   => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'not available' ),
       
   620 				'imagick::RESOURCETYPE_FILE'   => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'not available' ),
       
   621 				'imagick::RESOURCETYPE_MAP'    => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'not available' ),
       
   622 				'imagick::RESOURCETYPE_MEMORY' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'not available' ),
       
   623 				'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ),
       
   624 				'imagick::RESOURCETYPE_TIME'   => ( defined( 'imagick::RESOURCETYPE_TIME' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_TIME ) : 'not available' ),
       
   625 			);
       
   626 
       
   627 			$info['wp-media']['fields']['imagick_limits'] = array(
       
   628 				'label' => __( 'Imagick Resource Limits' ),
       
   629 				'value' => $limits,
       
   630 				'debug' => $limits_debug,
       
   631 			);
       
   632 
       
   633 			try {
       
   634 				$formats = Imagick::queryFormats( '*' );
       
   635 			} catch ( Exception $e ) {
       
   636 				$formats = array();
       
   637 			}
       
   638 
       
   639 			$info['wp-media']['fields']['imagemagick_file_formats'] = array(
       
   640 				'label' => __( 'ImageMagick supported file formats' ),
       
   641 				'value' => ( empty( $formats ) ) ? __( 'Unable to determine' ) : implode( ', ', $formats ),
       
   642 				'debug' => ( empty( $formats ) ) ? 'Unable to determine' : implode( ', ', $formats ),
       
   643 			);
       
   644 		}
       
   645 
       
   646 		// Get GD information, if available.
       
   647 		if ( function_exists( 'gd_info' ) ) {
       
   648 			$gd = gd_info();
       
   649 		} else {
       
   650 			$gd = false;
       
   651 		}
       
   652 
       
   653 		$info['wp-media']['fields']['gd_version'] = array(
       
   654 			'label' => __( 'GD version' ),
       
   655 			'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
       
   656 			'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
       
   657 		);
       
   658 
       
   659 		$gd_image_formats     = array();
       
   660 		$gd_supported_formats = array(
       
   661 			'GIF Create' => 'GIF',
       
   662 			'JPEG'       => 'JPEG',
       
   663 			'PNG'        => 'PNG',
       
   664 			'WebP'       => 'WebP',
       
   665 			'BMP'        => 'BMP',
       
   666 			'AVIF'       => 'AVIF',
       
   667 			'HEIF'       => 'HEIF',
       
   668 			'TIFF'       => 'TIFF',
       
   669 			'XPM'        => 'XPM',
       
   670 		);
       
   671 
       
   672 		foreach ( $gd_supported_formats as $format_key => $format ) {
       
   673 			$index = $format_key . ' Support';
       
   674 			if ( isset( $gd[ $index ] ) && $gd[ $index ] ) {
       
   675 				array_push( $gd_image_formats, $format );
       
   676 			}
       
   677 		}
       
   678 
       
   679 		if ( ! empty( $gd_image_formats ) ) {
       
   680 			$info['wp-media']['fields']['gd_formats'] = array(
       
   681 				'label' => __( 'GD supported file formats' ),
       
   682 				'value' => implode( ', ', $gd_image_formats ),
       
   683 			);
       
   684 		}
       
   685 
       
   686 		// Get Ghostscript information, if available.
       
   687 		if ( function_exists( 'exec' ) ) {
       
   688 			$gs = exec( 'gs --version' );
       
   689 
       
   690 			if ( empty( $gs ) ) {
       
   691 				$gs       = $not_available;
       
   692 				$gs_debug = 'not available';
       
   693 			} else {
       
   694 				$gs_debug = $gs;
       
   695 			}
       
   696 		} else {
       
   697 			$gs       = __( 'Unable to determine if Ghostscript is installed' );
       
   698 			$gs_debug = 'unknown';
       
   699 		}
       
   700 
       
   701 		$info['wp-media']['fields']['ghostscript_version'] = array(
       
   702 			'label' => __( 'Ghostscript version' ),
       
   703 			'value' => $gs,
       
   704 			'debug' => $gs_debug,
       
   705 		);
       
   706 
       
   707 		// Populate the server debug fields.
       
   708 		if ( function_exists( 'php_uname' ) ) {
       
   709 			$server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );
       
   710 		} else {
       
   711 			$server_architecture = 'unknown';
       
   712 		}
       
   713 
       
   714 		$php_version_debug = PHP_VERSION;
       
   715 		// Whether PHP supports 64-bit.
       
   716 		$php64bit = ( PHP_INT_SIZE * 8 === 64 );
       
   717 
       
   718 		$php_version = sprintf(
       
   719 			'%s %s',
       
   720 			$php_version_debug,
       
   721 			( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
       
   722 		);
       
   723 
       
   724 		if ( $php64bit ) {
       
   725 			$php_version_debug .= ' 64bit';
       
   726 		}
       
   727 
       
   728 		$info['wp-server']['fields']['server_architecture'] = array(
       
   729 			'label' => __( 'Server architecture' ),
       
   730 			'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ),
       
   731 			'debug' => $server_architecture,
       
   732 		);
       
   733 		$info['wp-server']['fields']['httpd_software']      = array(
       
   734 			'label' => __( 'Web server' ),
       
   735 			'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ),
       
   736 			'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
       
   737 		);
       
   738 		$info['wp-server']['fields']['php_version']         = array(
       
   739 			'label' => __( 'PHP version' ),
       
   740 			'value' => $php_version,
       
   741 			'debug' => $php_version_debug,
       
   742 		);
       
   743 		$info['wp-server']['fields']['php_sapi']            = array(
       
   744 			'label' => __( 'PHP SAPI' ),
       
   745 			'value' => PHP_SAPI,
       
   746 			'debug' => PHP_SAPI,
       
   747 		);
       
   748 
       
   749 		// Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
       
   750 		if ( ! function_exists( 'ini_get' ) ) {
       
   751 			$info['wp-server']['fields']['ini_get'] = array(
       
   752 				'label' => __( 'Server settings' ),
       
   753 				'value' => sprintf(
       
   754 					/* translators: %s: ini_get() */
       
   755 					__( 'Unable to determine some settings, as the %s function has been disabled.' ),
       
   756 					'ini_get()'
       
   757 				),
       
   758 				'debug' => 'ini_get() is disabled',
       
   759 			);
       
   760 		} else {
       
   761 			$info['wp-server']['fields']['max_input_variables'] = array(
       
   762 				'label' => __( 'PHP max input variables' ),
       
   763 				'value' => ini_get( 'max_input_vars' ),
       
   764 			);
       
   765 			$info['wp-server']['fields']['time_limit']          = array(
       
   766 				'label' => __( 'PHP time limit' ),
       
   767 				'value' => ini_get( 'max_execution_time' ),
       
   768 			);
       
   769 
       
   770 			if ( WP_Site_Health::get_instance()->php_memory_limit !== ini_get( 'memory_limit' ) ) {
       
   771 				$info['wp-server']['fields']['memory_limit']       = array(
       
   772 					'label' => __( 'PHP memory limit' ),
       
   773 					'value' => WP_Site_Health::get_instance()->php_memory_limit,
       
   774 				);
       
   775 				$info['wp-server']['fields']['admin_memory_limit'] = array(
       
   776 					'label' => __( 'PHP memory limit (only for admin screens)' ),
       
   777 					'value' => ini_get( 'memory_limit' ),
       
   778 				);
       
   779 			} else {
       
   780 				$info['wp-server']['fields']['memory_limit'] = array(
       
   781 					'label' => __( 'PHP memory limit' ),
       
   782 					'value' => ini_get( 'memory_limit' ),
       
   783 				);
       
   784 			}
       
   785 
       
   786 			$info['wp-server']['fields']['max_input_time']      = array(
       
   787 				'label' => __( 'Max input time' ),
       
   788 				'value' => ini_get( 'max_input_time' ),
       
   789 			);
       
   790 			$info['wp-server']['fields']['upload_max_filesize'] = array(
       
   791 				'label' => __( 'Upload max filesize' ),
       
   792 				'value' => ini_get( 'upload_max_filesize' ),
       
   793 			);
       
   794 			$info['wp-server']['fields']['php_post_max_size']   = array(
       
   795 				'label' => __( 'PHP post max size' ),
       
   796 				'value' => ini_get( 'post_max_size' ),
       
   797 			);
       
   798 		}
       
   799 
       
   800 		if ( function_exists( 'curl_version' ) ) {
       
   801 			$curl = curl_version();
       
   802 
       
   803 			$info['wp-server']['fields']['curl_version'] = array(
       
   804 				'label' => __( 'cURL version' ),
       
   805 				'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
       
   806 			);
       
   807 		} else {
       
   808 			$info['wp-server']['fields']['curl_version'] = array(
       
   809 				'label' => __( 'cURL version' ),
       
   810 				'value' => $not_available,
       
   811 				'debug' => 'not available',
       
   812 			);
       
   813 		}
       
   814 
       
   815 		// SUHOSIN.
       
   816 		$suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
       
   817 
       
   818 		$info['wp-server']['fields']['suhosin'] = array(
       
   819 			'label' => __( 'Is SUHOSIN installed?' ),
       
   820 			'value' => ( $suhosin_loaded ? __( 'Yes' ) : __( 'No' ) ),
       
   821 			'debug' => $suhosin_loaded,
       
   822 		);
       
   823 
       
   824 		// Imagick.
       
   825 		$imagick_loaded = extension_loaded( 'imagick' );
       
   826 
       
   827 		$info['wp-server']['fields']['imagick_availability'] = array(
       
   828 			'label' => __( 'Is the Imagick library available?' ),
       
   829 			'value' => ( $imagick_loaded ? __( 'Yes' ) : __( 'No' ) ),
       
   830 			'debug' => $imagick_loaded,
       
   831 		);
       
   832 
       
   833 		// Pretty permalinks.
       
   834 		$pretty_permalinks_supported = got_url_rewrite();
       
   835 
       
   836 		$info['wp-server']['fields']['pretty_permalinks'] = array(
       
   837 			'label' => __( 'Are pretty permalinks supported?' ),
       
   838 			'value' => ( $pretty_permalinks_supported ? __( 'Yes' ) : __( 'No' ) ),
       
   839 			'debug' => $pretty_permalinks_supported,
       
   840 		);
       
   841 
       
   842 		// Check if a .htaccess file exists.
       
   843 		if ( is_file( ABSPATH . '.htaccess' ) ) {
       
   844 			// If the file exists, grab the content of it.
       
   845 			$htaccess_content = file_get_contents( ABSPATH . '.htaccess' );
       
   846 
       
   847 			// Filter away the core WordPress rules.
       
   848 			$filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
       
   849 			$filtered_htaccess_content = ! empty( $filtered_htaccess_content );
       
   850 
       
   851 			if ( $filtered_htaccess_content ) {
       
   852 				/* translators: %s: .htaccess */
       
   853 				$htaccess_rules_string = sprintf( __( 'Custom rules have been added to your %s file.' ), '.htaccess' );
       
   854 			} else {
       
   855 				/* translators: %s: .htaccess */
       
   856 				$htaccess_rules_string = sprintf( __( 'Your %s file contains only core WordPress features.' ), '.htaccess' );
       
   857 			}
       
   858 
       
   859 			$info['wp-server']['fields']['htaccess_extra_rules'] = array(
       
   860 				'label' => __( '.htaccess rules' ),
       
   861 				'value' => $htaccess_rules_string,
       
   862 				'debug' => $filtered_htaccess_content,
       
   863 			);
       
   864 		}
       
   865 
       
   866 		// Server time.
       
   867 		$date = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
       
   868 
       
   869 		$info['wp-server']['fields']['current']     = array(
       
   870 			'label' => __( 'Current time' ),
       
   871 			'value' => $date->format( DateTime::ATOM ),
       
   872 		);
       
   873 		$info['wp-server']['fields']['utc-time']    = array(
       
   874 			'label' => __( 'Current UTC time' ),
       
   875 			'value' => $date->format( DateTime::RFC850 ),
       
   876 		);
       
   877 		$info['wp-server']['fields']['server-time'] = array(
       
   878 			'label' => __( 'Current Server time' ),
       
   879 			'value' => wp_date( 'c', $_SERVER['REQUEST_TIME'] ),
       
   880 		);
       
   881 
       
   882 		// Populate the database debug fields.
       
   883 		if ( is_object( $wpdb->dbh ) ) {
       
   884 			// mysqli or PDO.
       
   885 			$extension = get_class( $wpdb->dbh );
       
   886 		} else {
       
   887 			// Unknown sql extension.
       
   888 			$extension = null;
       
   889 		}
       
   890 
       
   891 		$server = $wpdb->get_var( 'SELECT VERSION()' );
       
   892 
       
   893 		$client_version = $wpdb->dbh->client_info;
       
   894 
       
   895 		$info['wp-database']['fields']['extension'] = array(
       
   896 			'label' => __( 'Extension' ),
       
   897 			'value' => $extension,
       
   898 		);
       
   899 
       
   900 		$info['wp-database']['fields']['server_version'] = array(
       
   901 			'label' => __( 'Server version' ),
       
   902 			'value' => $server,
       
   903 		);
       
   904 
       
   905 		$info['wp-database']['fields']['client_version'] = array(
       
   906 			'label' => __( 'Client version' ),
       
   907 			'value' => $client_version,
       
   908 		);
       
   909 
       
   910 		$info['wp-database']['fields']['database_user'] = array(
       
   911 			'label'   => __( 'Database username' ),
       
   912 			'value'   => $wpdb->dbuser,
       
   913 			'private' => true,
       
   914 		);
       
   915 
       
   916 		$info['wp-database']['fields']['database_host'] = array(
       
   917 			'label'   => __( 'Database host' ),
       
   918 			'value'   => $wpdb->dbhost,
       
   919 			'private' => true,
       
   920 		);
       
   921 
       
   922 		$info['wp-database']['fields']['database_name'] = array(
       
   923 			'label'   => __( 'Database name' ),
       
   924 			'value'   => $wpdb->dbname,
       
   925 			'private' => true,
       
   926 		);
       
   927 
       
   928 		$info['wp-database']['fields']['database_prefix'] = array(
       
   929 			'label'   => __( 'Table prefix' ),
       
   930 			'value'   => $wpdb->prefix,
       
   931 			'private' => true,
       
   932 		);
       
   933 
       
   934 		$info['wp-database']['fields']['database_charset'] = array(
       
   935 			'label'   => __( 'Database charset' ),
       
   936 			'value'   => $wpdb->charset,
       
   937 			'private' => true,
       
   938 		);
       
   939 
       
   940 		$info['wp-database']['fields']['database_collate'] = array(
       
   941 			'label'   => __( 'Database collation' ),
       
   942 			'value'   => $wpdb->collate,
       
   943 			'private' => true,
       
   944 		);
       
   945 
       
   946 		$info['wp-database']['fields']['max_allowed_packet'] = array(
       
   947 			'label' => __( 'Max allowed packet size' ),
       
   948 			'value' => self::get_mysql_var( 'max_allowed_packet' ),
       
   949 		);
       
   950 
       
   951 		$info['wp-database']['fields']['max_connections'] = array(
       
   952 			'label' => __( 'Max connections number' ),
       
   953 			'value' => self::get_mysql_var( 'max_connections' ),
       
   954 		);
       
   955 
       
   956 		// List must use plugins if there are any.
       
   957 		$mu_plugins = get_mu_plugins();
       
   958 
       
   959 		foreach ( $mu_plugins as $plugin_path => $plugin ) {
       
   960 			$plugin_version = $plugin['Version'];
       
   961 			$plugin_author  = $plugin['Author'];
       
   962 
       
   963 			$plugin_version_string       = __( 'No version or author information is available.' );
       
   964 			$plugin_version_string_debug = 'author: (undefined), version: (undefined)';
       
   965 
       
   966 			if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
       
   967 				/* translators: 1: Plugin version number. 2: Plugin author name. */
       
   968 				$plugin_version_string       = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
       
   969 				$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
       
   970 			} else {
       
   971 				if ( ! empty( $plugin_author ) ) {
       
   972 					/* translators: %s: Plugin author name. */
       
   973 					$plugin_version_string       = sprintf( __( 'By %s' ), $plugin_author );
       
   974 					$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
       
   975 				}
       
   976 
       
   977 				if ( ! empty( $plugin_version ) ) {
       
   978 					/* translators: %s: Plugin version number. */
       
   979 					$plugin_version_string       = sprintf( __( 'Version %s' ), $plugin_version );
       
   980 					$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
       
   981 				}
       
   982 			}
       
   983 
       
   984 			$info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
       
   985 				'label' => $plugin['Name'],
       
   986 				'value' => $plugin_version_string,
       
   987 				'debug' => $plugin_version_string_debug,
       
   988 			);
       
   989 		}
       
   990 
       
   991 		// List all available plugins.
       
   992 		$plugins        = get_plugins();
       
   993 		$plugin_updates = get_plugin_updates();
       
   994 		$transient      = get_site_transient( 'update_plugins' );
       
   995 
       
   996 		$auto_updates = array();
       
   997 
       
   998 		$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' );
       
   999 
       
  1000 		if ( $auto_updates_enabled ) {
       
  1001 			$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
       
  1002 		}
       
  1003 
       
  1004 		foreach ( $plugins as $plugin_path => $plugin ) {
       
  1005 			$plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive';
       
  1006 
       
  1007 			$plugin_version = $plugin['Version'];
       
  1008 			$plugin_author  = $plugin['Author'];
       
  1009 
       
  1010 			$plugin_version_string       = __( 'No version or author information is available.' );
       
  1011 			$plugin_version_string_debug = 'author: (undefined), version: (undefined)';
       
  1012 
       
  1013 			if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
       
  1014 				/* translators: 1: Plugin version number. 2: Plugin author name. */
       
  1015 				$plugin_version_string       = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
       
  1016 				$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
       
  1017 			} else {
       
  1018 				if ( ! empty( $plugin_author ) ) {
       
  1019 					/* translators: %s: Plugin author name. */
       
  1020 					$plugin_version_string       = sprintf( __( 'By %s' ), $plugin_author );
       
  1021 					$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
       
  1022 				}
       
  1023 
       
  1024 				if ( ! empty( $plugin_version ) ) {
       
  1025 					/* translators: %s: Plugin version number. */
       
  1026 					$plugin_version_string       = sprintf( __( 'Version %s' ), $plugin_version );
       
  1027 					$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
       
  1028 				}
       
  1029 			}
       
  1030 
       
  1031 			if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
       
  1032 				/* translators: %s: Latest plugin version number. */
       
  1033 				$plugin_version_string       .= ' ' . sprintf( __( '(Latest version: %s)' ), $plugin_updates[ $plugin_path ]->update->new_version );
       
  1034 				$plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
       
  1035 			}
       
  1036 
       
  1037 			if ( $auto_updates_enabled ) {
       
  1038 				if ( isset( $transient->response[ $plugin_path ] ) ) {
       
  1039 					$item = $transient->response[ $plugin_path ];
       
  1040 				} elseif ( isset( $transient->no_update[ $plugin_path ] ) ) {
       
  1041 					$item = $transient->no_update[ $plugin_path ];
       
  1042 				} else {
       
  1043 					$item = array(
       
  1044 						'id'            => $plugin_path,
       
  1045 						'slug'          => '',
       
  1046 						'plugin'        => $plugin_path,
       
  1047 						'new_version'   => '',
       
  1048 						'url'           => '',
       
  1049 						'package'       => '',
       
  1050 						'icons'         => array(),
       
  1051 						'banners'       => array(),
       
  1052 						'banners_rtl'   => array(),
       
  1053 						'tested'        => '',
       
  1054 						'requires_php'  => '',
       
  1055 						'compatibility' => new stdClass(),
       
  1056 					);
       
  1057 					$item = wp_parse_args( $plugin, $item );
       
  1058 				}
       
  1059 
       
  1060 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, (object) $item );
       
  1061 
       
  1062 				if ( ! is_null( $auto_update_forced ) ) {
       
  1063 					$enabled = $auto_update_forced;
       
  1064 				} else {
       
  1065 					$enabled = in_array( $plugin_path, $auto_updates, true );
       
  1066 				}
       
  1067 
       
  1068 				if ( $enabled ) {
       
  1069 					$auto_updates_string = __( 'Auto-updates enabled' );
       
  1070 				} else {
       
  1071 					$auto_updates_string = __( 'Auto-updates disabled' );
       
  1072 				}
       
  1073 
       
  1074 				/**
       
  1075 				 * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.
       
  1076 				 *
       
  1077 				 * @since 5.5.0
       
  1078 				 *
       
  1079 				 * @param string $auto_updates_string The string output for the auto-updates column.
       
  1080 				 * @param string $plugin_path         The path to the plugin file.
       
  1081 				 * @param array  $plugin              An array of plugin data.
       
  1082 				 * @param bool   $enabled             Whether auto-updates are enabled for this item.
       
  1083 				 */
       
  1084 				$auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled );
       
  1085 
       
  1086 				$plugin_version_string       .= ' | ' . $auto_updates_string;
       
  1087 				$plugin_version_string_debug .= ', ' . $auto_updates_string;
       
  1088 			}
       
  1089 
       
  1090 			$info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
       
  1091 				'label' => $plugin['Name'],
       
  1092 				'value' => $plugin_version_string,
       
  1093 				'debug' => $plugin_version_string_debug,
       
  1094 			);
       
  1095 		}
       
  1096 
       
  1097 		// Populate the section for the currently active theme.
       
  1098 		$theme_features = array();
       
  1099 
       
  1100 		if ( ! empty( $_wp_theme_features ) ) {
       
  1101 			foreach ( $_wp_theme_features as $feature => $options ) {
       
  1102 				$theme_features[] = $feature;
       
  1103 			}
       
  1104 		}
       
  1105 
       
  1106 		$active_theme  = wp_get_theme();
       
  1107 		$theme_updates = get_theme_updates();
       
  1108 		$transient     = get_site_transient( 'update_themes' );
       
  1109 
       
  1110 		$active_theme_version       = $active_theme->version;
       
  1111 		$active_theme_version_debug = $active_theme_version;
       
  1112 
       
  1113 		$auto_updates         = array();
       
  1114 		$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' );
       
  1115 		if ( $auto_updates_enabled ) {
       
  1116 			$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
       
  1117 		}
       
  1118 
       
  1119 		if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
       
  1120 			$theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];
       
  1121 
       
  1122 			/* translators: %s: Latest theme version number. */
       
  1123 			$active_theme_version       .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_update_new_version );
       
  1124 			$active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version );
       
  1125 		}
       
  1126 
       
  1127 		$active_theme_author_uri = $active_theme->display( 'AuthorURI' );
       
  1128 
       
  1129 		if ( $active_theme->parent_theme ) {
       
  1130 			$active_theme_parent_theme = sprintf(
       
  1131 				/* translators: 1: Theme name. 2: Theme slug. */
       
  1132 				__( '%1$s (%2$s)' ),
       
  1133 				$active_theme->parent_theme,
       
  1134 				$active_theme->template
       
  1135 			);
       
  1136 			$active_theme_parent_theme_debug = sprintf(
       
  1137 				'%s (%s)',
       
  1138 				$active_theme->parent_theme,
       
  1139 				$active_theme->template
       
  1140 			);
       
  1141 		} else {
       
  1142 			$active_theme_parent_theme       = __( 'None' );
       
  1143 			$active_theme_parent_theme_debug = 'none';
       
  1144 		}
       
  1145 
       
  1146 		$info['wp-active-theme']['fields'] = array(
       
  1147 			'name'           => array(
       
  1148 				'label' => __( 'Name' ),
       
  1149 				'value' => sprintf(
       
  1150 					/* translators: 1: Theme name. 2: Theme slug. */
       
  1151 					__( '%1$s (%2$s)' ),
       
  1152 					$active_theme->name,
       
  1153 					$active_theme->stylesheet
       
  1154 				),
       
  1155 			),
       
  1156 			'version'        => array(
       
  1157 				'label' => __( 'Version' ),
       
  1158 				'value' => $active_theme_version,
       
  1159 				'debug' => $active_theme_version_debug,
       
  1160 			),
       
  1161 			'author'         => array(
       
  1162 				'label' => __( 'Author' ),
       
  1163 				'value' => wp_kses( $active_theme->author, array() ),
       
  1164 			),
       
  1165 			'author_website' => array(
       
  1166 				'label' => __( 'Author website' ),
       
  1167 				'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined' ) ),
       
  1168 				'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ),
       
  1169 			),
       
  1170 			'parent_theme'   => array(
       
  1171 				'label' => __( 'Parent theme' ),
       
  1172 				'value' => $active_theme_parent_theme,
       
  1173 				'debug' => $active_theme_parent_theme_debug,
       
  1174 			),
       
  1175 			'theme_features' => array(
       
  1176 				'label' => __( 'Theme features' ),
       
  1177 				'value' => implode( ', ', $theme_features ),
       
  1178 			),
       
  1179 			'theme_path'     => array(
       
  1180 				'label' => __( 'Theme directory location' ),
       
  1181 				'value' => get_stylesheet_directory(),
       
  1182 			),
       
  1183 		);
       
  1184 
       
  1185 		if ( $auto_updates_enabled ) {
       
  1186 			if ( isset( $transient->response[ $active_theme->stylesheet ] ) ) {
       
  1187 				$item = $transient->response[ $active_theme->stylesheet ];
       
  1188 			} elseif ( isset( $transient->no_update[ $active_theme->stylesheet ] ) ) {
       
  1189 				$item = $transient->no_update[ $active_theme->stylesheet ];
       
  1190 			} else {
       
  1191 				$item = array(
       
  1192 					'theme'        => $active_theme->stylesheet,
       
  1193 					'new_version'  => $active_theme->version,
       
  1194 					'url'          => '',
       
  1195 					'package'      => '',
       
  1196 					'requires'     => '',
       
  1197 					'requires_php' => '',
       
  1198 				);
       
  1199 			}
       
  1200 
       
  1201 			$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
       
  1202 
       
  1203 			if ( ! is_null( $auto_update_forced ) ) {
       
  1204 				$enabled = $auto_update_forced;
       
  1205 			} else {
       
  1206 				$enabled = in_array( $active_theme->stylesheet, $auto_updates, true );
       
  1207 			}
       
  1208 
       
  1209 			if ( $enabled ) {
       
  1210 				$auto_updates_string = __( 'Enabled' );
       
  1211 			} else {
       
  1212 				$auto_updates_string = __( 'Disabled' );
       
  1213 			}
       
  1214 
       
  1215 			/** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
       
  1216 			$auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled );
       
  1217 
       
  1218 			$info['wp-active-theme']['fields']['auto_update'] = array(
       
  1219 				'label' => __( 'Auto-updates' ),
       
  1220 				'value' => $auto_updates_string,
       
  1221 				'debug' => $auto_updates_string,
       
  1222 			);
       
  1223 		}
       
  1224 
       
  1225 		$parent_theme = $active_theme->parent();
       
  1226 
       
  1227 		if ( $parent_theme ) {
       
  1228 			$parent_theme_version       = $parent_theme->version;
       
  1229 			$parent_theme_version_debug = $parent_theme_version;
       
  1230 
       
  1231 			if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {
       
  1232 				$parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];
       
  1233 
       
  1234 				/* translators: %s: Latest theme version number. */
       
  1235 				$parent_theme_version       .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version );
       
  1236 				$parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );
       
  1237 			}
       
  1238 
       
  1239 			$parent_theme_author_uri = $parent_theme->display( 'AuthorURI' );
       
  1240 
       
  1241 			$info['wp-parent-theme']['fields'] = array(
       
  1242 				'name'           => array(
       
  1243 					'label' => __( 'Name' ),
       
  1244 					'value' => sprintf(
       
  1245 						/* translators: 1: Theme name. 2: Theme slug. */
       
  1246 						__( '%1$s (%2$s)' ),
       
  1247 						$parent_theme->name,
       
  1248 						$parent_theme->stylesheet
       
  1249 					),
       
  1250 				),
       
  1251 				'version'        => array(
       
  1252 					'label' => __( 'Version' ),
       
  1253 					'value' => $parent_theme_version,
       
  1254 					'debug' => $parent_theme_version_debug,
       
  1255 				),
       
  1256 				'author'         => array(
       
  1257 					'label' => __( 'Author' ),
       
  1258 					'value' => wp_kses( $parent_theme->author, array() ),
       
  1259 				),
       
  1260 				'author_website' => array(
       
  1261 					'label' => __( 'Author website' ),
       
  1262 					'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ),
       
  1263 					'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
       
  1264 				),
       
  1265 				'theme_path'     => array(
       
  1266 					'label' => __( 'Theme directory location' ),
       
  1267 					'value' => get_template_directory(),
       
  1268 				),
       
  1269 			);
       
  1270 
       
  1271 			if ( $auto_updates_enabled ) {
       
  1272 				if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) {
       
  1273 					$item = $transient->response[ $parent_theme->stylesheet ];
       
  1274 				} elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) {
       
  1275 					$item = $transient->no_update[ $parent_theme->stylesheet ];
       
  1276 				} else {
       
  1277 					$item = array(
       
  1278 						'theme'        => $parent_theme->stylesheet,
       
  1279 						'new_version'  => $parent_theme->version,
       
  1280 						'url'          => '',
       
  1281 						'package'      => '',
       
  1282 						'requires'     => '',
       
  1283 						'requires_php' => '',
       
  1284 					);
       
  1285 				}
       
  1286 
       
  1287 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
       
  1288 
       
  1289 				if ( ! is_null( $auto_update_forced ) ) {
       
  1290 					$enabled = $auto_update_forced;
       
  1291 				} else {
       
  1292 					$enabled = in_array( $parent_theme->stylesheet, $auto_updates, true );
       
  1293 				}
       
  1294 
       
  1295 				if ( $enabled ) {
       
  1296 					$parent_theme_auto_update_string = __( 'Enabled' );
       
  1297 				} else {
       
  1298 					$parent_theme_auto_update_string = __( 'Disabled' );
       
  1299 				}
       
  1300 
       
  1301 				/** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
       
  1302 				$parent_theme_auto_update_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $parent_theme, $enabled );
       
  1303 
       
  1304 				$info['wp-parent-theme']['fields']['auto_update'] = array(
       
  1305 					'label' => __( 'Auto-update' ),
       
  1306 					'value' => $parent_theme_auto_update_string,
       
  1307 					'debug' => $parent_theme_auto_update_string,
       
  1308 				);
       
  1309 			}
       
  1310 		}
       
  1311 
       
  1312 		// Populate a list of all themes available in the install.
       
  1313 		$all_themes = wp_get_themes();
       
  1314 
       
  1315 		foreach ( $all_themes as $theme_slug => $theme ) {
       
  1316 			// Exclude the currently active theme from the list of all themes.
       
  1317 			if ( $active_theme->stylesheet === $theme_slug ) {
       
  1318 				continue;
       
  1319 			}
       
  1320 
       
  1321 			// Exclude the currently active parent theme from the list of all themes.
       
  1322 			if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) {
       
  1323 				continue;
       
  1324 			}
       
  1325 
       
  1326 			$theme_version = $theme->version;
       
  1327 			$theme_author  = $theme->author;
       
  1328 
       
  1329 			// Sanitize.
       
  1330 			$theme_author = wp_kses( $theme_author, array() );
       
  1331 
       
  1332 			$theme_version_string       = __( 'No version or author information is available.' );
       
  1333 			$theme_version_string_debug = 'undefined';
       
  1334 
       
  1335 			if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {
       
  1336 				/* translators: 1: Theme version number. 2: Theme author name. */
       
  1337 				$theme_version_string       = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author );
       
  1338 				$theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author );
       
  1339 			} else {
       
  1340 				if ( ! empty( $theme_author ) ) {
       
  1341 					/* translators: %s: Theme author name. */
       
  1342 					$theme_version_string       = sprintf( __( 'By %s' ), $theme_author );
       
  1343 					$theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author );
       
  1344 				}
       
  1345 
       
  1346 				if ( ! empty( $theme_version ) ) {
       
  1347 					/* translators: %s: Theme version number. */
       
  1348 					$theme_version_string       = sprintf( __( 'Version %s' ), $theme_version );
       
  1349 					$theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version );
       
  1350 				}
       
  1351 			}
       
  1352 
       
  1353 			if ( array_key_exists( $theme_slug, $theme_updates ) ) {
       
  1354 				/* translators: %s: Latest theme version number. */
       
  1355 				$theme_version_string       .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] );
       
  1356 				$theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );
       
  1357 			}
       
  1358 
       
  1359 			if ( $auto_updates_enabled ) {
       
  1360 				if ( isset( $transient->response[ $theme_slug ] ) ) {
       
  1361 					$item = $transient->response[ $theme_slug ];
       
  1362 				} elseif ( isset( $transient->no_update[ $theme_slug ] ) ) {
       
  1363 					$item = $transient->no_update[ $theme_slug ];
       
  1364 				} else {
       
  1365 					$item = array(
       
  1366 						'theme'        => $theme_slug,
       
  1367 						'new_version'  => $theme->version,
       
  1368 						'url'          => '',
       
  1369 						'package'      => '',
       
  1370 						'requires'     => '',
       
  1371 						'requires_php' => '',
       
  1372 					);
       
  1373 				}
       
  1374 
       
  1375 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
       
  1376 
       
  1377 				if ( ! is_null( $auto_update_forced ) ) {
       
  1378 					$enabled = $auto_update_forced;
       
  1379 				} else {
       
  1380 					$enabled = in_array( $theme_slug, $auto_updates, true );
       
  1381 				}
       
  1382 
       
  1383 				if ( $enabled ) {
       
  1384 					$auto_updates_string = __( 'Auto-updates enabled' );
       
  1385 				} else {
       
  1386 					$auto_updates_string = __( 'Auto-updates disabled' );
       
  1387 				}
       
  1388 
       
  1389 				/**
       
  1390 				 * Filters the text string of the auto-updates setting for each theme in the Site Health debug data.
       
  1391 				 *
       
  1392 				 * @since 5.5.0
       
  1393 				 *
       
  1394 				 * @param string   $auto_updates_string The string output for the auto-updates column.
       
  1395 				 * @param WP_Theme $theme               An object of theme data.
       
  1396 				 * @param bool     $enabled             Whether auto-updates are enabled for this item.
       
  1397 				 */
       
  1398 				$auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
       
  1399 
       
  1400 				$theme_version_string       .= ' | ' . $auto_updates_string;
       
  1401 				$theme_version_string_debug .= ', ' . $auto_updates_string;
       
  1402 			}
       
  1403 
       
  1404 			$info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->name ) ] = array(
       
  1405 				'label' => sprintf(
       
  1406 					/* translators: 1: Theme name. 2: Theme slug. */
       
  1407 					__( '%1$s (%2$s)' ),
       
  1408 					$theme->name,
       
  1409 					$theme_slug
       
  1410 				),
       
  1411 				'value' => $theme_version_string,
       
  1412 				'debug' => $theme_version_string_debug,
       
  1413 			);
       
  1414 		}
       
  1415 
       
  1416 		// Add more filesystem checks.
       
  1417 		if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
       
  1418 			$is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );
       
  1419 
       
  1420 			$info['wp-filesystem']['fields']['mu-plugins'] = array(
       
  1421 				'label' => __( 'The must use plugins directory' ),
       
  1422 				'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
  1423 				'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ),
       
  1424 			);
       
  1425 		}
       
  1426 
    74 
  1427 		/**
    75 		/**
  1428 		 * Filters the debug information shown on the Tools -> Site Health -> Info screen.
    76 		 * Filters the debug information shown on the Tools -> Site Health -> Info screen.
  1429 		 *
    77 		 *
  1430 		 * Plugin or themes may wish to introduce their own debug information without creating
    78 		 * Plugin or themes may wish to introduce their own debug information without creating
  1488 
   136 
  1489 		return $info;
   137 		return $info;
  1490 	}
   138 	}
  1491 
   139 
  1492 	/**
   140 	/**
       
   141 	 * Gets the WordPress core section of the debug data.
       
   142 	 *
       
   143 	 * @since 6.7.0
       
   144 	 *
       
   145 	 * @return array
       
   146 	 */
       
   147 	private static function get_wp_core(): array {
       
   148 		// Save few function calls.
       
   149 		$permalink_structure    = get_option( 'permalink_structure' );
       
   150 		$is_ssl                 = is_ssl();
       
   151 		$users_can_register     = get_option( 'users_can_register' );
       
   152 		$blog_public            = get_option( 'blog_public' );
       
   153 		$default_comment_status = get_option( 'default_comment_status' );
       
   154 		$environment_type       = wp_get_environment_type();
       
   155 		$core_version           = wp_get_wp_version();
       
   156 		$core_updates           = get_core_updates();
       
   157 		$core_update_needed     = '';
       
   158 
       
   159 		if ( is_array( $core_updates ) ) {
       
   160 			foreach ( $core_updates as $core => $update ) {
       
   161 				if ( 'upgrade' === $update->response ) {
       
   162 					/* translators: %s: Latest WordPress version number. */
       
   163 					$core_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $update->version );
       
   164 				} else {
       
   165 					$core_update_needed = '';
       
   166 				}
       
   167 			}
       
   168 		}
       
   169 
       
   170 		$fields = array(
       
   171 			'version'                => array(
       
   172 				'label' => __( 'Version' ),
       
   173 				'value' => $core_version . $core_update_needed,
       
   174 				'debug' => $core_version,
       
   175 			),
       
   176 			'site_language'          => array(
       
   177 				'label' => __( 'Site Language' ),
       
   178 				'value' => get_locale(),
       
   179 			),
       
   180 			'user_language'          => array(
       
   181 				'label' => __( 'User Language' ),
       
   182 				'value' => get_user_locale(),
       
   183 			),
       
   184 			'timezone'               => array(
       
   185 				'label' => __( 'Timezone' ),
       
   186 				'value' => wp_timezone_string(),
       
   187 			),
       
   188 			'home_url'               => array(
       
   189 				'label'   => __( 'Home URL' ),
       
   190 				'value'   => get_bloginfo( 'url' ),
       
   191 				'private' => true,
       
   192 			),
       
   193 			'site_url'               => array(
       
   194 				'label'   => __( 'Site URL' ),
       
   195 				'value'   => get_bloginfo( 'wpurl' ),
       
   196 				'private' => true,
       
   197 			),
       
   198 			'permalink'              => array(
       
   199 				'label' => __( 'Permalink structure' ),
       
   200 				'value' => $permalink_structure ? $permalink_structure : __( 'No permalink structure set' ),
       
   201 				'debug' => $permalink_structure,
       
   202 			),
       
   203 			'https_status'           => array(
       
   204 				'label' => __( 'Is this site using HTTPS?' ),
       
   205 				'value' => $is_ssl ? __( 'Yes' ) : __( 'No' ),
       
   206 				'debug' => $is_ssl,
       
   207 			),
       
   208 			'multisite'              => array(
       
   209 				'label' => __( 'Is this a multisite?' ),
       
   210 				'value' => is_multisite() ? __( 'Yes' ) : __( 'No' ),
       
   211 				'debug' => is_multisite(),
       
   212 			),
       
   213 			'user_registration'      => array(
       
   214 				'label' => __( 'Can anyone register on this site?' ),
       
   215 				'value' => $users_can_register ? __( 'Yes' ) : __( 'No' ),
       
   216 				'debug' => $users_can_register,
       
   217 			),
       
   218 			'blog_public'            => array(
       
   219 				'label' => __( 'Is this site discouraging search engines?' ),
       
   220 				'value' => $blog_public ? __( 'No' ) : __( 'Yes' ),
       
   221 				'debug' => $blog_public,
       
   222 			),
       
   223 			'default_comment_status' => array(
       
   224 				'label' => __( 'Default comment status' ),
       
   225 				'value' => 'open' === $default_comment_status ? _x( 'Open', 'comment status' ) : _x( 'Closed', 'comment status' ),
       
   226 				'debug' => $default_comment_status,
       
   227 			),
       
   228 			'environment_type'       => array(
       
   229 				'label' => __( 'Environment type' ),
       
   230 				'value' => $environment_type,
       
   231 				'debug' => $environment_type,
       
   232 			),
       
   233 		);
       
   234 
       
   235 		// Conditionally add debug information for multisite setups.
       
   236 		if ( is_multisite() ) {
       
   237 			$site_id = get_current_blog_id();
       
   238 
       
   239 			$fields['site_id'] = array(
       
   240 				'label' => __( 'Site ID' ),
       
   241 				'value' => $site_id,
       
   242 				'debug' => $site_id,
       
   243 			);
       
   244 
       
   245 			$network_query = new WP_Network_Query();
       
   246 			$network_ids   = $network_query->query(
       
   247 				array(
       
   248 					'fields'        => 'ids',
       
   249 					'number'        => 100,
       
   250 					'no_found_rows' => false,
       
   251 				)
       
   252 			);
       
   253 
       
   254 			$site_count = 0;
       
   255 			foreach ( $network_ids as $network_id ) {
       
   256 				$site_count += get_blog_count( $network_id );
       
   257 			}
       
   258 
       
   259 			$fields['site_count'] = array(
       
   260 				'label' => __( 'Site count' ),
       
   261 				'value' => $site_count,
       
   262 			);
       
   263 
       
   264 			$fields['network_count'] = array(
       
   265 				'label' => __( 'Network count' ),
       
   266 				'value' => $network_query->found_networks,
       
   267 			);
       
   268 		}
       
   269 
       
   270 		$fields['user_count'] = array(
       
   271 			'label' => __( 'User count' ),
       
   272 			'value' => get_user_count(),
       
   273 		);
       
   274 
       
   275 		// WordPress features requiring processing.
       
   276 		$wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) );
       
   277 
       
   278 		if ( ! is_wp_error( $wp_dotorg ) ) {
       
   279 			$fields['dotorg_communication'] = array(
       
   280 				'label' => __( 'Communication with WordPress.org' ),
       
   281 				'value' => __( 'WordPress.org is reachable' ),
       
   282 				'debug' => 'true',
       
   283 			);
       
   284 		} else {
       
   285 			$fields['dotorg_communication'] = array(
       
   286 				'label' => __( 'Communication with WordPress.org' ),
       
   287 				'value' => sprintf(
       
   288 				/* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
       
   289 					__( 'Unable to reach WordPress.org at %1$s: %2$s' ),
       
   290 					gethostbyname( 'wordpress.org' ),
       
   291 					$wp_dotorg->get_error_message()
       
   292 				),
       
   293 				'debug' => $wp_dotorg->get_error_message(),
       
   294 			);
       
   295 		}
       
   296 
       
   297 		return array(
       
   298 			'label'  => __( 'WordPress' ),
       
   299 			'fields' => $fields,
       
   300 		);
       
   301 	}
       
   302 
       
   303 	/**
       
   304 	 * Gets the WordPress drop-in section of the debug data.
       
   305 	 *
       
   306 	 * @since 6.7.0
       
   307 	 *
       
   308 	 * @return array
       
   309 	 */
       
   310 	private static function get_wp_dropins(): array {
       
   311 		// Get a list of all drop-in replacements.
       
   312 		$dropins = get_dropins();
       
   313 
       
   314 		// Get drop-ins descriptions.
       
   315 		$dropin_descriptions = _get_dropins();
       
   316 
       
   317 		$fields = array();
       
   318 		foreach ( $dropins as $dropin_key => $dropin ) {
       
   319 			$fields[ sanitize_text_field( $dropin_key ) ] = array(
       
   320 				'label' => $dropin_key,
       
   321 				'value' => $dropin_descriptions[ $dropin_key ][0],
       
   322 				'debug' => 'true',
       
   323 			);
       
   324 		}
       
   325 
       
   326 		return array(
       
   327 			'label'       => __( 'Drop-ins' ),
       
   328 			'show_count'  => true,
       
   329 			'description' => sprintf(
       
   330 				/* translators: %s: wp-content directory name. */
       
   331 				__( 'Drop-ins are single files, found in the %s directory, that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ),
       
   332 				'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
       
   333 			),
       
   334 			'fields'      => $fields,
       
   335 		);
       
   336 	}
       
   337 
       
   338 	/**
       
   339 	 * Gets the WordPress server section of the debug data.
       
   340 	 *
       
   341 	 * @since 6.7.0
       
   342 	 *
       
   343 	 * @return array
       
   344 	 */
       
   345 	private static function get_wp_server(): array {
       
   346 		// Populate the server debug fields.
       
   347 		if ( function_exists( 'php_uname' ) ) {
       
   348 			$server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );
       
   349 		} else {
       
   350 			$server_architecture = 'unknown';
       
   351 		}
       
   352 
       
   353 		$php_version_debug = PHP_VERSION;
       
   354 		// Whether PHP supports 64-bit.
       
   355 		$php64bit = ( PHP_INT_SIZE * 8 === 64 );
       
   356 
       
   357 		$php_version = sprintf(
       
   358 			'%s %s',
       
   359 			$php_version_debug,
       
   360 			( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
       
   361 		);
       
   362 
       
   363 		if ( $php64bit ) {
       
   364 			$php_version_debug .= ' 64bit';
       
   365 		}
       
   366 
       
   367 		$fields = array();
       
   368 
       
   369 		$fields['server_architecture'] = array(
       
   370 			'label' => __( 'Server architecture' ),
       
   371 			'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ),
       
   372 			'debug' => $server_architecture,
       
   373 		);
       
   374 		$fields['httpd_software']      = array(
       
   375 			'label' => __( 'Web server' ),
       
   376 			'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ),
       
   377 			'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
       
   378 		);
       
   379 		$fields['php_version']         = array(
       
   380 			'label' => __( 'PHP version' ),
       
   381 			'value' => $php_version,
       
   382 			'debug' => $php_version_debug,
       
   383 		);
       
   384 		$fields['php_sapi']            = array(
       
   385 			'label' => __( 'PHP SAPI' ),
       
   386 			'value' => PHP_SAPI,
       
   387 			'debug' => PHP_SAPI,
       
   388 		);
       
   389 
       
   390 		// Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
       
   391 		if ( ! function_exists( 'ini_get' ) ) {
       
   392 			$fields['ini_get'] = array(
       
   393 				'label' => __( 'Server settings' ),
       
   394 				'value' => sprintf(
       
   395 				/* translators: %s: ini_get() */
       
   396 					__( 'Unable to determine some settings, as the %s function has been disabled.' ),
       
   397 					'ini_get()'
       
   398 				),
       
   399 				'debug' => 'ini_get() is disabled',
       
   400 			);
       
   401 		} else {
       
   402 			$fields['max_input_variables'] = array(
       
   403 				'label' => __( 'PHP max input variables' ),
       
   404 				'value' => ini_get( 'max_input_vars' ),
       
   405 			);
       
   406 			$fields['time_limit']          = array(
       
   407 				'label' => __( 'PHP time limit' ),
       
   408 				'value' => ini_get( 'max_execution_time' ),
       
   409 			);
       
   410 
       
   411 			if ( WP_Site_Health::get_instance()->php_memory_limit !== ini_get( 'memory_limit' ) ) {
       
   412 				$fields['memory_limit']       = array(
       
   413 					'label' => __( 'PHP memory limit' ),
       
   414 					'value' => WP_Site_Health::get_instance()->php_memory_limit,
       
   415 				);
       
   416 				$fields['admin_memory_limit'] = array(
       
   417 					'label' => __( 'PHP memory limit (only for admin screens)' ),
       
   418 					'value' => ini_get( 'memory_limit' ),
       
   419 				);
       
   420 			} else {
       
   421 				$fields['memory_limit'] = array(
       
   422 					'label' => __( 'PHP memory limit' ),
       
   423 					'value' => ini_get( 'memory_limit' ),
       
   424 				);
       
   425 			}
       
   426 
       
   427 			$fields['max_input_time']      = array(
       
   428 				'label' => __( 'Max input time' ),
       
   429 				'value' => ini_get( 'max_input_time' ),
       
   430 			);
       
   431 			$fields['upload_max_filesize'] = array(
       
   432 				'label' => __( 'Upload max filesize' ),
       
   433 				'value' => ini_get( 'upload_max_filesize' ),
       
   434 			);
       
   435 			$fields['php_post_max_size']   = array(
       
   436 				'label' => __( 'PHP post max size' ),
       
   437 				'value' => ini_get( 'post_max_size' ),
       
   438 			);
       
   439 		}
       
   440 
       
   441 		if ( function_exists( 'curl_version' ) ) {
       
   442 			$curl = curl_version();
       
   443 
       
   444 			$fields['curl_version'] = array(
       
   445 				'label' => __( 'cURL version' ),
       
   446 				'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
       
   447 			);
       
   448 		} else {
       
   449 			$fields['curl_version'] = array(
       
   450 				'label' => __( 'cURL version' ),
       
   451 				'value' => __( 'Not available' ),
       
   452 				'debug' => 'not available',
       
   453 			);
       
   454 		}
       
   455 
       
   456 		// SUHOSIN.
       
   457 		$suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
       
   458 
       
   459 		$fields['suhosin'] = array(
       
   460 			'label' => __( 'Is SUHOSIN installed?' ),
       
   461 			'value' => ( $suhosin_loaded ? __( 'Yes' ) : __( 'No' ) ),
       
   462 			'debug' => $suhosin_loaded,
       
   463 		);
       
   464 
       
   465 		// Imagick.
       
   466 		$imagick_loaded = extension_loaded( 'imagick' );
       
   467 
       
   468 		$fields['imagick_availability'] = array(
       
   469 			'label' => __( 'Is the Imagick library available?' ),
       
   470 			'value' => ( $imagick_loaded ? __( 'Yes' ) : __( 'No' ) ),
       
   471 			'debug' => $imagick_loaded,
       
   472 		);
       
   473 
       
   474 		// Pretty permalinks.
       
   475 		$pretty_permalinks_supported = got_url_rewrite();
       
   476 
       
   477 		$fields['pretty_permalinks'] = array(
       
   478 			'label' => __( 'Are pretty permalinks supported?' ),
       
   479 			'value' => ( $pretty_permalinks_supported ? __( 'Yes' ) : __( 'No' ) ),
       
   480 			'debug' => $pretty_permalinks_supported,
       
   481 		);
       
   482 
       
   483 		// Check if a .htaccess file exists.
       
   484 		if ( is_file( ABSPATH . '.htaccess' ) ) {
       
   485 			// If the file exists, grab the content of it.
       
   486 			$htaccess_content = file_get_contents( ABSPATH . '.htaccess' );
       
   487 
       
   488 			// Filter away the core WordPress rules.
       
   489 			$filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
       
   490 			$filtered_htaccess_content = ! empty( $filtered_htaccess_content );
       
   491 
       
   492 			if ( $filtered_htaccess_content ) {
       
   493 				/* translators: %s: .htaccess */
       
   494 				$htaccess_rules_string = sprintf( __( 'Custom rules have been added to your %s file.' ), '.htaccess' );
       
   495 			} else {
       
   496 				/* translators: %s: .htaccess */
       
   497 				$htaccess_rules_string = sprintf( __( 'Your %s file contains only core WordPress features.' ), '.htaccess' );
       
   498 			}
       
   499 
       
   500 			$fields['htaccess_extra_rules'] = array(
       
   501 				'label' => __( '.htaccess rules' ),
       
   502 				'value' => $htaccess_rules_string,
       
   503 				'debug' => $filtered_htaccess_content,
       
   504 			);
       
   505 		}
       
   506 
       
   507 		// Check if a robots.txt file exists.
       
   508 		if ( is_file( ABSPATH . 'robots.txt' ) ) {
       
   509 			// If the file exists, turn debug info to true.
       
   510 			$robotstxt_debug = true;
       
   511 
       
   512 			/* translators: %s: robots.txt */
       
   513 			$robotstxt_string = sprintf( __( 'There is a static %s file in your installation folder. WordPress cannot dynamically serve one.' ), 'robots.txt' );
       
   514 		} elseif ( got_url_rewrite() ) {
       
   515 			// No robots.txt file available and rewrite rules in place, turn debug info to false.
       
   516 			$robotstxt_debug = false;
       
   517 
       
   518 			/* translators: %s: robots.txt */
       
   519 			$robotstxt_string = sprintf( __( 'Your site is using the dynamic %s file which is generated by WordPress.' ), 'robots.txt' );
       
   520 		} else {
       
   521 			// No robots.txt file, but without rewrite rules WP can't serve one.
       
   522 			$robotstxt_debug = true;
       
   523 
       
   524 			/* translators: %s: robots.txt */
       
   525 			$robotstxt_string = sprintf( __( 'WordPress cannot dynamically serve a %s file due to a lack of rewrite rule support' ), 'robots.txt' );
       
   526 
       
   527 		}
       
   528 
       
   529 		$fields['static_robotstxt_file'] = array(
       
   530 			'label' => __( 'robots.txt' ),
       
   531 			'value' => $robotstxt_string,
       
   532 			'debug' => $robotstxt_debug,
       
   533 		);
       
   534 
       
   535 		// Server time.
       
   536 		$date = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
       
   537 
       
   538 		$fields['current']     = array(
       
   539 			'label' => __( 'Current time' ),
       
   540 			'value' => $date->format( DateTime::ATOM ),
       
   541 		);
       
   542 		$fields['utc-time']    = array(
       
   543 			'label' => __( 'Current UTC time' ),
       
   544 			'value' => $date->format( DateTime::RFC850 ),
       
   545 		);
       
   546 		$fields['server-time'] = array(
       
   547 			'label' => __( 'Current Server time' ),
       
   548 			'value' => wp_date( 'c', $_SERVER['REQUEST_TIME'] ),
       
   549 		);
       
   550 
       
   551 		return array(
       
   552 			'label'       => __( 'Server' ),
       
   553 			'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host&#8217;s assistance.' ),
       
   554 			'fields'      => $fields,
       
   555 		);
       
   556 	}
       
   557 
       
   558 	/**
       
   559 	 * Gets the WordPress media section of the debug data.
       
   560 	 *
       
   561 	 * @since 6.7.0
       
   562 	 *
       
   563 	 * @throws ImagickException
       
   564 	 * @return array
       
   565 	 */
       
   566 	private static function get_wp_media(): array {
       
   567 		// Spare few function calls.
       
   568 		$not_available = __( 'Not available' );
       
   569 
       
   570 		// Populate the media fields.
       
   571 		$fields['image_editor'] = array(
       
   572 			'label' => __( 'Active editor' ),
       
   573 			'value' => _wp_image_editor_choose(),
       
   574 		);
       
   575 
       
   576 		// Get ImageMagic information, if available.
       
   577 		if ( class_exists( 'Imagick' ) ) {
       
   578 			// Save the Imagick instance for later use.
       
   579 			$imagick             = new Imagick();
       
   580 			$imagemagick_version = $imagick->getVersion();
       
   581 		} else {
       
   582 			$imagemagick_version = __( 'Not available' );
       
   583 		}
       
   584 
       
   585 		$fields['imagick_module_version'] = array(
       
   586 			'label' => __( 'ImageMagick version number' ),
       
   587 			'value' => ( is_array( $imagemagick_version ) ? $imagemagick_version['versionNumber'] : $imagemagick_version ),
       
   588 		);
       
   589 
       
   590 		$fields['imagemagick_version'] = array(
       
   591 			'label' => __( 'ImageMagick version string' ),
       
   592 			'value' => ( is_array( $imagemagick_version ) ? $imagemagick_version['versionString'] : $imagemagick_version ),
       
   593 		);
       
   594 
       
   595 		$imagick_version = phpversion( 'imagick' );
       
   596 
       
   597 		$fields['imagick_version'] = array(
       
   598 			'label' => __( 'Imagick version' ),
       
   599 			'value' => ( $imagick_version ) ? $imagick_version : __( 'Not available' ),
       
   600 		);
       
   601 
       
   602 		if ( ! function_exists( 'ini_get' ) ) {
       
   603 			$fields['ini_get'] = array(
       
   604 				'label' => __( 'File upload settings' ),
       
   605 				'value' => sprintf(
       
   606 				/* translators: %s: ini_get() */
       
   607 					__( 'Unable to determine some settings, as the %s function has been disabled.' ),
       
   608 					'ini_get()'
       
   609 				),
       
   610 				'debug' => 'ini_get() is disabled',
       
   611 			);
       
   612 		} else {
       
   613 			// Get the PHP ini directive values.
       
   614 			$file_uploads        = ini_get( 'file_uploads' );
       
   615 			$post_max_size       = ini_get( 'post_max_size' );
       
   616 			$upload_max_filesize = ini_get( 'upload_max_filesize' );
       
   617 			$max_file_uploads    = ini_get( 'max_file_uploads' );
       
   618 			$effective           = min( wp_convert_hr_to_bytes( $post_max_size ), wp_convert_hr_to_bytes( $upload_max_filesize ) );
       
   619 
       
   620 			// Add info in Media section.
       
   621 			$fields['file_uploads']        = array(
       
   622 				'label' => __( 'File uploads' ),
       
   623 				'value' => $file_uploads ? __( 'Enabled' ) : __( 'Disabled' ),
       
   624 				'debug' => $file_uploads,
       
   625 			);
       
   626 			$fields['post_max_size']       = array(
       
   627 				'label' => __( 'Max size of post data allowed' ),
       
   628 				'value' => $post_max_size,
       
   629 			);
       
   630 			$fields['upload_max_filesize'] = array(
       
   631 				'label' => __( 'Max size of an uploaded file' ),
       
   632 				'value' => $upload_max_filesize,
       
   633 			);
       
   634 			$fields['max_effective_size']  = array(
       
   635 				'label' => __( 'Max effective file size' ),
       
   636 				'value' => size_format( $effective ),
       
   637 			);
       
   638 			$fields['max_file_uploads']    = array(
       
   639 				'label' => __( 'Max simultaneous file uploads' ),
       
   640 				'value' => $max_file_uploads,
       
   641 			);
       
   642 		}
       
   643 
       
   644 		// If Imagick is used as our editor, provide some more information about its limitations.
       
   645 		if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
       
   646 			$limits = array(
       
   647 				'area'   => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),
       
   648 				'disk'   => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ),
       
   649 				'file'   => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ),
       
   650 				'map'    => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ),
       
   651 				'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ),
       
   652 				'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ),
       
   653 				'time'   => ( defined( 'imagick::RESOURCETYPE_TIME' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_TIME ) : $not_available ),
       
   654 			);
       
   655 
       
   656 			$limits_debug = array(
       
   657 				'imagick::RESOURCETYPE_AREA'   => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ),
       
   658 				'imagick::RESOURCETYPE_DISK'   => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'not available' ),
       
   659 				'imagick::RESOURCETYPE_FILE'   => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'not available' ),
       
   660 				'imagick::RESOURCETYPE_MAP'    => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'not available' ),
       
   661 				'imagick::RESOURCETYPE_MEMORY' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'not available' ),
       
   662 				'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ),
       
   663 				'imagick::RESOURCETYPE_TIME'   => ( defined( 'imagick::RESOURCETYPE_TIME' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_TIME ) : 'not available' ),
       
   664 			);
       
   665 
       
   666 			$fields['imagick_limits'] = array(
       
   667 				'label' => __( 'Imagick Resource Limits' ),
       
   668 				'value' => $limits,
       
   669 				'debug' => $limits_debug,
       
   670 			);
       
   671 
       
   672 			try {
       
   673 				$formats = Imagick::queryFormats( '*' );
       
   674 			} catch ( Exception $e ) {
       
   675 				$formats = array();
       
   676 			}
       
   677 
       
   678 			$fields['imagemagick_file_formats'] = array(
       
   679 				'label' => __( 'ImageMagick supported file formats' ),
       
   680 				'value' => ( empty( $formats ) ) ? __( 'Unable to determine' ) : implode( ', ', $formats ),
       
   681 				'debug' => ( empty( $formats ) ) ? 'Unable to determine' : implode( ', ', $formats ),
       
   682 			);
       
   683 		}
       
   684 
       
   685 		// Get GD information, if available.
       
   686 		if ( function_exists( 'gd_info' ) ) {
       
   687 			$gd = gd_info();
       
   688 		} else {
       
   689 			$gd = false;
       
   690 		}
       
   691 
       
   692 		$fields['gd_version'] = array(
       
   693 			'label' => __( 'GD version' ),
       
   694 			'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
       
   695 			'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
       
   696 		);
       
   697 
       
   698 		$gd_image_formats     = array();
       
   699 		$gd_supported_formats = array(
       
   700 			'GIF Create' => 'GIF',
       
   701 			'JPEG'       => 'JPEG',
       
   702 			'PNG'        => 'PNG',
       
   703 			'WebP'       => 'WebP',
       
   704 			'BMP'        => 'BMP',
       
   705 			'AVIF'       => 'AVIF',
       
   706 			'HEIF'       => 'HEIF',
       
   707 			'TIFF'       => 'TIFF',
       
   708 			'XPM'        => 'XPM',
       
   709 		);
       
   710 
       
   711 		foreach ( $gd_supported_formats as $format_key => $format ) {
       
   712 			$index = $format_key . ' Support';
       
   713 			if ( isset( $gd[ $index ] ) && $gd[ $index ] ) {
       
   714 				array_push( $gd_image_formats, $format );
       
   715 			}
       
   716 		}
       
   717 
       
   718 		if ( ! empty( $gd_image_formats ) ) {
       
   719 			$fields['gd_formats'] = array(
       
   720 				'label' => __( 'GD supported file formats' ),
       
   721 				'value' => implode( ', ', $gd_image_formats ),
       
   722 			);
       
   723 		}
       
   724 
       
   725 		// Get Ghostscript information, if available.
       
   726 		if ( function_exists( 'exec' ) ) {
       
   727 			$gs = exec( 'gs --version' );
       
   728 
       
   729 			if ( empty( $gs ) ) {
       
   730 				$gs       = $not_available;
       
   731 				$gs_debug = 'not available';
       
   732 			} else {
       
   733 				$gs_debug = $gs;
       
   734 			}
       
   735 		} else {
       
   736 			$gs       = __( 'Unable to determine if Ghostscript is installed' );
       
   737 			$gs_debug = 'unknown';
       
   738 		}
       
   739 
       
   740 		$fields['ghostscript_version'] = array(
       
   741 			'label' => __( 'Ghostscript version' ),
       
   742 			'value' => $gs,
       
   743 			'debug' => $gs_debug,
       
   744 		);
       
   745 
       
   746 		return array(
       
   747 			'label'  => __( 'Media Handling' ),
       
   748 			'fields' => $fields,
       
   749 		);
       
   750 	}
       
   751 
       
   752 	/**
       
   753 	 * Gets the WordPress MU plugins section of the debug data.
       
   754 	 *
       
   755 	 * @since 6.7.0
       
   756 	 *
       
   757 	 * @return array
       
   758 	 */
       
   759 	private static function get_wp_mu_plugins(): array {
       
   760 		// List must use plugins if there are any.
       
   761 		$mu_plugins = get_mu_plugins();
       
   762 		$fields     = array();
       
   763 
       
   764 		foreach ( $mu_plugins as $plugin_path => $plugin ) {
       
   765 			$plugin_version = $plugin['Version'];
       
   766 			$plugin_author  = $plugin['Author'];
       
   767 
       
   768 			$plugin_version_string       = __( 'No version or author information is available.' );
       
   769 			$plugin_version_string_debug = 'author: (undefined), version: (undefined)';
       
   770 
       
   771 			if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
       
   772 				/* translators: 1: Plugin version number. 2: Plugin author name. */
       
   773 				$plugin_version_string       = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
       
   774 				$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
       
   775 			} else {
       
   776 				if ( ! empty( $plugin_author ) ) {
       
   777 					/* translators: %s: Plugin author name. */
       
   778 					$plugin_version_string       = sprintf( __( 'By %s' ), $plugin_author );
       
   779 					$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
       
   780 				}
       
   781 
       
   782 				if ( ! empty( $plugin_version ) ) {
       
   783 					/* translators: %s: Plugin version number. */
       
   784 					$plugin_version_string       = sprintf( __( 'Version %s' ), $plugin_version );
       
   785 					$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
       
   786 				}
       
   787 			}
       
   788 
       
   789 			$fields[ sanitize_text_field( $plugin['Name'] ) ] = array(
       
   790 				'label' => $plugin['Name'],
       
   791 				'value' => $plugin_version_string,
       
   792 				'debug' => $plugin_version_string_debug,
       
   793 			);
       
   794 		}
       
   795 
       
   796 		return array(
       
   797 			'label'      => __( 'Must Use Plugins' ),
       
   798 			'show_count' => true,
       
   799 			'fields'     => $fields,
       
   800 		);
       
   801 	}
       
   802 
       
   803 	/**
       
   804 	 * Gets the WordPress paths and sizes section of the debug data.
       
   805 	 *
       
   806 	 * @since 6.7.0
       
   807 	 *
       
   808 	 * @return array|null Paths and sizes debug data for single sites,
       
   809 	 *                    otherwise `null` for multi-site installs.
       
   810 	 */
       
   811 	private static function get_wp_paths_sizes(): ?array {
       
   812 		if ( is_multisite() ) {
       
   813 			return null;
       
   814 		}
       
   815 
       
   816 		$loading = __( 'Loading&hellip;' );
       
   817 
       
   818 		$fields = array(
       
   819 			'wordpress_path' => array(
       
   820 				'label' => __( 'WordPress directory location' ),
       
   821 				'value' => untrailingslashit( ABSPATH ),
       
   822 			),
       
   823 			'wordpress_size' => array(
       
   824 				'label' => __( 'WordPress directory size' ),
       
   825 				'value' => $loading,
       
   826 				'debug' => 'loading...',
       
   827 			),
       
   828 			'uploads_path'   => array(
       
   829 				'label' => __( 'Uploads directory location' ),
       
   830 				'value' => wp_upload_dir()['basedir'],
       
   831 			),
       
   832 			'uploads_size'   => array(
       
   833 				'label' => __( 'Uploads directory size' ),
       
   834 				'value' => $loading,
       
   835 				'debug' => 'loading...',
       
   836 			),
       
   837 			'themes_path'    => array(
       
   838 				'label' => __( 'Themes directory location' ),
       
   839 				'value' => get_theme_root(),
       
   840 			),
       
   841 			'themes_size'    => array(
       
   842 				'label' => __( 'Themes directory size' ),
       
   843 				'value' => $loading,
       
   844 				'debug' => 'loading...',
       
   845 			),
       
   846 			'plugins_path'   => array(
       
   847 				'label' => __( 'Plugins directory location' ),
       
   848 				'value' => WP_PLUGIN_DIR,
       
   849 			),
       
   850 			'plugins_size'   => array(
       
   851 				'label' => __( 'Plugins directory size' ),
       
   852 				'value' => $loading,
       
   853 				'debug' => 'loading...',
       
   854 			),
       
   855 			'fonts_path'     => array(
       
   856 				'label' => __( 'Fonts directory location' ),
       
   857 				'value' => wp_get_font_dir()['basedir'],
       
   858 			),
       
   859 			'fonts_size'     => array(
       
   860 				'label' => __( 'Fonts directory size' ),
       
   861 				'value' => $loading,
       
   862 				'debug' => 'loading...',
       
   863 			),
       
   864 			'database_size'  => array(
       
   865 				'label' => __( 'Database size' ),
       
   866 				'value' => $loading,
       
   867 				'debug' => 'loading...',
       
   868 			),
       
   869 			'total_size'     => array(
       
   870 				'label' => __( 'Total installation size' ),
       
   871 				'value' => $loading,
       
   872 				'debug' => 'loading...',
       
   873 			),
       
   874 		);
       
   875 
       
   876 		return array(
       
   877 			/* translators: Filesystem directory paths and storage sizes. */
       
   878 			'label'  => __( 'Directories and Sizes' ),
       
   879 			'fields' => $fields,
       
   880 		);
       
   881 	}
       
   882 
       
   883 	/**
       
   884 	 * Gets the WordPress active plugins section of the debug data.
       
   885 	 *
       
   886 	 * @since 6.7.0
       
   887 	 *
       
   888 	 * @return array
       
   889 	 */
       
   890 	private static function get_wp_plugins_active(): array {
       
   891 		return array(
       
   892 			'label'      => __( 'Active Plugins' ),
       
   893 			'show_count' => true,
       
   894 			'fields'     => self::get_wp_plugins_raw_data()['wp-plugins-active'],
       
   895 		);
       
   896 	}
       
   897 
       
   898 	/**
       
   899 	 * Gets the WordPress inactive plugins section of the debug data.
       
   900 	 *
       
   901 	 * @since 6.7.0
       
   902 	 *
       
   903 	 * @return array
       
   904 	 */
       
   905 	private static function get_wp_plugins_inactive(): array {
       
   906 		return array(
       
   907 			'label'      => __( 'Inactive Plugins' ),
       
   908 			'show_count' => true,
       
   909 			'fields'     => self::get_wp_plugins_raw_data()['wp-plugins-inactive'],
       
   910 		);
       
   911 	}
       
   912 
       
   913 	/**
       
   914 	 * Gets the raw plugin data for the WordPress active and inactive sections of the debug data.
       
   915 	 *
       
   916 	 * @since 6.7.0
       
   917 	 *
       
   918 	 * @return array
       
   919 	 */
       
   920 	private static function get_wp_plugins_raw_data(): array {
       
   921 		// List all available plugins.
       
   922 		$plugins        = get_plugins();
       
   923 		$plugin_updates = get_plugin_updates();
       
   924 		$transient      = get_site_transient( 'update_plugins' );
       
   925 
       
   926 		$auto_updates = array();
       
   927 		$fields       = array(
       
   928 			'wp-plugins-active'   => array(),
       
   929 			'wp-plugins-inactive' => array(),
       
   930 		);
       
   931 
       
   932 		$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' );
       
   933 
       
   934 		if ( $auto_updates_enabled ) {
       
   935 			$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
       
   936 		}
       
   937 
       
   938 		foreach ( $plugins as $plugin_path => $plugin ) {
       
   939 			$plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive';
       
   940 
       
   941 			$plugin_version = $plugin['Version'];
       
   942 			$plugin_author  = $plugin['Author'];
       
   943 
       
   944 			$plugin_version_string       = __( 'No version or author information is available.' );
       
   945 			$plugin_version_string_debug = 'author: (undefined), version: (undefined)';
       
   946 
       
   947 			if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
       
   948 				/* translators: 1: Plugin version number. 2: Plugin author name. */
       
   949 				$plugin_version_string       = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
       
   950 				$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
       
   951 			} else {
       
   952 				if ( ! empty( $plugin_author ) ) {
       
   953 					/* translators: %s: Plugin author name. */
       
   954 					$plugin_version_string       = sprintf( __( 'By %s' ), $plugin_author );
       
   955 					$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
       
   956 				}
       
   957 
       
   958 				if ( ! empty( $plugin_version ) ) {
       
   959 					/* translators: %s: Plugin version number. */
       
   960 					$plugin_version_string       = sprintf( __( 'Version %s' ), $plugin_version );
       
   961 					$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
       
   962 				}
       
   963 			}
       
   964 
       
   965 			if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
       
   966 				/* translators: %s: Latest plugin version number. */
       
   967 				$plugin_version_string       .= ' ' . sprintf( __( '(Latest version: %s)' ), $plugin_updates[ $plugin_path ]->update->new_version );
       
   968 				$plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
       
   969 			}
       
   970 
       
   971 			if ( $auto_updates_enabled ) {
       
   972 				if ( isset( $transient->response[ $plugin_path ] ) ) {
       
   973 					$item = $transient->response[ $plugin_path ];
       
   974 				} elseif ( isset( $transient->no_update[ $plugin_path ] ) ) {
       
   975 					$item = $transient->no_update[ $plugin_path ];
       
   976 				} else {
       
   977 					$item = array(
       
   978 						'id'            => $plugin_path,
       
   979 						'slug'          => '',
       
   980 						'plugin'        => $plugin_path,
       
   981 						'new_version'   => '',
       
   982 						'url'           => '',
       
   983 						'package'       => '',
       
   984 						'icons'         => array(),
       
   985 						'banners'       => array(),
       
   986 						'banners_rtl'   => array(),
       
   987 						'tested'        => '',
       
   988 						'requires_php'  => '',
       
   989 						'compatibility' => new stdClass(),
       
   990 					);
       
   991 					$item = wp_parse_args( $plugin, $item );
       
   992 				}
       
   993 
       
   994 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, (object) $item );
       
   995 
       
   996 				if ( ! is_null( $auto_update_forced ) ) {
       
   997 					$enabled = $auto_update_forced;
       
   998 				} else {
       
   999 					$enabled = in_array( $plugin_path, $auto_updates, true );
       
  1000 				}
       
  1001 
       
  1002 				if ( $enabled ) {
       
  1003 					$auto_updates_string = __( 'Auto-updates enabled' );
       
  1004 				} else {
       
  1005 					$auto_updates_string = __( 'Auto-updates disabled' );
       
  1006 				}
       
  1007 
       
  1008 				/**
       
  1009 				 * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.
       
  1010 				 *
       
  1011 				 * @since 5.5.0
       
  1012 				 *
       
  1013 				 * @param string $auto_updates_string The string output for the auto-updates column.
       
  1014 				 * @param string $plugin_path         The path to the plugin file.
       
  1015 				 * @param array  $plugin              An array of plugin data.
       
  1016 				 * @param bool   $enabled             Whether auto-updates are enabled for this item.
       
  1017 				 */
       
  1018 				$auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled );
       
  1019 
       
  1020 				$plugin_version_string       .= ' | ' . $auto_updates_string;
       
  1021 				$plugin_version_string_debug .= ', ' . $auto_updates_string;
       
  1022 			}
       
  1023 
       
  1024 			$fields[ $plugin_part ][ sanitize_text_field( $plugin['Name'] ) ] = array(
       
  1025 				'label' => $plugin['Name'],
       
  1026 				'value' => $plugin_version_string,
       
  1027 				'debug' => $plugin_version_string_debug,
       
  1028 			);
       
  1029 		}
       
  1030 
       
  1031 		return $fields;
       
  1032 	}
       
  1033 
       
  1034 	/**
       
  1035 	 * Gets the WordPress active theme section of the debug data.
       
  1036 	 *
       
  1037 	 * @since 6.7.0
       
  1038 	 *
       
  1039 	 * @global array $_wp_theme_features
       
  1040 	 *
       
  1041 	 * @return array
       
  1042 	 */
       
  1043 	private static function get_wp_active_theme(): array {
       
  1044 		global $_wp_theme_features;
       
  1045 
       
  1046 		// Populate the section for the currently active theme.
       
  1047 		$theme_features = array();
       
  1048 
       
  1049 		if ( ! empty( $_wp_theme_features ) ) {
       
  1050 			foreach ( $_wp_theme_features as $feature => $options ) {
       
  1051 				$theme_features[] = $feature;
       
  1052 			}
       
  1053 		}
       
  1054 
       
  1055 		$active_theme  = wp_get_theme();
       
  1056 		$theme_updates = get_theme_updates();
       
  1057 		$transient     = get_site_transient( 'update_themes' );
       
  1058 
       
  1059 		$active_theme_version       = $active_theme->version;
       
  1060 		$active_theme_version_debug = $active_theme_version;
       
  1061 
       
  1062 		$auto_updates         = array();
       
  1063 		$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' );
       
  1064 		if ( $auto_updates_enabled ) {
       
  1065 			$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
       
  1066 		}
       
  1067 
       
  1068 		if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
       
  1069 			$theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];
       
  1070 
       
  1071 			/* translators: %s: Latest theme version number. */
       
  1072 			$active_theme_version       .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_update_new_version );
       
  1073 			$active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version );
       
  1074 		}
       
  1075 
       
  1076 		$active_theme_author_uri = $active_theme->display( 'AuthorURI' );
       
  1077 
       
  1078 		if ( $active_theme->parent_theme ) {
       
  1079 			$active_theme_parent_theme = sprintf(
       
  1080 				/* translators: 1: Theme name. 2: Theme slug. */
       
  1081 				__( '%1$s (%2$s)' ),
       
  1082 				$active_theme->parent_theme,
       
  1083 				$active_theme->template
       
  1084 			);
       
  1085 			$active_theme_parent_theme_debug = sprintf(
       
  1086 				'%s (%s)',
       
  1087 				$active_theme->parent_theme,
       
  1088 				$active_theme->template
       
  1089 			);
       
  1090 		} else {
       
  1091 			$active_theme_parent_theme       = __( 'None' );
       
  1092 			$active_theme_parent_theme_debug = 'none';
       
  1093 		}
       
  1094 
       
  1095 		$fields = array(
       
  1096 			'name'           => array(
       
  1097 				'label' => __( 'Name' ),
       
  1098 				'value' => sprintf(
       
  1099 					/* translators: 1: Theme name. 2: Theme slug. */
       
  1100 					__( '%1$s (%2$s)' ),
       
  1101 					$active_theme->name,
       
  1102 					$active_theme->stylesheet
       
  1103 				),
       
  1104 			),
       
  1105 			'version'        => array(
       
  1106 				'label' => __( 'Version' ),
       
  1107 				'value' => $active_theme_version,
       
  1108 				'debug' => $active_theme_version_debug,
       
  1109 			),
       
  1110 			'author'         => array(
       
  1111 				'label' => __( 'Author' ),
       
  1112 				'value' => wp_kses( $active_theme->author, array() ),
       
  1113 			),
       
  1114 			'author_website' => array(
       
  1115 				'label' => __( 'Author website' ),
       
  1116 				'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined' ) ),
       
  1117 				'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ),
       
  1118 			),
       
  1119 			'parent_theme'   => array(
       
  1120 				'label' => __( 'Parent theme' ),
       
  1121 				'value' => $active_theme_parent_theme,
       
  1122 				'debug' => $active_theme_parent_theme_debug,
       
  1123 			),
       
  1124 			'theme_features' => array(
       
  1125 				'label' => __( 'Theme features' ),
       
  1126 				'value' => implode( ', ', $theme_features ),
       
  1127 			),
       
  1128 			'theme_path'     => array(
       
  1129 				'label' => __( 'Theme directory location' ),
       
  1130 				'value' => get_stylesheet_directory(),
       
  1131 			),
       
  1132 		);
       
  1133 
       
  1134 		if ( $auto_updates_enabled ) {
       
  1135 			if ( isset( $transient->response[ $active_theme->stylesheet ] ) ) {
       
  1136 				$item = $transient->response[ $active_theme->stylesheet ];
       
  1137 			} elseif ( isset( $transient->no_update[ $active_theme->stylesheet ] ) ) {
       
  1138 				$item = $transient->no_update[ $active_theme->stylesheet ];
       
  1139 			} else {
       
  1140 				$item = array(
       
  1141 					'theme'        => $active_theme->stylesheet,
       
  1142 					'new_version'  => $active_theme->version,
       
  1143 					'url'          => '',
       
  1144 					'package'      => '',
       
  1145 					'requires'     => '',
       
  1146 					'requires_php' => '',
       
  1147 				);
       
  1148 			}
       
  1149 
       
  1150 			$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
       
  1151 
       
  1152 			if ( ! is_null( $auto_update_forced ) ) {
       
  1153 				$enabled = $auto_update_forced;
       
  1154 			} else {
       
  1155 				$enabled = in_array( $active_theme->stylesheet, $auto_updates, true );
       
  1156 			}
       
  1157 
       
  1158 			if ( $enabled ) {
       
  1159 				$auto_updates_string = __( 'Enabled' );
       
  1160 			} else {
       
  1161 				$auto_updates_string = __( 'Disabled' );
       
  1162 			}
       
  1163 
       
  1164 			/** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
       
  1165 			$auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled );
       
  1166 
       
  1167 			$fields['auto_update'] = array(
       
  1168 				'label' => __( 'Auto-updates' ),
       
  1169 				'value' => $auto_updates_string,
       
  1170 				'debug' => $auto_updates_string,
       
  1171 			);
       
  1172 		}
       
  1173 
       
  1174 		return array(
       
  1175 			'label'  => __( 'Active Theme' ),
       
  1176 			'fields' => $fields,
       
  1177 		);
       
  1178 	}
       
  1179 
       
  1180 	/**
       
  1181 	 * Gets the WordPress parent theme section of the debug data.
       
  1182 	 *
       
  1183 	 * @since 6.7.0
       
  1184 	 *
       
  1185 	 * @return array
       
  1186 	 */
       
  1187 	private static function get_wp_parent_theme(): array {
       
  1188 		$theme_updates = get_theme_updates();
       
  1189 		$transient     = get_site_transient( 'update_themes' );
       
  1190 
       
  1191 		$auto_updates         = array();
       
  1192 		$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' );
       
  1193 		if ( $auto_updates_enabled ) {
       
  1194 			$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
       
  1195 		}
       
  1196 
       
  1197 		$active_theme = wp_get_theme();
       
  1198 		$parent_theme = $active_theme->parent();
       
  1199 		$fields       = array();
       
  1200 
       
  1201 		if ( $parent_theme ) {
       
  1202 			$parent_theme_version       = $parent_theme->version;
       
  1203 			$parent_theme_version_debug = $parent_theme_version;
       
  1204 
       
  1205 			if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {
       
  1206 				$parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];
       
  1207 
       
  1208 				/* translators: %s: Latest theme version number. */
       
  1209 				$parent_theme_version       .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version );
       
  1210 				$parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );
       
  1211 			}
       
  1212 
       
  1213 			$parent_theme_author_uri = $parent_theme->display( 'AuthorURI' );
       
  1214 
       
  1215 			$fields = array(
       
  1216 				'name'           => array(
       
  1217 					'label' => __( 'Name' ),
       
  1218 					'value' => sprintf(
       
  1219 						/* translators: 1: Theme name. 2: Theme slug. */
       
  1220 						__( '%1$s (%2$s)' ),
       
  1221 						$parent_theme->name,
       
  1222 						$parent_theme->stylesheet
       
  1223 					),
       
  1224 				),
       
  1225 				'version'        => array(
       
  1226 					'label' => __( 'Version' ),
       
  1227 					'value' => $parent_theme_version,
       
  1228 					'debug' => $parent_theme_version_debug,
       
  1229 				),
       
  1230 				'author'         => array(
       
  1231 					'label' => __( 'Author' ),
       
  1232 					'value' => wp_kses( $parent_theme->author, array() ),
       
  1233 				),
       
  1234 				'author_website' => array(
       
  1235 					'label' => __( 'Author website' ),
       
  1236 					'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ),
       
  1237 					'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
       
  1238 				),
       
  1239 				'theme_path'     => array(
       
  1240 					'label' => __( 'Theme directory location' ),
       
  1241 					'value' => get_template_directory(),
       
  1242 				),
       
  1243 			);
       
  1244 
       
  1245 			if ( $auto_updates_enabled ) {
       
  1246 				if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) {
       
  1247 					$item = $transient->response[ $parent_theme->stylesheet ];
       
  1248 				} elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) {
       
  1249 					$item = $transient->no_update[ $parent_theme->stylesheet ];
       
  1250 				} else {
       
  1251 					$item = array(
       
  1252 						'theme'        => $parent_theme->stylesheet,
       
  1253 						'new_version'  => $parent_theme->version,
       
  1254 						'url'          => '',
       
  1255 						'package'      => '',
       
  1256 						'requires'     => '',
       
  1257 						'requires_php' => '',
       
  1258 					);
       
  1259 				}
       
  1260 
       
  1261 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
       
  1262 
       
  1263 				if ( ! is_null( $auto_update_forced ) ) {
       
  1264 					$enabled = $auto_update_forced;
       
  1265 				} else {
       
  1266 					$enabled = in_array( $parent_theme->stylesheet, $auto_updates, true );
       
  1267 				}
       
  1268 
       
  1269 				if ( $enabled ) {
       
  1270 					$parent_theme_auto_update_string = __( 'Enabled' );
       
  1271 				} else {
       
  1272 					$parent_theme_auto_update_string = __( 'Disabled' );
       
  1273 				}
       
  1274 
       
  1275 				/** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
       
  1276 				$parent_theme_auto_update_string = apply_filters( 'theme_auto_update_debug_string', $parent_theme_auto_update_string, $parent_theme, $enabled );
       
  1277 
       
  1278 				$fields['auto_update'] = array(
       
  1279 					'label' => __( 'Auto-update' ),
       
  1280 					'value' => $parent_theme_auto_update_string,
       
  1281 					'debug' => $parent_theme_auto_update_string,
       
  1282 				);
       
  1283 			}
       
  1284 		}
       
  1285 
       
  1286 		return array(
       
  1287 			'label'  => __( 'Parent Theme' ),
       
  1288 			'fields' => $fields,
       
  1289 		);
       
  1290 	}
       
  1291 
       
  1292 	/**
       
  1293 	 * Gets the WordPress inactive themes section of the debug data.
       
  1294 	 *
       
  1295 	 * @since 6.7.0
       
  1296 	 *
       
  1297 	 * @return array
       
  1298 	 */
       
  1299 	private static function get_wp_themes_inactive(): array {
       
  1300 		$active_theme  = wp_get_theme();
       
  1301 		$parent_theme  = $active_theme->parent();
       
  1302 		$theme_updates = get_theme_updates();
       
  1303 
       
  1304 		$auto_updates         = array();
       
  1305 		$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' );
       
  1306 		if ( $auto_updates_enabled ) {
       
  1307 			$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
       
  1308 		}
       
  1309 
       
  1310 		// Populate a list of all themes available in the installation.
       
  1311 		$all_themes = wp_get_themes();
       
  1312 		$fields     = array();
       
  1313 
       
  1314 		foreach ( $all_themes as $theme_slug => $theme ) {
       
  1315 			// Exclude the currently active theme from the list of all themes.
       
  1316 			if ( $active_theme->stylesheet === $theme_slug ) {
       
  1317 				continue;
       
  1318 			}
       
  1319 
       
  1320 			// Exclude the currently active parent theme from the list of all themes.
       
  1321 			if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) {
       
  1322 				continue;
       
  1323 			}
       
  1324 
       
  1325 			$theme_version = $theme->version;
       
  1326 			$theme_author  = $theme->author;
       
  1327 
       
  1328 			// Sanitize.
       
  1329 			$theme_author = wp_kses( $theme_author, array() );
       
  1330 
       
  1331 			$theme_version_string       = __( 'No version or author information is available.' );
       
  1332 			$theme_version_string_debug = 'undefined';
       
  1333 
       
  1334 			if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {
       
  1335 				/* translators: 1: Theme version number. 2: Theme author name. */
       
  1336 				$theme_version_string       = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author );
       
  1337 				$theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author );
       
  1338 			} else {
       
  1339 				if ( ! empty( $theme_author ) ) {
       
  1340 					/* translators: %s: Theme author name. */
       
  1341 					$theme_version_string       = sprintf( __( 'By %s' ), $theme_author );
       
  1342 					$theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author );
       
  1343 				}
       
  1344 
       
  1345 				if ( ! empty( $theme_version ) ) {
       
  1346 					/* translators: %s: Theme version number. */
       
  1347 					$theme_version_string       = sprintf( __( 'Version %s' ), $theme_version );
       
  1348 					$theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version );
       
  1349 				}
       
  1350 			}
       
  1351 
       
  1352 			if ( array_key_exists( $theme_slug, $theme_updates ) ) {
       
  1353 				/* translators: %s: Latest theme version number. */
       
  1354 				$theme_version_string       .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] );
       
  1355 				$theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );
       
  1356 			}
       
  1357 
       
  1358 			if ( $auto_updates_enabled ) {
       
  1359 				if ( isset( $transient->response[ $theme_slug ] ) ) {
       
  1360 					$item = $transient->response[ $theme_slug ];
       
  1361 				} elseif ( isset( $transient->no_update[ $theme_slug ] ) ) {
       
  1362 					$item = $transient->no_update[ $theme_slug ];
       
  1363 				} else {
       
  1364 					$item = array(
       
  1365 						'theme'        => $theme_slug,
       
  1366 						'new_version'  => $theme->version,
       
  1367 						'url'          => '',
       
  1368 						'package'      => '',
       
  1369 						'requires'     => '',
       
  1370 						'requires_php' => '',
       
  1371 					);
       
  1372 				}
       
  1373 
       
  1374 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
       
  1375 
       
  1376 				if ( ! is_null( $auto_update_forced ) ) {
       
  1377 					$enabled = $auto_update_forced;
       
  1378 				} else {
       
  1379 					$enabled = in_array( $theme_slug, $auto_updates, true );
       
  1380 				}
       
  1381 
       
  1382 				if ( $enabled ) {
       
  1383 					$auto_updates_string = __( 'Auto-updates enabled' );
       
  1384 				} else {
       
  1385 					$auto_updates_string = __( 'Auto-updates disabled' );
       
  1386 				}
       
  1387 
       
  1388 				/**
       
  1389 				 * Filters the text string of the auto-updates setting for each theme in the Site Health debug data.
       
  1390 				 *
       
  1391 				 * @since 5.5.0
       
  1392 				 *
       
  1393 				 * @param string   $auto_updates_string The string output for the auto-updates column.
       
  1394 				 * @param WP_Theme $theme               An object of theme data.
       
  1395 				 * @param bool     $enabled             Whether auto-updates are enabled for this item.
       
  1396 				 */
       
  1397 				$auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
       
  1398 
       
  1399 				$theme_version_string       .= ' | ' . $auto_updates_string;
       
  1400 				$theme_version_string_debug .= ', ' . $auto_updates_string;
       
  1401 			}
       
  1402 
       
  1403 			$fields[ sanitize_text_field( $theme->name ) ] = array(
       
  1404 				'label' => sprintf(
       
  1405 					/* translators: 1: Theme name. 2: Theme slug. */
       
  1406 					__( '%1$s (%2$s)' ),
       
  1407 					$theme->name,
       
  1408 					$theme_slug
       
  1409 				),
       
  1410 				'value' => $theme_version_string,
       
  1411 				'debug' => $theme_version_string_debug,
       
  1412 			);
       
  1413 		}
       
  1414 
       
  1415 		return array(
       
  1416 			'label'      => __( 'Inactive Themes' ),
       
  1417 			'show_count' => true,
       
  1418 			'fields'     => $fields,
       
  1419 		);
       
  1420 	}
       
  1421 
       
  1422 	/**
       
  1423 	 * Gets the WordPress constants section of the debug data.
       
  1424 	 *
       
  1425 	 * @since 6.7.0
       
  1426 	 *
       
  1427 	 * @return array
       
  1428 	 */
       
  1429 	private static function get_wp_constants(): array {
       
  1430 		// Check if WP_DEBUG_LOG is set.
       
  1431 		$wp_debug_log_value = __( 'Disabled' );
       
  1432 		if ( is_string( WP_DEBUG_LOG ) ) {
       
  1433 			$wp_debug_log_value = WP_DEBUG_LOG;
       
  1434 		} elseif ( WP_DEBUG_LOG ) {
       
  1435 			$wp_debug_log_value = __( 'Enabled' );
       
  1436 		}
       
  1437 
       
  1438 		// Check CONCATENATE_SCRIPTS.
       
  1439 		if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
       
  1440 			$concatenate_scripts       = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
       
  1441 			$concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
       
  1442 		} else {
       
  1443 			$concatenate_scripts       = __( 'Undefined' );
       
  1444 			$concatenate_scripts_debug = 'undefined';
       
  1445 		}
       
  1446 
       
  1447 		// Check COMPRESS_SCRIPTS.
       
  1448 		if ( defined( 'COMPRESS_SCRIPTS' ) ) {
       
  1449 			$compress_scripts       = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
       
  1450 			$compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
       
  1451 		} else {
       
  1452 			$compress_scripts       = __( 'Undefined' );
       
  1453 			$compress_scripts_debug = 'undefined';
       
  1454 		}
       
  1455 
       
  1456 		// Check COMPRESS_CSS.
       
  1457 		if ( defined( 'COMPRESS_CSS' ) ) {
       
  1458 			$compress_css       = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' );
       
  1459 			$compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
       
  1460 		} else {
       
  1461 			$compress_css       = __( 'Undefined' );
       
  1462 			$compress_css_debug = 'undefined';
       
  1463 		}
       
  1464 
       
  1465 		// Check WP_ENVIRONMENT_TYPE.
       
  1466 		if ( defined( 'WP_ENVIRONMENT_TYPE' ) ) {
       
  1467 			$wp_environment_type       = WP_ENVIRONMENT_TYPE ? WP_ENVIRONMENT_TYPE : __( 'Empty value' );
       
  1468 			$wp_environment_type_debug = WP_ENVIRONMENT_TYPE;
       
  1469 		} else {
       
  1470 			$wp_environment_type       = __( 'Undefined' );
       
  1471 			$wp_environment_type_debug = 'undefined';
       
  1472 		}
       
  1473 
       
  1474 		// Check DB_COLLATE.
       
  1475 		if ( defined( 'DB_COLLATE' ) ) {
       
  1476 			$db_collate       = DB_COLLATE ? DB_COLLATE : __( 'Empty value' );
       
  1477 			$db_collate_debug = DB_COLLATE;
       
  1478 		} else {
       
  1479 			$db_collate       = __( 'Undefined' );
       
  1480 			$db_collate_debug = 'undefined';
       
  1481 		}
       
  1482 
       
  1483 		$fields = array(
       
  1484 			'ABSPATH'             => array(
       
  1485 				'label'   => 'ABSPATH',
       
  1486 				'value'   => ABSPATH,
       
  1487 				'private' => true,
       
  1488 			),
       
  1489 			'WP_HOME'             => array(
       
  1490 				'label' => 'WP_HOME',
       
  1491 				'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
       
  1492 				'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
       
  1493 			),
       
  1494 			'WP_SITEURL'          => array(
       
  1495 				'label' => 'WP_SITEURL',
       
  1496 				'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
       
  1497 				'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
       
  1498 			),
       
  1499 			'WP_CONTENT_DIR'      => array(
       
  1500 				'label' => 'WP_CONTENT_DIR',
       
  1501 				'value' => WP_CONTENT_DIR,
       
  1502 			),
       
  1503 			'WP_PLUGIN_DIR'       => array(
       
  1504 				'label' => 'WP_PLUGIN_DIR',
       
  1505 				'value' => WP_PLUGIN_DIR,
       
  1506 			),
       
  1507 			'WP_MEMORY_LIMIT'     => array(
       
  1508 				'label' => 'WP_MEMORY_LIMIT',
       
  1509 				'value' => WP_MEMORY_LIMIT,
       
  1510 			),
       
  1511 			'WP_MAX_MEMORY_LIMIT' => array(
       
  1512 				'label' => 'WP_MAX_MEMORY_LIMIT',
       
  1513 				'value' => WP_MAX_MEMORY_LIMIT,
       
  1514 			),
       
  1515 			'WP_DEBUG'            => array(
       
  1516 				'label' => 'WP_DEBUG',
       
  1517 				'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
       
  1518 				'debug' => WP_DEBUG,
       
  1519 			),
       
  1520 			'WP_DEBUG_DISPLAY'    => array(
       
  1521 				'label' => 'WP_DEBUG_DISPLAY',
       
  1522 				'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ),
       
  1523 				'debug' => WP_DEBUG_DISPLAY,
       
  1524 			),
       
  1525 			'WP_DEBUG_LOG'        => array(
       
  1526 				'label' => 'WP_DEBUG_LOG',
       
  1527 				'value' => $wp_debug_log_value,
       
  1528 				'debug' => WP_DEBUG_LOG,
       
  1529 			),
       
  1530 			'SCRIPT_DEBUG'        => array(
       
  1531 				'label' => 'SCRIPT_DEBUG',
       
  1532 				'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
       
  1533 				'debug' => SCRIPT_DEBUG,
       
  1534 			),
       
  1535 			'WP_CACHE'            => array(
       
  1536 				'label' => 'WP_CACHE',
       
  1537 				'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ),
       
  1538 				'debug' => WP_CACHE,
       
  1539 			),
       
  1540 			'CONCATENATE_SCRIPTS' => array(
       
  1541 				'label' => 'CONCATENATE_SCRIPTS',
       
  1542 				'value' => $concatenate_scripts,
       
  1543 				'debug' => $concatenate_scripts_debug,
       
  1544 			),
       
  1545 			'COMPRESS_SCRIPTS'    => array(
       
  1546 				'label' => 'COMPRESS_SCRIPTS',
       
  1547 				'value' => $compress_scripts,
       
  1548 				'debug' => $compress_scripts_debug,
       
  1549 			),
       
  1550 			'COMPRESS_CSS'        => array(
       
  1551 				'label' => 'COMPRESS_CSS',
       
  1552 				'value' => $compress_css,
       
  1553 				'debug' => $compress_css_debug,
       
  1554 			),
       
  1555 			'WP_ENVIRONMENT_TYPE' => array(
       
  1556 				'label' => 'WP_ENVIRONMENT_TYPE',
       
  1557 				'value' => $wp_environment_type,
       
  1558 				'debug' => $wp_environment_type_debug,
       
  1559 			),
       
  1560 			'WP_DEVELOPMENT_MODE' => array(
       
  1561 				'label' => 'WP_DEVELOPMENT_MODE',
       
  1562 				'value' => WP_DEVELOPMENT_MODE ? WP_DEVELOPMENT_MODE : __( 'Disabled' ),
       
  1563 				'debug' => WP_DEVELOPMENT_MODE,
       
  1564 			),
       
  1565 			'DB_CHARSET'          => array(
       
  1566 				'label' => 'DB_CHARSET',
       
  1567 				'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
       
  1568 				'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
       
  1569 			),
       
  1570 			'DB_COLLATE'          => array(
       
  1571 				'label' => 'DB_COLLATE',
       
  1572 				'value' => $db_collate,
       
  1573 				'debug' => $db_collate_debug,
       
  1574 			),
       
  1575 		);
       
  1576 
       
  1577 		return array(
       
  1578 			'label'       => __( 'WordPress Constants' ),
       
  1579 			'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
       
  1580 			'fields'      => $fields,
       
  1581 		);
       
  1582 	}
       
  1583 
       
  1584 	/**
       
  1585 	 * Gets the WordPress database section of the debug data.
       
  1586 	 *
       
  1587 	 * @since 6.7.0
       
  1588 	 *
       
  1589 	 * @global wpdb $wpdb WordPress database abstraction object.
       
  1590 	 *
       
  1591 	 * @return array
       
  1592 	 */
       
  1593 	private static function get_wp_database(): array {
       
  1594 		global $wpdb;
       
  1595 
       
  1596 		// Populate the database debug fields.
       
  1597 		if ( is_object( $wpdb->dbh ) ) {
       
  1598 			// mysqli or PDO.
       
  1599 			$extension = get_class( $wpdb->dbh );
       
  1600 		} else {
       
  1601 			// Unknown sql extension.
       
  1602 			$extension = null;
       
  1603 		}
       
  1604 
       
  1605 		$server = $wpdb->get_var( 'SELECT VERSION()' );
       
  1606 
       
  1607 		$client_version = $wpdb->dbh->client_info;
       
  1608 
       
  1609 		$fields = array(
       
  1610 			'extension'          => array(
       
  1611 				'label' => __( 'Database Extension' ),
       
  1612 				'value' => $extension,
       
  1613 			),
       
  1614 			'server_version'     => array(
       
  1615 				'label' => __( 'Server version' ),
       
  1616 				'value' => $server,
       
  1617 			),
       
  1618 			'client_version'     => array(
       
  1619 				'label' => __( 'Client version' ),
       
  1620 				'value' => $client_version,
       
  1621 			),
       
  1622 			'database_user'      => array(
       
  1623 				'label'   => __( 'Database username' ),
       
  1624 				'value'   => $wpdb->dbuser,
       
  1625 				'private' => true,
       
  1626 			),
       
  1627 			'database_host'      => array(
       
  1628 				'label'   => __( 'Database host' ),
       
  1629 				'value'   => $wpdb->dbhost,
       
  1630 				'private' => true,
       
  1631 			),
       
  1632 			'database_name'      => array(
       
  1633 				'label'   => __( 'Database name' ),
       
  1634 				'value'   => $wpdb->dbname,
       
  1635 				'private' => true,
       
  1636 			),
       
  1637 			'database_prefix'    => array(
       
  1638 				'label'   => __( 'Table prefix' ),
       
  1639 				'value'   => $wpdb->prefix,
       
  1640 				'private' => true,
       
  1641 			),
       
  1642 			'database_charset'   => array(
       
  1643 				'label'   => __( 'Database charset' ),
       
  1644 				'value'   => $wpdb->charset,
       
  1645 				'private' => true,
       
  1646 			),
       
  1647 			'database_collate'   => array(
       
  1648 				'label'   => __( 'Database collation' ),
       
  1649 				'value'   => $wpdb->collate,
       
  1650 				'private' => true,
       
  1651 			),
       
  1652 			'max_allowed_packet' => array(
       
  1653 				'label' => __( 'Max allowed packet size' ),
       
  1654 				'value' => self::get_mysql_var( 'max_allowed_packet' ),
       
  1655 			),
       
  1656 			'max_connections'    => array(
       
  1657 				'label' => __( 'Max connections number' ),
       
  1658 				'value' => self::get_mysql_var( 'max_connections' ),
       
  1659 			),
       
  1660 		);
       
  1661 
       
  1662 		return array(
       
  1663 			'label'  => __( 'Database' ),
       
  1664 			'fields' => $fields,
       
  1665 		);
       
  1666 	}
       
  1667 
       
  1668 	/**
       
  1669 	 * Gets the file system section of the debug data.
       
  1670 	 *
       
  1671 	 * @since 6.7.0
       
  1672 	 *
       
  1673 	 * @return array
       
  1674 	 */
       
  1675 	private static function get_wp_filesystem(): array {
       
  1676 		$upload_dir                     = wp_upload_dir();
       
  1677 		$fonts_dir_exists               = file_exists( wp_get_font_dir()['basedir'] );
       
  1678 		$is_writable_abspath            = wp_is_writable( ABSPATH );
       
  1679 		$is_writable_wp_content_dir     = wp_is_writable( WP_CONTENT_DIR );
       
  1680 		$is_writable_upload_dir         = wp_is_writable( $upload_dir['basedir'] );
       
  1681 		$is_writable_wp_plugin_dir      = wp_is_writable( WP_PLUGIN_DIR );
       
  1682 		$is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) );
       
  1683 		$is_writable_fonts_dir          = $fonts_dir_exists ? wp_is_writable( wp_get_font_dir()['basedir'] ) : false;
       
  1684 
       
  1685 		$fields = array(
       
  1686 			'wordpress'  => array(
       
  1687 				'label' => __( 'The main WordPress directory' ),
       
  1688 				'value' => ( $is_writable_abspath ? __( 'Writable' ) : __( 'Not writable' ) ),
       
  1689 				'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
       
  1690 			),
       
  1691 			'wp-content' => array(
       
  1692 				'label' => __( 'The wp-content directory' ),
       
  1693 				'value' => ( $is_writable_wp_content_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
  1694 				'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
       
  1695 			),
       
  1696 			'uploads'    => array(
       
  1697 				'label' => __( 'The uploads directory' ),
       
  1698 				'value' => ( $is_writable_upload_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
  1699 				'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
       
  1700 			),
       
  1701 			'plugins'    => array(
       
  1702 				'label' => __( 'The plugins directory' ),
       
  1703 				'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
  1704 				'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
       
  1705 			),
       
  1706 			'themes'     => array(
       
  1707 				'label' => __( 'The themes directory' ),
       
  1708 				'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ),
       
  1709 				'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
       
  1710 			),
       
  1711 			'fonts'      => array(
       
  1712 				'label' => __( 'The fonts directory' ),
       
  1713 				'value' => $fonts_dir_exists
       
  1714 					? ( $is_writable_fonts_dir ? __( 'Writable' ) : __( 'Not writable' ) )
       
  1715 					: __( 'Does not exist' ),
       
  1716 				'debug' => $fonts_dir_exists
       
  1717 					? ( $is_writable_fonts_dir ? 'writable' : 'not writable' )
       
  1718 					: 'does not exist',
       
  1719 			),
       
  1720 		);
       
  1721 
       
  1722 		// Add more filesystem checks.
       
  1723 		if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
       
  1724 			$is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );
       
  1725 
       
  1726 			$fields['mu-plugins'] = array(
       
  1727 				'label' => __( 'The must use plugins directory' ),
       
  1728 				'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
       
  1729 				'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ),
       
  1730 			);
       
  1731 		}
       
  1732 
       
  1733 		return array(
       
  1734 			'label'       => __( 'Filesystem Permissions' ),
       
  1735 			'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ),
       
  1736 			'fields'      => $fields,
       
  1737 		);
       
  1738 	}
       
  1739 
       
  1740 	/**
  1493 	 * Returns the value of a MySQL system variable.
  1741 	 * Returns the value of a MySQL system variable.
  1494 	 *
  1742 	 *
  1495 	 * @since 5.9.0
  1743 	 * @since 5.9.0
  1496 	 *
  1744 	 *
  1497 	 * @global wpdb $wpdb WordPress database abstraction object.
  1745 	 * @global wpdb $wpdb WordPress database abstraction object.