function ninja_forms_field_shortcode($atts) { global $ninja_forms_processing; $field_id = $atts['id']; if (is_object($ninja_forms_processing)) { $value = $ninja_forms_processing->get_field_value($field_id); $value = apply_filters('ninja_forms_field_shortcode', $value, $atts); if (is_array($value)) { $value = implode(',', $value); } } else { $value = ''; } return nf_wp_kses_post_deep($value); }
/** * Save our submission user values * * @access public * @since 2.7 * @return void */ public function save_sub($sub_id, $post) { global $pagenow; if (!isset($_POST['nf_edit_sub']) || $_POST['nf_edit_sub'] != 1) { return $sub_id; } // verify if this is an auto save routine. // If it is our form has not been submitted, so we dont want to do anything if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $sub_id; } if ($pagenow != 'post.php') { return $sub_id; } if ($post->post_type != 'nf_sub') { return $sub_id; } /* Get the post type object. */ $post_type = get_post_type_object($post->post_type); /* Check if the current user has permission to edit the post. */ if (!current_user_can($post_type->cap->edit_post, $sub_id)) { return $sub_id; } foreach ($_POST['fields'] as $field_id => $user_value) { $user_value = nf_wp_kses_post_deep(apply_filters('nf_edit_sub_user_value', $user_value, $field_id, $sub_id)); Ninja_Forms()->sub($sub_id)->update_field($field_id, $user_value); } set_transient('nf_sub_edit_ref', $_REQUEST['ref']); }
/** * Add the submitted vars to $this->data['fields']. * Also runs any functions registered to the field's pre_process hook. * * */ function setup_submitted_vars() { global $ninja_forms_fields, $wp; $form_ID = $this->data['form_ID']; //Get our plugin settings $plugin_settings = nf_get_settings(); $req_field_error = __($plugin_settings['req_field_error'], 'ninja-forms'); if (empty($this->data)) { return ''; } $this->data['action'] = 'submit'; $this->data['form']['form_url'] = $this->get_current_url(); $transient_id = Ninja_Forms()->session->get('nf_transient_id'); $cache = $transient_id ? get_transient($transient_id) : null; // If we have fields in our $_POST object, then loop through the $_POST'd field values and add them to our global variable. if (isset($_POST['_ninja_forms_display_submit']) or isset($_POST['_ninja_forms_edit_sub'])) { $field_results = ninja_forms_get_fields_by_form_id($form_ID); //$field_results = apply_filters('ninja_forms_display_fields_array', $field_results, $form_ID); foreach ($field_results as $field) { $data = $field['data']; $field_id = $field['id']; $field_type = $field['type']; if (isset($_POST['ninja_forms_field_' . $field_id])) { $val = ninja_forms_stripslashes_deep($_POST['ninja_forms_field_' . $field_id]); $this->data['submitted_fields'][] = $field_id; } else { $val = false; } $val = nf_wp_kses_post_deep($val); $this->data['fields'][$field_id] = $val; $field_row = ninja_forms_get_field_by_id($field_id); $field_row['data']['field_class'] = 'ninja-forms-field'; $this->data['field_data'][$field_id] = $field_row; } foreach ($_POST as $key => $val) { if (substr($key, 0, 1) == '_') { $this->data['extra'][$key] = $val; } } //Grab the form info from the database and store it in our global form variables. $form_row = ninja_forms_get_form_by_id($form_ID); $form_data = $form_row['data']; if (isset($_REQUEST['_sub_id']) and !empty($_REQUEST['_sub_id'])) { $form_data['sub_id'] = absint($_REQUEST['_sub_id']); } else { $form_data['sub_id'] = ''; } //Loop through the form data and set the global $ninja_form_data variable. if (is_array($form_data) and !empty($form_data)) { foreach ($form_data as $key => $val) { if (!is_array($val)) { $value = stripslashes($val); $value = nf_wp_kses_post_deep($value); //$value = htmlspecialchars($value); } else { $value = nf_wp_kses_post_deep($val); } $this->data['form'][$key] = $value; } $this->data['form']['admin_attachments'] = array(); $this->data['form']['user_attachments'] = array(); } } else { if ($cache !== false) { // Check to see if we have cached values from a submission. if (is_array($cache['field_values'])) { // We do have a submission contained in our cache. We'll populate the field values with that data. foreach ($cache['field_values'] as $field_id => $val) { $field_row = ninja_forms_get_field_by_id($field_id); if (is_array($field_row) and !empty($field_row)) { if (isset($field_row['type'])) { $field_type = $field_row['type']; } else { $field_type = ''; } if (isset($field_row['data']['req'])) { $req = $field_row['data']['req']; } else { $req = ''; } $val = ninja_forms_stripslashes_deep($val); $val = nf_wp_kses_post_deep($val); $this->data['fields'][$field_id] = $val; if (isset($cache['field_settings'][$field_id])) { $field_row = $cache['field_settings'][$field_id]; } else { $field_row = ninja_forms_get_field_by_id($field_id); } $field_row['data']['field_class'] = 'ninja-forms-field'; $this->data['field_data'][$field_id] = $field_row; } } } $this->data['form'] = $cache['form_settings']; $this->data['success'] = $cache['success_msgs']; $this->data['errors'] = $cache['error_msgs']; $this->data['extra'] = $cache['extra_values']; } } }
/** * Save our notifications admin. * * @access public * * @since 2.8 * @return void */ public function save_admin($form_id, $data) { if (!isset($data['notification_id']) || empty($data['notification_id'])) { return false; } $n_id = $data['notification_id']; $settings = $data['settings']; if ('new' == $n_id) { $type = $settings['type']; $n_id = $this->create($form_id); $new = true; } else { $type = Ninja_Forms()->notification($n_id)->type; $new = false; } $data = Ninja_Forms()->notification_types[$type]->save_admin($n_id, $data); foreach ($settings as $meta_key => $meta_value) { nf_update_object_meta($n_id, $meta_key, nf_wp_kses_post_deep($meta_value)); } do_action('nf_save_notification', $n_id, $data, $new); if ($new) { $redirect = esc_url_raw(remove_query_arg(array('notification-action'))); $redirect = esc_url_raw(add_query_arg(array('id' => $n_id, 'notification-action' => 'edit', 'update_message' => urlencode(__('Action Updated', 'ninja-forms'))), $redirect)); wp_redirect($redirect); die; } return __('Action Updated', 'ninja-forms'); }