On this page
apache_mod_loaded( string $mod, bool $default = false ): bool
Determines whether the specified module exist in the Apache config.
Parameters
$modstring Required-
The module, e.g. mod_rewrite.
$defaultbool Optional-
The default return value if the module is not found.
Default:
false
Return
bool Whether the specified module is loaded.
Source
File: wp-includes/functions.php. View all references
function apache_mod_loaded( $mod, $default = false ) {
global $is_apache;
if ( ! $is_apache ) {
return false;
}
$loaded_mods = array();
if ( function_exists( 'apache_get_modules' ) ) {
$loaded_mods = apache_get_modules();
if ( in_array( $mod, $loaded_mods, true ) ) {
return true;
}
}
if ( empty( $loaded_mods )
&& function_exists( 'phpinfo' )
&& false === strpos( ini_get( 'disable_functions' ), 'phpinfo' )
) {
ob_start();
phpinfo( INFO_MODULES );
$phpinfo = ob_get_clean();
if ( false !== strpos( $phpinfo, $mod ) ) {
return true;
}
}
return $default;
}
Related
Used By
| Used By | Description |
|---|---|
| network_step1() wp-admin/includes/network.php | Prints step 1 for Network installation process. |
| got_mod_rewrite() wp-admin/includes/misc.php | Returns whether the server is running Apache with the mod_rewrite module loaded. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/apache_mod_loaded