我正在尝试自定义幻灯片默认字段(幻灯片字段 - Redux 框架)以包含 wp 编辑器而不是 textarea(描述区域)
到目前为止,我已经更改了这部分代码
if ( $this->field[ 'show' ][ 'description' ] ) {
$placeholder = ( isset ( $this->field[ 'placeholder' ][ 'description' ] ) ) ? esc_attr ($this->field[ 'placeholder' ][ 'description' ] ) : __ ( 'Description', 'redux-framework' );
echo '<li><textarea name="' . $this->field[ 'name' ] . '[' . $x . '][description]' . $this->field['name_suffix'] . '" id="' . $this->field[ 'id' ] . '-description_' . $x . '" placeholder="' . $placeholder . '" class="large-text" rows="6">' . esc_attr ( $slide[ 'description' ] ) . '</textarea></li>';
}
对此:
if ( $this->field[ 'show' ][ 'description' ] ) {
$placeholder = ( isset ( $this->field[ 'placeholder' ][ 'description' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'description' ] ) : __ ( 'Description', 'redux-framework' );
$editor_id = $this->field[ 'id' ] . '-description_' . $x;
echo '<li> '.wp_editor( $content, $editor_id ,array("textarea_name" => ''.$this->field[ 'name' ] . '[' . $x . '][description]' . $this->field['name_suffix'].'' ));'</li>';
}
所以,我在幻灯片中获取 wp_editors,但问题是,我无法保存任何内容,顺便说一句,每个动态生成的编辑器文本字段都有唯一的名称和 ID,就像在原始代码中一样。
更新
请注意,编辑器在页面刷新后不会保留内容,而是在第一次提交时存储数据。