php - 尽管页面正在更新/发布,但获取更新失败/发布失败通知
问题描述
当您在嵌入了简码的页面/帖子上按发布/更新时,我的 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 核心文件,该功能只是一个错误记录器。
我知道问题与古腾堡编辑器有关,因为插件在经典编辑器中按预期工作。
阅读后,我注意到有人建议将短代码的输出放入一个变量中并返回它,我这样做无济于事。
我认为相关的代码在这里:
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
提前谢谢你,真的很感激。
解决方案
事实证明,尽管我将输出分配给要返回的变量,但从长远来看,我最终还是会回显我的数据。为了在不重写我的大部分代码的情况下解决问题,我现在不得不使用输出缓冲
function enu_explorer_shortcode() {
$output = '';
include_once "eurno_include_file.php";
begin_eurno_explorer();
return $output;
}
add_shortcode( 'eurno_explorer', 'enu_explorer_shortcode' );
对此:
function enu_explorer_shortcode() {
ob_start();
include_once "eurno_include_file.php";
begin_eurno_explorer();
$eurno_explorer_output = ob_get_clean();
return $eurno_explorer_output;
}
add_shortcode( 'eurno_explorer', 'enu_explorer_shortcode' );
推荐阅读
- unit-testing - 对 16 位嵌入式目标的单元测试
- javascript - Google Ad Manager 网站的 CSP(内容安全政策)
- django - 从 Django 的 ImageField 下载并打印图像
- android - 本机崩溃发生了约 2k 次,但仅影响了 6 名使用 3 台特定三星设备的用户
- python - Python while 循环和 Reeborg 的世界挑战赛
- python - 将选项限制为仅整数
- python - Nextflow 在流程之间操纵变量
- cassandra - 如何在 MacOs Big Sur 上安装 Cassandra
- java - 如何在同一个项目中找到文件的路径?
- angular - 在 RxJS 管道中转换 JavaScript 对象