2

我正在尝试自定义幻灯片默认字段(幻灯片字段 - Redux 框架)以包含 wp 编辑器而不是 textarea(描述区域)

原始文件在这里:https ://raw.githubusercontent.com/ReduxFramework/redux-framework/master/ReduxCore/inc/fields/slides/field_slides.php

到目前为止,我已经更改了这部分代码

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,就像在原始代码中一样。

更新

请注意,编辑器在页面刷新后不会保留内容,而是在第一次提交时存储数据。

4

1 回答 1

4

请参阅:http ://codex.wordpress.org/Function_Reference/wp_editor

wp_editor 采用三个参数。您的代码中有四个显示。我很惊讶这并没有触发错误或警告。

所以,改变这个

echo '<li> '.wp_editor( $content, $editor_id, '',array("textarea_name" => ''.$this->field[ 'name' ] . '[' . $x . '][description]' . $this->field['name_suffix'].'' ));'</li>';

}

对此

echo '<li> '.wp_editor( $content, $editor_id, array("textarea_name" => ''.$this->field[ 'name' ] . '[' . $x . '][description]' . $this->field['name_suffix'].'' ));'</li>';

}

于 2014-12-29T03:10:16.990 回答