WP Mail SMTP by WPForms 與 PHP 8.0 不相容的問題

WordPress 5.6 已發 (2020/12/8) 佈一段時間,5.6 版本也開始支援 PHP 8.0 (2020/11/27 日發佈),不過,至今 WP Mail SMTP by WPForms 2.5.1 版本還是沒有支援 PHP 8.0 版,但在官方 Support 看到解法,(官方說明會在下一個版本 (2.5.2) 更新,但沒有明確時間。

如果,你還不想等官方發佈修正版本,可以參考官方公佈的修正方式,與 PHP 8.0 相容。

wp-mail-smtp

.../wp-content/plugins/wp-mail-smtp/vendor_prefixed/symfony/polyfill-mbstring/Resources/

增加一個 mb_convert_variables.php8 文件,如下:

.../wp-content/plugins/wp-mail-smtp/vendor_prefixed/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8

mb_convert_variables.php8 代碼

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring as p;

if (!function_exists('mb_convert_variables')) {
    /**
     * Convert character code in variable(s)
     */
    function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars)
    {
        $vars = [&$var, ...$vars];

        $ok = true;
        array_walk_recursive($vars, function (&$v) use (&$ok, $to_encoding, $from_encoding) {
            if (false === $v = p\Mbstring::mb_convert_encoding($v, $to_encoding, $from_encoding)) {
                $ok = false;
            }
        });

        return $ok ? $from_encoding : false;
    }

Latest posts by yungkeli (see all)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *