/** * Upload file via ajax * * No nonce field since the form may be statically cached. */ public function upload_file() { $data = array('files' => array()); if (!empty($_FILES)) { foreach ($_FILES as $file_key => $file) { $files_to_upload = event_manager_prepare_uploaded_files($file); foreach ($files_to_upload as $file_to_upload) { $uploaded_file = event_manager_upload_file($file_to_upload, array('file_key' => $file_key)); if (is_wp_error($uploaded_file)) { $data['files'][] = array('error' => $uploaded_file->get_error_message()); } else { $data['files'][] = $uploaded_file; } } } } wp_send_json($data); }
// Decode URLs if (is_string($value) && (strstr($value, 'http:') || strstr($value, 'https:'))) { $value = urldecode($value); } // Santize value $value = is_array($value) ? array_map(array($this, 'sanitize_posted_field'), $value) : sanitize_text_field(stripslashes(trim($value))); return $value; } /** * Get the value of a posted field * @param string $key * @param array $field * @return string|array */ protected function get_posted_field($key, $field) { return isset($_POST[$key]) ? $this->sanitize_posted_field($_POST[$key]) : ''; } /** * Get the value of a posted multiselect field * @param string $key * @param array $field * @return array */ protected function get_posted_multiselect_field($key, $field) {