Ошибка получения обновления/опубликования уведомления об ошибке, хотя страница обновляется/опубликовывается

Мой плагин 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

Спасибо заранее, это действительно ценится.


person MakingStuffs    schedule 11.01.2019    source источник


Ответы (1)


Оказалось, что, хотя я назначал свой вывод переменной, которую я возвращал, я все же в конечном итоге повторял свои данные в долгосрочной перспективе. Чтобы решить проблему, не переписывая большую часть моего кода, мне пришлось использовать буферизацию вывода, поэтому теперь

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' );
person MakingStuffs    schedule 12.01.2019