/** * When the page or tab is saved, save a single custom option contained in the page or tab. * * @since 0.1.0 * @param array $element The element structure. * @param string|array $element_value The element value. */ protected function _save_single_field($element, $value) { $value = Ev_Field::sanitize($element, $value); ev_update_option($element['handle'], $value); }
/** * Save a color preset. * * @since 0.4.0 */ function ev_color_save_preset() { if (!ev_is_post_nonce_valid('ev_color_save_preset')) { die; } $hex = isset($_POST['hex']) ? sanitize_text_field($_POST['hex']) : false; $id = isset($_POST['id']) ? sanitize_text_field($_POST['id']) : false; $name = isset($_POST['name']) ? sanitize_text_field($_POST['name']) : $hex; if (!$hex || !$id) { die; } $key = 'color_presets'; $presets = ev_get_option($key); if (!isset($presets['user'])) { $presets['user'] = array(); } $presets['user'][] = array('user' => true, 'hex' => $hex, 'label' => $name, 'id' => $id); ev_update_option($key, $presets); die; }