apache_mod_loaded() WordPress Function

The apache_mod_loaded() function is used to check if a specific Apache module is loaded. This is useful for checking if a particular feature is available before using it.

apache_mod_loaded( string $mod, bool $default = false ) #

Does the specified module exist in the Apache config?


Parameters

$mod

(string)(Required)The module, e.g. mod_rewrite.

$default

(bool)(Optional) The default return value if the module is not found.

Default value: false


Top ↑

Return

(bool) Whether the specified module is loaded.


Top ↑

Source

File: wp-includes/functions.php

function apache_mod_loaded( $mod, $default = false ) {
	global $is_apache;

	if ( ! $is_apache ) {
		return false;
	}

	if ( function_exists( 'apache_get_modules' ) ) {
		$mods = apache_get_modules();
		if ( in_array( $mod, $mods, true ) ) {
			return true;
		}
	} elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
			ob_start();
			phpinfo( 8 );
			$phpinfo = ob_get_clean();
		if ( false !== strpos( $phpinfo, $mod ) ) {
			return true;
		}
	}

	return $default;
}


Top ↑

Changelog

Changelog
VersionDescription
2.5.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.

Show More
Show More