douzhi1924 2019-01-11 15:49
浏览 353
已采纳

尽管页面正在更新/发布,但更新失败/发布失败

My Wordpress plugin is causing the page/post editor to display the update/publishing failed notice when you press publish/update on a page/post with its shortcode embedded, however, the data is being update/published.

I have enable WP_DEBUG and WP_DEBUG_LOG but they are not really that helpful as the only error reported is as follows:

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

I checked the file but it is a WP core file as you can see and the function is simply an error logger.

I know the problem is to do with the Gutenberg editor as the plugin works as expected when in the classic editor.

After reading I noted people suggesting putting the output of the shortcode into a variable and returning that, which I have done to no avail.

The code which I think is relevant is here:

function enu_explorer_shortcode() {
  $output = '';
  include_once "eurno_include_file.php";
  begin_eurno_explorer();
  return $output;
}
add_shortcode( 'eurno_explorer', 'enu_explorer_shortcode' );

and the code from the file eurno_include_file.php is here:

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

If you would like a further look into the plugin's code it can be found at: https://github.com/eurno/eurno-explorer

Thank you in advance it is really appreciated.

  • 写回答

1条回答 默认 最新

  • dongqi8030 2019-01-12 12:59
    关注

    It turned out that, although I was assigning my output to a variable which I was returning, I was still ultimately echoing my data in the long run. In order to fix the problem without rewriting the majority of my code I had to use output buffering so now

    function enu_explorer_shortcode() {
    $output = '';
    include_once "eurno_include_file.php";
    begin_eurno_explorer();
    return $output;
    }
    add_shortcode( 'eurno_explorer', 'enu_explorer_shortcode' );
    

    to this:

    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' );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法