samedi 19 décembre 2015

how to get wp_editor to save data in plugin admin page

I'm trying to use plugin settings api to add wp_editor, but the text/html is not saving.

// add the admin settings and such
add_action('admin_init', 'wp_shabbat_admin_init');
function wp_shabbat_admin_init(){
register_setting( 'wp_shabbat_settings', 'wp_shabbat_settings', 'wp_shabbat_settings_validate');
add_settings_field('wp_shabbat_user_custom_text', __('Enter your message','WP-Shabbat'), 'wp_shabbat_user_custom_text', 'wp_shabbat', 'wp_shabbat_main');

function wp_shabbat_user_custom_text() {
$options = get_option('wp_shabbat_settings');
$settings  = array('media_buttons' => "false",'textarea_rows' => "5",'textarea_name' => 'user_cutom _text_msg');
wp_editor( $options['user_custom_text'],'user_custom_text', $settings  );}  

// validate  
function wp_shabbat_settings_validate() {
$options = get_option('wp_shabbat_settings');
$user_custom_text = $input['user_custom_text'];

if ( empty($user_custom_text) ){
$options['user_custom_text'] = $user_custom_text;
}else{
$options['user_custom_text'] =  __('Enter your own text','WP-Shabbat');// as set when the plugin activated



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire