Summery Summery

Should we use the libsodium core function instead? This is always a good idea, if it’s available. (Unless we’re in the middle of running our unit test suite.)

Syntax Syntax

ParagonIE_Sodium_Compat::use_fallback( string $sodium_func_name = '' )

Description Description

If ext/libsodium is available, use it. Return TRUE. Otherwise, we have to use the code provided herein. Return FALSE.

Parameters Parameters



Default value: ''

Return Return


Source Source

File: wp-includes/sodium_compat/src/Compat.php

    protected static function use_fallback($sodium_func_name = '')
        static $res = null;
        if ($res === null) {
            $res = extension_loaded('libsodium') && PHP_VERSION_ID >= 50300;
        if ($res === false) {
            // No libsodium installed
            return false;
        if (self::$disableFallbackForUnitTests) {
            // Don't fallback. Use the PHP implementation.
            return false;
        if (!empty($sodium_func_name)) {
            return is_callable('\\Sodium\\' . $sodium_func_name);
        return true;



Leave a Reply