• Hello everyone,
    I’m here because I’ve a problem about the option page for my plugin. I just want to draw 7 checkboxes, and to save their values in the option array shareit-options. I tried many different things but nothing works. I give you a piece of the code I tried :

    add_action('admin_init', 'shareit_admin_init');
    function shareit_admin_init(){
    register_setting( 'shareit_options', 'shareit_options', 'shareit_options_validate' );
    add_settings_section('shareit_main', 'Boutons de partage à afficher', 'shareit_section_text', __FILE__);
    add_settings_field('chkbx1', 'Twitter', 'shareit_setting1', __FILE__, 'shareit_main');
    }
    
    function shareit_section_text() {
    echo '';
    }
    
    function shareit_setting1() {
    $options = get_option('shareit_options');
    if($options['chkbx1']) { $checked = ' checked="checked" '; }
    echo "<input ".$checked." id='chkbx1' name='chkbx1' type='checkbox' />";
    }
    
    function shareit_options_validate($input) {
    return $input;
    }
    
    register_activation_hook(__FILE__, 'add_defaults_fn');
    
    function add_defaults_fn() {
    $arr = array("twitter" => "on");
    update_option('shareit_options', $arr);
    }

    Thanks for help!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Plugin and option page’ is closed to new replies.