Exemple #1
0
 /**
  * Returns array of appreciations for this game
  * @return array of ::Appreciation
  */
 private function fetchAppreciations()
 {
     global $wpdb;
     // Fetch from DB
     $row = $wpdb->get_results($wpdb->prepare('SELECT id FROM ' . WPViralQuiz::getTableName('appreciations') . ' WHERE quizId = %d', $this->id));
     // No appreciations
     if (empty($row)) {
         return array();
     }
     $appreciations = array();
     foreach ($row as $appreciation) {
         $app = new WPVQAppreciation();
         $app->load($appreciation->id);
         $appreciations[] = $app;
     }
     return $appreciations;
 }
         $i++;
     }
 }
 // end of tab=QUESTIONS
 /**
  * ================================================
  * 		      APPRECIATIONS PROCESS
  * ================================================
  */
 if ($activeTab == 'appreciations') {
     // Delete appreciations if we need to
     $deleteAppreciations = array_filter(explode(',', $_POST['deleteAppreciations']));
     foreach ($deleteAppreciations as $appreciationId) {
         $appreciation = new WPVQAppreciation();
         try {
             $appreciation->load(intval($appreciationId))->delete();
         } catch (Exception $e) {
         }
     }
     // If Personality Quizz
     // => add appreciations
     if ($quizType == 'WPVQGamePersonality' && isset($_POST['vqappreciations'])) {
         foreach ($_POST['vqappreciations'] as $appreciation) {
             // Empty appreciation
             if ($appreciation['content'] == '' && $appreciation['label'] == '') {
                 continue;
             }
             $param = array();
             // Wordpress addslashes to $_POST by default. But in the case of appreciation,
             // there is an issue with json_encode and slashes. We have to remove slashes here.
             $appreciation['label'] = sanitize_text_field(stripslashes_deep($appreciation['label']));