解决 WordPress 停用 Polylang 插件报错问题

建站 码拜 5年前 (2019-10-23) 2928次浏览 0个评论

上一篇介绍了 wordpress 中 Polylang 插件 的应用。多语言网站轻松实现了,后来因为某些原因需要临时停用 Polylang 插件,问题来了。在插件列表点击停用后,后台报错了。修改 web-config.php 文件,让错误显示出来。错误如下:

Fatal error: Uncaught Error: Call to undefined function pll_register_string() in
/home/.../wp-content/themes/codebye.com/functions.php:19 Stack trace: #0
/home/.../wp-includes/class-wp-hook.php(286): {closure}('') #1
/home/.../wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2
/home/.../wp-includes/plugin.php(465): WP_Hook->do_action(Array) #3
/home/.../wp-settings.php(525): do_action('init') #4
/home/.../wp-config.php(90): require_once('/home/mybitwor/...') #5
/home/.../wp-load.php(37): require_once('/home/mybitwor/...') #6
/home/.../wp-admin/admin.php(34): require_once('/home/mybitwor/...') #7
/home/.../wp-admin/plugins.php(10): require_once('/home/mybitwor/...') #8
{main} th in /home/.../wp-content/themes/codebye.com/functions.php on line 19

问题原因:polylang插件停用后,pll_register_string 找不到了。

处理方式:修改functions.php

function codebyecom_after_setup_theme() {
    if ( function_exists( 'pll_register_string' ) ) {
		pll_register_string('custom', 'codebye');
    }
}
 add_action( 'after_setup_theme', 'codebyecom_after_setup_theme' );

function pl_e( $string = '' ) {
    if ( function_exists( 'pll_e' ) ) {
        pll_e( $string );
    } else {
        echo $string;
    }
}

经过上述修改后,停用polylang插件恢复正常。


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明解决 WordPress 停用 Polylang 插件报错问题
喜欢 (1)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!