我有一个包含多个wp_editors的页面。我要做其中的两件。我试过以下几种方法,但都没有用。我确实把它放在加载页面的函数之后,但不确定它是否应该在其他地方。任何帮助都是非常感谢的。
Code来加载wp_编辑器
$content = "";
$editorid = "statement";
$settings = array(
'textarea_name' => 'statement',
'editor_height' => 100,
'quicktags' => false,
'media_buttons' => false,
'teeny' => true,
'tinymce'=> array(
'theme_advanced_disable' => 'fullscreen',
'width' => 500,
)
);
wp_editor( $content, $editorid, $settings );
使编辑器需要的<#>Code
add_filter( 'statement', 'add_required_attribute_to_wp_editor', 10, 1 );
function add_required_attribute_to_wp_editor( $editor ) {
$editor = str_replace( '
发布于 2019-05-15 17:38:08
除了id之外,我找不到任何允许向wp_editor
添加任何标记属性的文档。你有两个我能想到的选择。第一种方法是包含一个依赖于(或不依赖) jQuery的javascript文件,它将在DOM完全呈现之后将所需的属性添加到编辑器文本区域。
另一种选择是包括一个验证函数,无论是服务器端还是浏览器端,以确保数据是存在的。我建议采用这种方法,因为所需的属性不是在浏览器中普遍实现的。。
您的代码将无法工作,因为没有在apply_filter
上触发的$statement
函数。
https://wordpress.stackexchange.com/questions/337964
复制相似问题