name = $name; $this->value = $value; $this->title = $title; $this->allow_empty = $allow_empty; $this->deprecated = $deprecated; } /** * */ public function validate($new_value) { return (bool) $new_value; } /** * * {@inheritDoc} * @see \mtekk\adminKit\setting\setting::get_opt_name() */ public function get_opt_name() { return 'b' . $this->get_name(); } /** * * {@inheritDoc} * @see mtekk_adminKit_setting::updateFromFormInput() */ public function maybe_update_from_form_input($input, $bool_ignore_missing = false) { //If the setting was in the input array, check if it is true or false if(isset($input[$this->get_opt_name()])) { if($input[$this->get_opt_name()] === true || $input[$this->get_opt_name()] === '1') { $newval = true; } //Treat anything that wasn't true as trying to set false else { $newval = false; } } //Normally checkbox inputs will be missing the setting if uncecked (treat as false) else { //If the value wasn't set, but we are to ignore missing inputs if($bool_ignore_missing) { return; } $newval = false; } $this->set_value($this->validate($newval)); } }