當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WooThemes_Sensei_Utils::upload_file方法代碼示例

本文整理匯總了PHP中WooThemes_Sensei_Utils::upload_file方法的典型用法代碼示例。如果您正苦於以下問題:PHP WooThemes_Sensei_Utils::upload_file方法的具體用法?PHP WooThemes_Sensei_Utils::upload_file怎麽用?PHP WooThemes_Sensei_Utils::upload_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WooThemes_Sensei_Utils的用法示例。


在下文中一共展示了WooThemes_Sensei_Utils::upload_file方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepare_form_submitted_answers

 /**
  * This function converts the submitted array and makes it ready it for storage
  *
  * Creating a single array of all question types including file id's to be stored
  * as comment meta by the calling function.
  *
  * @since 1.7.4
  * @access public
  *
  * @param array $unprepared_answers
  * @param $files
  * @return array
  */
 public static function prepare_form_submitted_answers($unprepared_answers, $files)
 {
     global $woothemes_sensei;
     $prepared_answers = array();
     // validate incoming answers
     if (empty($unprepared_answers) || !is_array($unprepared_answers)) {
         return false;
     }
     // Loop through submitted quiz answers and save them appropriately
     foreach ($unprepared_answers as $question_id => $answer) {
         //get the current questions question type
         $question_type = $woothemes_sensei->question->get_question_type($question_id);
         // Sanitise answer
         if (0 == get_magic_quotes_gpc()) {
             $answer = wp_unslash($answer);
         }
         // compress the answer for saving
         if ('multi-line' == $question_type) {
             $answer = esc_html($answer);
         } elseif ('file-upload' == $question_type) {
             $file_key = 'file_upload_' . $question_id;
             if (isset($files[$file_key])) {
                 $attachment_id = WooThemes_Sensei_Utils::upload_file($files[$file_key]);
                 if ($attachment_id) {
                     $answer = $attachment_id;
                 }
             }
         }
         // end if
         $prepared_answers[$question_id] = base64_encode(maybe_serialize($answer));
     }
     // end for each $quiz_answers
     return $prepared_answers;
 }
開發者ID:mattytemple,項目名稱:YTC-Sensei,代碼行數:47,代碼來源:class-woothemes-sensei-quiz.php


注:本文中的WooThemes_Sensei_Utils::upload_file方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。