/** * Collect metadata from all boxes. */ function save_post($post_id, $post) { if ('revision' == $post->post_type || defined('DOING_AJAX')) { return; } if (isset($_POST['p2p_connections'])) { // Loop through the hidden fields instead of through $_POST['p2p_meta'] because empty checkboxes send no data. foreach ($_POST['p2p_connections'] as $p2p_id) { $data = scbForms::get_value(array('p2p_meta', $p2p_id), $_POST, array()); $connection = p2p_get_connection($p2p_id); if (!$connection) { continue; } $fields = p2p_type($connection->p2p_type)->fields; foreach ($fields as $key => &$field) { $field['name'] = $key; } $data = scbForms::validate_post_data($fields, $data); scbForms::update_meta($fields, $data, $p2p_id, 'p2p'); } } // Ordering if (isset($_POST['p2p_order'])) { foreach ($_POST['p2p_order'] as $key => $list) { foreach ($list as $i => $p2p_id) { p2p_update_meta($p2p_id, $key, $i); } } } }
function settings_handler() { if (!isset($_POST['save_settings'])) { return; } $to_update = scbForms::validate_post_data($this->settings_fields); $this->options->update($to_update); $this->admin_msg(); }
static function handle_form() { if (empty($_POST['action']) || 'manage-escrow' != $_POST['action']) { return; } if (!wp_verify_nonce($_POST['_wpnonce'], 'app-manage-escrow')) { return; } $sanitized_user_meta = scbForms::validate_post_data(self::get_fields()); foreach ($sanitized_user_meta as $meta_key => $meta_value) { update_user_option(get_current_user_id(), $meta_key, $meta_value); } appthemes_add_notice('saved-escrow-settings', __('Settings Saved.', APP_TD), 'success'); }
function form_handler() { if (empty($_POST['action']) || !$this->tabs->contains($_POST['action'])) { return; } check_admin_referer($this->nonce); $form_fields = array(); foreach ($this->tab_sections[$_POST['action']] as $section) { $form_fields = array_merge($form_fields, $section['fields']); } $to_update = scbForms::validate_post_data($form_fields, null, $this->options->get()); $this->options->update($to_update); $this->admin_msg(); }
function form_handler() { if (empty($_POST['action']) || !$this->tabs->contains($_POST['action'])) { return; } check_admin_referer($this->nonce); $form_fields = array(); foreach ($this->tab_sections[$_POST['action']] as $section) { $form_fields = array_merge($form_fields, $section['fields']); } $to_update = scbForms::validate_post_data($form_fields, null, $this->options->get()); $this->options->update($to_update); do_action('tabs_' . $this->pagehook . '_form_handler', $this); add_action('admin_notices', array($this, 'admin_msg')); }
function form_handler() { if (empty($_POST['action']) || !$this->tabs->contains($_POST['action'])) { return; } check_admin_referer($this->nonce); foreach ($this->tab_sections[$_POST['action']] as &$section) { if (isset($section['options']) && is_a($section['options'], 'scbOptions')) { $options =& $section['options']; } else { $options =& $this->options; } $to_update = scbForms::validate_post_data($section['fields'], null, $options->get()); $options->update($to_update); } do_action('tabs_' . $this->pagehook . '_form_handler', $this); add_action('admin_notices', array($this, 'admin_msg')); }
/** * Saves metabox form data. * * @param int $user_id * * @return void */ public function save($user_id) { if (!current_user_can('edit_user', $user_id)) { return; } $this->user_id = $user_id; $form_fields = $this->form_fields(); $to_update = $this->before_save(scbForms::validate_post_data($form_fields), $user_id); $form_fields = $this->set_keys($form_fields); $this->validate_fields_data($to_update, $form_fields, $user_id); if (!empty($this->errors)) { return false; } foreach ($to_update as $key => $value) { update_user_meta($user_id, $key, $value); } }
/** * Validates and updates widget settings. * * @param array $new_instance New settings for this instance. * @param array $old_instance Old settings for this instance. * * @return array */ public function update($new_instance, $old_instance) { $form_fields = $this->form_fields(); $to_update = scbForms::validate_post_data($form_fields, $new_instance, $old_instance); return $to_update; }
protected function save($post_id) { $form_fields = $this->form_fields(); $to_update = scbForms::validate_post_data($form_fields); // Filter data $to_update = $this->before_save($to_update, $post_id); // Validate dataset $is_valid = $this->validate_post_data($to_update, $post_id); if ($is_valid instanceof WP_Error && $is_valid->get_error_codes()) { $error_data = array('fields' => $is_valid->get_error_codes(), 'data' => $to_update); update_post_meta($post_id, '_error_data_' . $this->id, $error_data); $location = add_query_arg('message', 1, get_edit_post_link($post_id, 'url')); wp_redirect(apply_filters('redirect_post_location', $location, $post_id)); exit; } foreach ($to_update as $key => $value) { update_post_meta($post_id, $key, $value); } }