WordPress 常见错误及解决方法

BBigSun 评论240阅读模式

记录 WordPress 的一些常见报错及解决方法

一、添加链接报错

WordPress 常见错误及解决方法文章源自十年又十年-https://www.bbigsun.com/205.html

报错信息文章源自十年又十年-https://www.bbigsun.com/205.html

operty "ID" on null in /wp-content/plugins/wp-githuber-md/src/helpers.php on line 62文章源自十年又十年-https://www.bbigsun.com/205.html

解决方法文章源自十年又十年-https://www.bbigsun.com/205.html

在 插件文件编辑器 中修改 helpers.php 代码文章源自十年又十年-https://www.bbigsun.com/205.html

原代码 62 行未判断 post 是否为空,故当 post 为空时报错。文章源自十年又十年-https://www.bbigsun.com/205.html

function githuber_current_user_can( $action ) {
    global $post;

    if ( current_user_can( $action, $post->ID ) ) {
        return true;
    }

    return false;
}

添加判断语句,如果 post 不为空执行代码文章源自十年又十年-https://www.bbigsun.com/205.html

function githuber_current_user_can( $action ) {
    global $post;

    if ( ! empty( $post ) ) {
        if ( current_user_can( $action, $post->ID ) ) {
            return true;
        }
    }

    return false;
}
文章源自十年又十年-https://www.bbigsun.com/205.html文章源自十年又十年-https://www.bbigsun.com/205.html

纸上得来终觉浅,绝知此事要躬行。

weinxin
17688689121
我的微信
微信扫一扫
BBigSun
  • 本文由 BBigSun 发表于 2023年 1月 8日 12:18:54
  • 转载请务必保留本文链接:https://www.bbigsun.com/205.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定