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() WordPress Method

The WP_Site_Health::test_php_extension_availability() method is used to test whether the required PHP extensions are available.

WP_Site_Health::test_php_extension_availability( string $extension_name = null, string $function_name = null, string $constant_name = null, string $class_name = null ) #

Check if the passed extension or function are available.


Description

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


Top ↑

Parameters

$extension_name

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

Default value: null

$function_name

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

Default value: null

$constant_name

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

Default value: null

$class_name

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

Default value: null


Top ↑

Return

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


Top ↑

Source

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

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

		if ( $extension_name && ! extension_loaded( $extension_name ) ) {
			return false;
		}

		if ( $function_name && ! function_exists( $function_name ) ) {
			return false;
		}

		if ( $constant_name && ! defined( $constant_name ) ) {
			return false;
		}

		if ( $class_name && ! class_exists( $class_name ) ) {
			return false;
		}

		return true;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.3.0The $constant_name and $class_name parameters were added.
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.