本文整理汇总了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;
}