apache_mod_loaded

The timeline below displays how wordpress function apache_mod_loaded has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Determines whether the specified module exist in the Apache config.
 *
 * @since 2.5.0
 *
 * @global bool $is_apache
 *
 * @param string $mod           The module, e.g. mod_rewrite.
 * @param bool   $default_value Optional. The default return value if the module is not found. Default false.
 * @return bool Whether the specified module is loaded.
 */
function apache_mod_loaded($mod, $default_value = 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') && !str_contains(ini_get('disable_functions'), 'phpinfo')) {
        ob_start();
        phpinfo(INFO_MODULES);
        $phpinfo = ob_get_clean();
        if (str_contains($phpinfo, $mod)) {
            return true;
        }
    }
    return $default_value;
}

WordPress Version: 6.2

/**
 * Determines whether the specified module exist in the Apache config.
 *
 * @since 2.5.0
 *
 * @global bool $is_apache
 *
 * @param string $mod           The module, e.g. mod_rewrite.
 * @param bool   $default_value Optional. The default return value if the module is not found. Default false.
 * @return bool Whether the specified module is loaded.
 */
function apache_mod_loaded($mod, $default_value = 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_value;
}

WordPress Version: 6.1

/**
 * Determines whether the specified module exist in the Apache config.
 *
 * @since 2.5.0
 *
 * @global bool $is_apache
 *
 * @param string $mod     The module, e.g. mod_rewrite.
 * @param bool   $default Optional. The default return value if the module is not found. Default false.
 * @return bool Whether the specified module is loaded.
 */
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;
}

WordPress Version: 5.5

/**
 * Does the specified module exist in the Apache config?
 *
 * @since 2.5.0
 *
 * @global bool $is_apache
 *
 * @param string $mod     The module, e.g. mod_rewrite.
 * @param bool   $default Optional. The default return value if the module is not found. Default false.
 * @return bool Whether the specified module is loaded.
 */
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;
}

WordPress Version: 4.3

/**
 * Does the specified module exist in the Apache config?
 *
 * @since 2.5.0
 *
 * @global bool $is_apache
 *
 * @param string $mod     The module, e.g. mod_rewrite.
 * @param bool   $default Optional. The default return value if the module is not found. Default false.
 * @return bool Whether the specified module is loaded.
 */
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)) {
            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;
}

WordPress Version: 4.0

/**
 * Does the specified module exist in the Apache config?
 *
 * @since 2.5.0
 *
 * @param string $mod     The module, e.g. mod_rewrite.
 * @param bool   $default Optional. The default return value if the module is not found. Default false.
 * @return bool Whether the specified module is loaded.
 */
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)) {
            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;
}

WordPress Version: 3.7

/**
 * Does the specified module exist in the Apache config?
 *
 * @since 2.5.0
 *
 * @param string $mod e.g. mod_rewrite
 * @param bool $default The default return value if the module is not found
 * @return bool
 */
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)) {
            return true;
        }
    } elseif (function_exists('phpinfo')) {
        ob_start();
        phpinfo(8);
        $phpinfo = ob_get_clean();
        if (false !== strpos($phpinfo, $mod)) {
            return true;
        }
    }
    return $default;
}