2

textarea (説明領域) の代わりに wp エディターを含めるために、スライドのデフォルト フィールド (スライド フィールド - Redux フレームワーク)をカスタマイズしようとしています。

元のファイルはこちら: 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