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

WP_Site_Health::test_php_extension_availability( string $extension = null, string $function = null, string $constant = null, string $class = null )

Check if the passed extension or function are available.


Description Description

Make the check for available PHP modules into a simple boolean operator for a cleaner test runner.


Top ↑

Parameters Parameters

$extension

(string) (Optional) The extension name to test.

Default value: null

$function

(string) (Optional) The function name to test.

Default value: null

$constant

(string) (Optional) The constant name to test for.

Default value: null

$class

(string) (Optional) The class name to test for.

Default value: null


Top ↑

Return Return

(bool) Whether or not the extension and function are available.


Top ↑

Source Source

File: wp-admin/includes/class-wp-site-health.php

	private function test_php_extension_availability( $extension = null, $function = null, $constant = null, $class = null ) {
		// If no extension or function is passed, claim to fail testing, as we have nothing to test against.
		if ( ! $extension && ! $function && ! $constant && ! $class ) {
			return false;
		}

		if ( $extension && ! extension_loaded( $extension ) ) {
			return false;
		}
		if ( $function && ! function_exists( $function ) ) {
			return false;
		}
		if ( $constant && ! defined( $constant ) ) {
			return false;
		}
		if ( $class && ! class_exists( $class ) ) {
			return false;
		}

		return true;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.3.0 The $constant and $class parameters were added.
5.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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