在自定义小部件中嵌入所见即所得编辑器需要声明表单函数下的字段,这将在小部件中创建所见即所得编辑器。您可以定义参数,即要显示的所有特征。
public function form( $instance ) {
$rand = rand( 0, 999 );
$ed_id = $this->get_field_id( \'wp_editor_\' . $rand );
$ed_name = $this->get_field_name( \'wp_editor_\' . $rand );
$content = \'Hello World!\';
$editor_id = $ed_id;
$settings = array(\'media_buttons\' => true,\'textarea_rows\' => 4,\'textarea_name\' => $ed_name,\'teeny\' => true,);
wp_editor( $content, $editor_id, $settings );