Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress使用设置API保存wp_编辑器内容_Wordpress_Wp Editor - Fatal编程技术网

Wordpress使用设置API保存wp_编辑器内容

Wordpress使用设置API保存wp_编辑器内容,wordpress,wp-editor,Wordpress,Wp Editor,我正在创建一个带有管理员设置页面的插件,我想使用设置API 我可以保存文本字段和复选框,但当我使用wp_编辑器添加设置字段时,它不会保存 我以前使用get_选项来实现这一点,但现在我想使用settings类和register_设置方法 这是我的代码: public function register_settings() { register_setting( 'eman_setting', 'eman_setting', array( $this, 'eman_validate_set

我正在创建一个带有管理员设置页面的插件,我想使用设置API

我可以保存文本字段和复选框,但当我使用wp_编辑器添加设置字段时,它不会保存

我以前使用get_选项来实现这一点,但现在我想使用settings类和register_设置方法

这是我的代码:

public function register_settings() {
    register_setting( 'eman_setting', 'eman_setting', array( $this, 'eman_validate_settings' ) );

    add_settings_field(
        'eman_dashboard_welcome',                      
        __( "", 'emanlang' ),                           
        array( $this, 'eman_dashboard_welcome_callback' ),   
        'management-settings',                          
        'eman_settings_section'         
    );  

}

public function eman_dashboard_welcome_callback() {
    //$content = 'Empty';
    $editor_id = 'textareadashboardwelcome';    
    $args = array('textarea_name' => 'eman_dashboard_welcome');

    if(! empty( $this->eman_setting['eman_dashboard_welcome'] ) ) {
        $content = $this->eman_setting['eman_dashboard_welcome'];
    } else {
        $content = 'The field is empty';
    }

    wp_editor( $content, $editor_id, $args );

    /** TESTING **/
    echo '<br /><b>testing textarea output: </b>'. $content .'<br /><br />';
    echo '<b>Complete settings array dump: </b><br />';
    echo var_dump($this->eman_setting);

}
保存表单后,数组仅包含3个字段,因此该数组甚至没有填充[eman_dashboard_welcome]

我尝试了许多可能的解决方案,比如添加以下jQuery:

$('#submit').mousedown( function() {
tinyMCE.triggerSave();
}); 
但什么都不管用。。。请帮助:-

找到了

解决方案:

Textarea/wp_编辑器“name”需要调用数组中的字段

就我而言:

$args = array('textarea_name' => 'eman_setting[eman_dashboard_welcome]');
wp_editor( $content, $editor_id, $args );
找到了

解决方案:

Textarea/wp_编辑器“name”需要调用数组中的字段

就我而言:

$args = array('textarea_name' => 'eman_setting[eman_dashboard_welcome]');
wp_editor( $content, $editor_id, $args );

固溶体。感谢你花时间回答自己的问题!固溶体。感谢你花时间回答自己的问题!