WP_Site_Health::test_php_extension_availability

Advertisement

Private Access Private Access

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.

Summery Summery

Check if the passed extension or function are available.

Syntax Syntax

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

Description Description

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

Parameters Parameters

$extension

(Optional) The extension name to test.

Default value: null

$function

(Optional) The function name to test.

Default value: null

$constant

(Optional) The constant name to test for.

Default value: null

$class

(Optional) The class name to test for.

Default value: null

Return Return

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

Source Source

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

	 * @param string $function  Optional. The function name to test. Default null.
	 * @param string $constant  Optional. The constant name to test for. Default null.
	 * @param string $class     Optional. The class name to test for. Default null.
	 * @return bool Whether or not the extension and function are available.
	 */
	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 ) ) {

Advertisement

Changelog Changelog

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

Advertisement

Leave a Reply