【发布时间】:2019-06-06 13:41:09
【问题描述】:
当您在嵌入了简码的页面/帖子上按发布/更新时,我的 Wordpress 插件导致页面/帖子编辑器显示更新/发布失败通知,但是,数据 正在更新/发布。
我已启用 WP_DEBUG 和 WP_DEBUG_LOG,但它们并没有那么有用,因为报告的唯一错误如下:
PHP Notice: edit_form_advanced is <strong>deprecated</strong> since version 5.0.0! Use block_editor_meta_box_hidden_fields instead. This action is still supported in the classic editor, but is deprecated in the block editor. in /wp-includes/functions.php on line 4112
我检查了文件,但如您所见,它是一个 WP 核心文件,该功能只是一个错误记录器。
我知道问题与 Gutenberg 编辑器有关,因为该插件在经典编辑器中按预期工作。
阅读后,我注意到有人建议将短代码的输出放入变量中并返回,但我没有这样做。
我认为相关的代码在这里:
function enu_explorer_shortcode() {
$output = '';
include_once "eurno_include_file.php";
begin_eurno_explorer();
return $output;
}
add_shortcode( 'eurno_explorer', 'enu_explorer_shortcode' );
文件 eurno_include_file.php 中的代码在这里:
function begin_eurno_explorer() {
if (!isset($_GET['action'])) {
if(((!empty(key($_GET))) && (!isset($_GET['preview']))) ){
$chainName = key($_GET);
if(isset($_GET[$chainName])){
$name = $_GET[$chainName];
}
if(isset(get_option('eurno_explorer')['eurno_data']['api'][$chainName][0])){
$api = get_option('eurno_explorer')['eurno_data']['api'][$chainName][0];
}
if(!isset(get_option('eurno_explorer')['eurno_data']['api'][$chainName][0])) {
$api = 'https://enu.qsx.io:443';
}
} else {
$chainName = 'enu';
$api = 'https://enu.qsx.io:443';
}
$output = (include "header.php");
$output .= (include "config/search.php");
if((isset($_GET[$chainName])) && (empty($_GET[$chainName])) || (!isset($_GET[$chainName]))) {
$output .= (include "config/chain-info.php");
$output .= (include "config/block-producers.php");
return;
} elseif(isset($_GET[$chainName]) && (strlen($_GET[$chainName]) === 64) && (ctype_xdigit($_GET[$chainName]))) {
$output .= (include "config/transaction.php");
return;
} elseif((isset($_GET[$chainName])) && (strlen($_GET[$chainName]) <= 12)){
$output .= (include 'config/recent-transactions.php');
return;
}
$term = implode(", ", $_GET);
$chain = key($_GET);
$output .= '<div class="card border border-danger mt-5">';
$output .= '<div class="card-header alert alert-danger">';
$output .= 'Showing results for: '.$term.' on: ' . $chain;
$output .= '</div>';
$output .= '<div class="card-body">';
$output .= '<div class="p-4">';
$output .= '<h4>Well, this is embarassing.</h4>';
$output .= '<p>We can\'t seem to find anything for <b>'.$term.'</b> on the <b>'.$chain.'</b> blockchain. Are you sure you have entered a valid transaction ID or account name?.</p>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
}
}
如果您想进一步了解插件的代码,请访问:https://github.com/eurno/eurno-explorer
提前谢谢你,真的很感激。
【问题讨论】:
标签: php wordpress shortcode wordpress-gutenberg