/** * Set the defaults on plugin activation. */ function set_defaults() { // First install. if (!$this->options) { $defaults = get_wpui_default_options(); update_option('wpUI_options', $defaults); } else { // Append the new options. $oldopts = get_option('wpUI_options'); $newdefs = get_wpui_default_options(); foreach ($newdefs as $def => $val) { // Options not set. if (!isset($oldopts[$def])) { if (is_array($newdefs[$def])) { $oldopts[$def] = array(); } $oldopts[$def] = $newdefs[$def]; } } /* $oldopts = array_merge( $oldopts, $newdefs );*/ update_option('wpUI_options', $oldopts); $this->clean_up_post_meta(); } // End if ( !this->options ) }
/** * Set the defaults on plugin activation. */ function set_defaults() { $options = get_option('wpUI_options', false); // First install. if (!$options) { $options = get_wpui_default_options(); // update_option( 'wpUI_options', $defaults ); } else { $defaults = get_wpui_default_options(); $options = array_merge($options, $defaults); } // End if ( !this->options ) update_option('wpUI_options', $options); }
public function validate_options($input) { $new_input = $input; $db_options = get_option('wpUI_options'); $reset = !empty($input['reset']) ? true : false; if ($reset) { $defaults = get_wpui_default_options(); return $defaults; } $reset_tmpls = preg_grep_keys('/^reset_post_template_[3-9]{1,2}$/', $input); if ($reset_tmpls) { foreach ($reset_tmpls as $tmpls => $data) { $template_num = str_ireplace('reset_', '', $tmpls); unset($new_input[$template_num]); } } if (!empty($input['script_conditionals'])) { $cond = $input['script_conditionals']; if (preg_match('/(x=x\\s--|1=1|Or\\s?1=1\\s--|$_GET|SELECT|DROP\\sTABLE|base64)/im', $cond)) { wp_die('UN SAFE code detected in the conditionals.'); } } foreach ($this->fields as $option => $opt) { if ($opt['type'] == 'checkbox' && !isset($input[$opt['id']])) { $new_input[$opt['id']] = 'off'; } } $new_input['version'] = WPUI_VER; /* die();*/ /* parent::validate_options( $input );*/ return $new_input; }