wp/wp-admin/includes/class-wp-debug-data.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    46 		$environment_type       = wp_get_environment_type();
    46 		$environment_type       = wp_get_environment_type();
    47 		$core_version           = get_bloginfo( 'version' );
    47 		$core_version           = get_bloginfo( 'version' );
    48 		$core_updates           = get_core_updates();
    48 		$core_updates           = get_core_updates();
    49 		$core_update_needed     = '';
    49 		$core_update_needed     = '';
    50 
    50 
    51 		foreach ( $core_updates as $core => $update ) {
    51 		if ( is_array( $core_updates ) ) {
    52 			if ( 'upgrade' === $update->response ) {
    52 			foreach ( $core_updates as $core => $update ) {
    53 				/* translators: %s: Latest WordPress version number. */
    53 				if ( 'upgrade' === $update->response ) {
    54 				$core_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $update->version );
    54 					/* translators: %s: Latest WordPress version number. */
    55 			} else {
    55 					$core_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $update->version );
    56 				$core_update_needed = '';
    56 				} else {
       
    57 					$core_update_needed = '';
       
    58 				}
    57 			}
    59 			}
    58 		}
    60 		}
    59 
    61 
    60 		// Set up the array that holds all debug information.
    62 		// Set up the array that holds all debug information.
    61 		$info = array();
    63 		$info = array();
   266 				),
   268 				),
   267 				'WP_PLUGIN_DIR'       => array(
   269 				'WP_PLUGIN_DIR'       => array(
   268 					'label' => 'WP_PLUGIN_DIR',
   270 					'label' => 'WP_PLUGIN_DIR',
   269 					'value' => WP_PLUGIN_DIR,
   271 					'value' => WP_PLUGIN_DIR,
   270 				),
   272 				),
       
   273 				'WP_MEMORY_LIMIT'     => array(
       
   274 					'label' => 'WP_MEMORY_LIMIT',
       
   275 					'value' => WP_MEMORY_LIMIT,
       
   276 				),
   271 				'WP_MAX_MEMORY_LIMIT' => array(
   277 				'WP_MAX_MEMORY_LIMIT' => array(
   272 					'label' => 'WP_MAX_MEMORY_LIMIT',
   278 					'label' => 'WP_MAX_MEMORY_LIMIT',
   273 					'value' => WP_MAX_MEMORY_LIMIT,
   279 					'value' => WP_MAX_MEMORY_LIMIT,
   274 				),
   280 				),
   275 				'WP_DEBUG'            => array(
   281 				'WP_DEBUG'            => array(
   507 		);
   513 		);
   508 
   514 
   509 		// Get ImageMagic information, if available.
   515 		// Get ImageMagic information, if available.
   510 		if ( class_exists( 'Imagick' ) ) {
   516 		if ( class_exists( 'Imagick' ) ) {
   511 			// Save the Imagick instance for later use.
   517 			// Save the Imagick instance for later use.
   512 			$imagick         = new Imagick();
   518 			$imagick             = new Imagick();
   513 			$imagick_version = $imagick->getVersion();
   519 			$imagemagick_version = $imagick->getVersion();
   514 		} else {
   520 		} else {
   515 			$imagick_version = __( 'Not available' );
   521 			$imagemagick_version = __( 'Not available' );
   516 		}
   522 		}
   517 
   523 
   518 		$info['wp-media']['fields']['imagick_module_version'] = array(
   524 		$info['wp-media']['fields']['imagick_module_version'] = array(
   519 			'label' => __( 'ImageMagick version number' ),
   525 			'label' => __( 'ImageMagick version number' ),
   520 			'value' => ( is_array( $imagick_version ) ? $imagick_version['versionNumber'] : $imagick_version ),
   526 			'value' => ( is_array( $imagemagick_version ) ? $imagemagick_version['versionNumber'] : $imagemagick_version ),
   521 		);
   527 		);
   522 
   528 
   523 		$info['wp-media']['fields']['imagemagick_version'] = array(
   529 		$info['wp-media']['fields']['imagemagick_version'] = array(
   524 			'label' => __( 'ImageMagick version string' ),
   530 			'label' => __( 'ImageMagick version string' ),
   525 			'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ),
   531 			'value' => ( is_array( $imagemagick_version ) ? $imagemagick_version['versionString'] : $imagemagick_version ),
       
   532 		);
       
   533 
       
   534 		$imagick_version = phpversion( 'imagick' );
       
   535 
       
   536 		$info['wp-media']['fields']['imagick_version'] = array(
       
   537 			'label' => __( 'Imagick version' ),
       
   538 			'value' => ( $imagick_version ) ? $imagick_version : __( 'Not available' ),
   526 		);
   539 		);
   527 
   540 
   528 		if ( ! function_exists( 'ini_get' ) ) {
   541 		if ( ! function_exists( 'ini_get' ) ) {
   529 			$info['wp-media']['fields']['ini_get'] = array(
   542 			$info['wp-media']['fields']['ini_get'] = array(
   530 				'label' => __( 'File upload settings' ),
   543 				'label' => __( 'File upload settings' ),
   589 			$info['wp-media']['fields']['imagick_limits'] = array(
   602 			$info['wp-media']['fields']['imagick_limits'] = array(
   590 				'label' => __( 'Imagick Resource Limits' ),
   603 				'label' => __( 'Imagick Resource Limits' ),
   591 				'value' => $limits,
   604 				'value' => $limits,
   592 				'debug' => $limits_debug,
   605 				'debug' => $limits_debug,
   593 			);
   606 			);
       
   607 
       
   608 			try {
       
   609 				$formats = Imagick::queryFormats( '*' );
       
   610 			} catch ( Exception $e ) {
       
   611 				$formats = array();
       
   612 			}
       
   613 
       
   614 			$info['wp-media']['fields']['imagemagick_file_formats'] = array(
       
   615 				'label' => __( 'ImageMagick supported file formats' ),
       
   616 				'value' => ( empty( $formats ) ) ? __( 'Unable to determine' ) : implode( ', ', $formats ),
       
   617 				'debug' => ( empty( $formats ) ) ? 'Unable to determine' : implode( ', ', $formats ),
       
   618 			);
   594 		}
   619 		}
   595 
   620 
   596 		// Get GD information, if available.
   621 		// Get GD information, if available.
   597 		if ( function_exists( 'gd_info' ) ) {
   622 		if ( function_exists( 'gd_info' ) ) {
   598 			$gd = gd_info();
   623 			$gd = gd_info();
   603 		$info['wp-media']['fields']['gd_version'] = array(
   628 		$info['wp-media']['fields']['gd_version'] = array(
   604 			'label' => __( 'GD version' ),
   629 			'label' => __( 'GD version' ),
   605 			'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
   630 			'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
   606 			'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
   631 			'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
   607 		);
   632 		);
       
   633 
       
   634 		$gd_image_formats     = array();
       
   635 		$gd_supported_formats = array(
       
   636 			'GIF Create' => 'GIF',
       
   637 			'JPEG'       => 'JPEG',
       
   638 			'PNG'        => 'PNG',
       
   639 			'WebP'       => 'WebP',
       
   640 			'BMP'        => 'BMP',
       
   641 			'AVIF'       => 'AVIF',
       
   642 			'HEIF'       => 'HEIF',
       
   643 			'TIFF'       => 'TIFF',
       
   644 			'XPM'        => 'XPM',
       
   645 		);
       
   646 
       
   647 		foreach ( $gd_supported_formats as $format_key => $format ) {
       
   648 			$index = $format_key . ' Support';
       
   649 			if ( isset( $gd[ $index ] ) && $gd[ $index ] ) {
       
   650 				array_push( $gd_image_formats, $format );
       
   651 			}
       
   652 		}
       
   653 
       
   654 		if ( ! empty( $gd_image_formats ) ) {
       
   655 			$info['wp-media']['fields']['gd_formats'] = array(
       
   656 				'label' => __( 'GD supported file formats' ),
       
   657 				'value' => implode( ', ', $gd_image_formats ),
       
   658 			);
       
   659 		}
   608 
   660 
   609 		// Get Ghostscript information, if available.
   661 		// Get Ghostscript information, if available.
   610 		if ( function_exists( 'exec' ) ) {
   662 		if ( function_exists( 'exec' ) ) {
   611 			$gs = exec( 'gs --version' );
   663 			$gs = exec( 'gs --version' );
   612 
   664 
   972 						'banners_rtl'   => array(),
  1024 						'banners_rtl'   => array(),
   973 						'tested'        => '',
  1025 						'tested'        => '',
   974 						'requires_php'  => '',
  1026 						'requires_php'  => '',
   975 						'compatibility' => new stdClass(),
  1027 						'compatibility' => new stdClass(),
   976 					);
  1028 					);
   977 					$item = array_merge( $item, array_intersect_key( $plugin, $item ) );
  1029 					$item = wp_parse_args( $plugin, $item );
   978 				}
  1030 				}
   979 
  1031 
   980 				$type = 'plugin';
  1032 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, (object) $item );
   981 				/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
       
   982 				$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
       
   983 
  1033 
   984 				if ( ! is_null( $auto_update_forced ) ) {
  1034 				if ( ! is_null( $auto_update_forced ) ) {
   985 					$enabled = $auto_update_forced;
  1035 					$enabled = $auto_update_forced;
   986 				} else {
  1036 				} else {
   987 					$enabled = in_array( $plugin_path, $auto_updates, true );
  1037 					$enabled = in_array( $plugin_path, $auto_updates, true );
  1119 					'requires'     => '',
  1169 					'requires'     => '',
  1120 					'requires_php' => '',
  1170 					'requires_php' => '',
  1121 				);
  1171 				);
  1122 			}
  1172 			}
  1123 
  1173 
  1124 			$type = 'theme';
  1174 			$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
  1125 			/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
       
  1126 			$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
       
  1127 
  1175 
  1128 			if ( ! is_null( $auto_update_forced ) ) {
  1176 			if ( ! is_null( $auto_update_forced ) ) {
  1129 				$enabled = $auto_update_forced;
  1177 				$enabled = $auto_update_forced;
  1130 			} else {
  1178 			} else {
  1131 				$enabled = in_array( $active_theme->stylesheet, $auto_updates, true );
  1179 				$enabled = in_array( $active_theme->stylesheet, $auto_updates, true );
  1207 						'requires'     => '',
  1255 						'requires'     => '',
  1208 						'requires_php' => '',
  1256 						'requires_php' => '',
  1209 					);
  1257 					);
  1210 				}
  1258 				}
  1211 
  1259 
  1212 				$type = 'theme';
  1260 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
  1213 				/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
       
  1214 				$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
       
  1215 
  1261 
  1216 				if ( ! is_null( $auto_update_forced ) ) {
  1262 				if ( ! is_null( $auto_update_forced ) ) {
  1217 					$enabled = $auto_update_forced;
  1263 					$enabled = $auto_update_forced;
  1218 				} else {
  1264 				} else {
  1219 					$enabled = in_array( $parent_theme->stylesheet, $auto_updates, true );
  1265 					$enabled = in_array( $parent_theme->stylesheet, $auto_updates, true );
  1297 						'requires'     => '',
  1343 						'requires'     => '',
  1298 						'requires_php' => '',
  1344 						'requires_php' => '',
  1299 					);
  1345 					);
  1300 				}
  1346 				}
  1301 
  1347 
  1302 				$type = 'theme';
  1348 				$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
  1303 				/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
       
  1304 				$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
       
  1305 
  1349 
  1306 				if ( ! is_null( $auto_update_forced ) ) {
  1350 				if ( ! is_null( $auto_update_forced ) ) {
  1307 					$enabled = $auto_update_forced;
  1351 					$enabled = $auto_update_forced;
  1308 				} else {
  1352 				} else {
  1309 					$enabled = in_array( $theme_slug, $auto_updates, true );
  1353 					$enabled = in_array( $theme_slug, $auto_updates, true );
  1325 				 * @param bool     $enabled             Whether auto-updates are enabled for this item.
  1369 				 * @param bool     $enabled             Whether auto-updates are enabled for this item.
  1326 				 */
  1370 				 */
  1327 				$auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
  1371 				$auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
  1328 
  1372 
  1329 				$theme_version_string       .= ' | ' . $auto_updates_string;
  1373 				$theme_version_string       .= ' | ' . $auto_updates_string;
  1330 				$theme_version_string_debug .= ',' . $auto_updates_string;
  1374 				$theme_version_string_debug .= ', ' . $auto_updates_string;
  1331 			}
  1375 			}
  1332 
  1376 
  1333 			$info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->name ) ] = array(
  1377 			$info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->name ) ] = array(
  1334 				'label' => sprintf(
  1378 				'label' => sprintf(
  1335 					/* translators: 1: Theme name. 2: Theme slug. */
  1379 					/* translators: 1: Theme name. 2: Theme slug. */