我正在构建一个用于前端提交的插件。 我正在使用短代码 API 来显示内容提交的表单,但我遇到了麻烦。 问题是,wp_editor echoe 的数据,shortcode 应该返回数据。 当我像这样集成 wp_editor 时:
$final_form .= wp_editor();
表单确实呈现,但不在地方,而是在帖子内容之上,其中包含 shotcode。 你知道如何在短代码 API 中使用 wp_editor 吗? 我不想手动调用 TinyMCE 等。
谢谢。
如果一个函数 echo
s 数据,你可以使用 php 输出缓冲来捕获 echo
编辑输出并返回它
// Turn on the output buffer
ob_start();
// Echo the editor to the buffer
wp_editor();
// Store the contents of the buffer in a variable
$editor_contents = ob_get_clean();
// Return the content you want to the calling function
return $editor_contents;