Пример #1
0
 public static function survey($atts)
 {
     global $Questions_FormProcess;
     $atts = shortcode_atts(array('id' => '', 'title' => __('Survey', 'questions-locale')), $atts);
     if ('' == $atts['id']) {
         _e('Please enter an id in the survey shortcode!', 'questions-locale');
         return;
     }
     if (!qu_form_exists($atts['id'])) {
         _e('Survey not found. Please enter another ID in your shortcode.', 'questions-locale');
         return;
     }
     return $Questions_FormProcess->show_survey($atts['id']);
 }
Пример #2
0
 /**
  * Processing entered data
  * @since 1.0.0
  */
 public function process_response()
 {
     global $questions_survey_id;
     // Form ID was posted or die
     if (!array_key_exists('questions_id', $_POST)) {
         return;
     }
     $questions_survey_id = $_POST['questions_id'];
     // WP Nonce Check
     if (!wp_verify_nonce($_POST['_wpnonce'], 'questions-' . $questions_survey_id)) {
         return;
     }
     // Survey exists or die
     if (!qu_form_exists($questions_survey_id)) {
         return;
     }
     // Checking restrictions
     if (TRUE !== $this->check_restrictions($questions_survey_id)) {
         return;
     }
     // Setting up session if not exists
     if (!isset($_SESSION)) {
         session_start();
     }
     // If session has data, get it!
     if (isset($_SESSION['questions_response'])) {
         $saved_response = $_SESSION['questions_response'][$questions_survey_id];
     }
     do_action('questions_before_process_response', $_POST);
     $response = array();
     $this->finished = FALSE;
     // Getting data of posted step
     $survey_response = array();
     if (array_key_exists('questions_response', $_POST)) {
         $survey_response = $_POST['questions_response'];
     }
     $survey_actual_step = (int) $_POST['questions_actual_step'];
     // Validating response values and setting up error variables
     $this->validate_response($questions_survey_id, $survey_response, $survey_actual_step);
     // Adding / merging Values to response var
     if (isset($saved_response)) {
         // Replacing old values by key
         if (is_array($survey_response) && count($survey_response) > 0) {
             foreach ($survey_response as $key => $answer) {
                 $saved_response[$key] = qu_prepare_post_data($answer);
             }
         }
         $response = $saved_response;
     } else {
         $response = $survey_response;
     }
     $response = apply_filters('questions_process_response', $response);
     // Storing values in Session
     $_SESSION['questions_response'][$questions_survey_id] = $response;
     $this->save_response();
     do_action('questions_after_process_response', $_POST);
 }