尽管页面正在 updated/published 中,但获取更新 failed/publishing 通知失败

Getting update failed/publishing failed notice although page is being updated/published

我的 Wordpress 插件导致 page/post 编辑器显示 update/publishing 失败通知,当您在嵌入了简码的 page/post 上按 publish/update 时,但是,数据 是 update/published。

我启用了 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

提前致谢,非常感谢。

事实证明,虽然我将我的输出分配给一个我正在返回的变量,但我最终还是在长 运行 中回显了我的数据。为了在不重写大部分代码的情况下解决问题,我不得不使用输出缓冲,所以现在

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' );