我为Wordpress创建了一个自定义插件,它有一些自定义表等。在处理数据后,我要么显示确认消息,要么显示错误消息(这是在wp管理端)。我一直在使用WordPress类来使用默认主题,如下所示:
<?php if ( ! empty($success)): ?>
<div class="updated">
<ul>
<?php foreach ($success as $message): ?>
<li><?php echo $message; ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php if ( ! empty($errors)): ?>
<div class="error">
<ul>
<?php foreach ($errors as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<!-- HTML STARTS HERE -->
<div class="wrap">
奇怪的是,当输出错误或成功消息时,它们会出现在HTML的不同部分。我不明白为什么。在某些情况下,DOM树中有几个节点,例如。
<!-- In the code it's here (as shown above)... -->
<div class="wrap">
<section>
<header>
<div>
<!-- BUT IT SHOWS UP HERE, WHAT!? -->
</div>
</header>
</section>
</div>