WP-Editor.MD升级后 500问题解决

简介: WP-Editor.MD升级后 500问题解决

WP-Editor.MD升级后 500问题解决


使用 markdown 格式来发布 blog,遇到语法渲染的问题,升级 WP-Editor.MD。


1. 现象


升级 WP-Editor.MD 后发布文章入口出现 500 错误,停用 WP-Editor.MD 后可以正常访问。


2. 调测


修改根目录下 wp-config.php 中

/**
 * 开发者专用:WordPress调试模式。
 *
 * 将这个值改为true,WordPress将显示所有用于开发的提示。
 * 强烈建议插件开发者在开发环境中启用WP_DEBUG。
 *
 * 要获取其他能用于调试的信息,请访问Codex。
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define('WP_DEBUG', true); // false -> ture


重新访问文章发布页面:


Fatal error: Cannot redeclare Markdown() (previously declared in wordpress/wp-content/plugins/jetpack-markdown/markdown/lib/extra.php:51) in wordpress/wp-content/plugins/wp-editormd/Jetpack/lib/markdown/extra.phpon line 67


3. 解决



WP-Editor.MD 插件底层使用WordPress Jetpack 的Markdown模块来解析和保存内容,因此可能是相关的插件存在冲突

通过报错可以看到是函数 Markdown() 重复定义造成的,

在 插件 jetpack 中定义了一个函数 Markdown(), 由于 wp-editormd 底层也是用了 Jetpack 底层的 Markdown 模块,造成包含库的时间有冲突。

wordpress/wp-content/plugins/jetpack/_inc/lib/markdown/extra.php


### Standard Function Interface ###
@define( 'MARKDOWN_PARSER_CLASS',  'MarkdownExtra_Parser' );
function Markdown($text) {
#
# Initialize the parser and return the result of its transform method.
#
        # Setup static parser variable.
        static $parser;
        if (!isset($parser)) {
                $parser_class = MARKDOWN_PARSER_CLASS;
                $parser = new $parser_class;
        }
        # Transform text using parser.
        return $parser->transform($text);
}

wordpress/wp-content/plugins/wp-editormd/Jetpack/lib/markdown/extra.php


### Standard Function Interface ###
@define( 'MARKDOWN_PARSER_CLASS',  'MarkdownExtra_Parser_Editormd' );
function Markdown($text) {
#
# Initialize the parser and return the result of its transform method.
#
        # Setup static parser variable.
        static $parser;
        if (!isset($parser)) {
                $parser_class = MARKDOWN_PARSER_CLASS;
                $parser = new $parser_class;
        }
        # Transform text using parser.
        return $parser->transform($text);
}


安装wp-editor插件后写文章页面打不开,报500错误


JetPack 插件也打开md语法功能,造成冲突,关闭 JetPack md 语法功能,或者将两个文件中的文件名修改一个;作者在最新版本已经修复该问题,参见 commit


关闭 wordpress 调试模式

define('WP_DEBUG', false);


目录
相关文章
|
7月前
|
应用服务中间件 nginx
Docsify——部署后显示404且无法访问README.md
Docsify——部署后显示404且无法访问README.md
88 0
|
10月前
使用PDF.js预览文件老是报错Message: file origin does not match viewer‘s_otherError @ app.js:1140怎么办??
使用PDF.js预览文件老是报错Message: file origin does not match viewer‘s_otherError @ app.js:1140怎么办??
|
数据安全/隐私保护
s3cmd安装及使用
s3cmd安装及使用
|
JavaScript 数据安全/隐私保护
jQuery 使用 md5 加密效果demo(整理)
jQuery 使用 md5 加密效果demo(整理)
|
数据安全/隐私保护
MD5加密js-md5
MD5加密js-md5
160 0
|
存储 JSON JavaScript
v-md-editor详解(MarkDown编辑器组件)
v-md-editor详解(MarkDown编辑器组件)
2076 0
|
编译器
在HTML页面中引用Markdown编辑器(Editor.md)
在HTML页面中引用Markdown编辑器(Editor.md)
在HTML页面中引用Markdown编辑器(Editor.md)
|
人工智能 JavaScript 前端开发
尝试:Script Lab,快速 O365 开发工具//SL01)
尝试:Script Lab,快速 O365 开发工具//SL01)
395 0
尝试:Script Lab,快速 O365 开发工具//SL01)
|
JavaScript PHP
php中base64和js中base64可互相加解密
php中base64和js中base64可互相加解密
451 0