WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

Snoopy::_prepare_post_body() public WP 1.0

{} Это метод класса: Snoopy{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$Snoopy = new Snoopy();
$Snoopy->_prepare_post_body( $formvars, $formfiles );

Код Snoopy::_prepare_post_body() WP 5.5.3

<?php
function _prepare_post_body($formvars, $formfiles)
{
	settype($formvars, "array");
	settype($formfiles, "array");
	$postdata = '';

	if (count($formvars) == 0 && count($formfiles) == 0)
		return;

	switch ($this->_submit_type) {
		case "application/x-www-form-urlencoded":
			reset($formvars);
			foreach ( $formvars as $key => $val ) {
				if (is_array($val) || is_object($val)) {
					foreach ( $val as $cur_key => $cur_val ) {
						$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
					}
				} else
					$postdata .= urlencode($key)."=".urlencode($val)."&";
			}
			break;

		case "multipart/form-data":
			$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));

			reset($formvars);
			foreach ( $formvars as $key => $val ) {
				if (is_array($val) || is_object($val)) {
					foreach ( $val as $cur_key => $cur_val ) {
						$postdata .= "--".$this->_mime_boundary."\r\n";
						$postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
						$postdata .= "$cur_val\r\n";
					}
				} else {
					$postdata .= "--".$this->_mime_boundary."\r\n";
					$postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
					$postdata .= "$val\r\n";
				}
			}

			reset($formfiles);
			foreach ( $formfiles as $field_name => $file_names ) {
				settype($file_names, "array");
				foreach ( $file_names as $file_name ) {
					if (!is_readable($file_name)) continue;

					$fp = fopen($file_name, "r");
					$file_content = fread($fp, filesize($file_name));
					fclose($fp);
					$base_name = basename($file_name);

					$postdata .= "--".$this->_mime_boundary."\r\n";
					$postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n";
					$postdata .= "$file_content\r\n";
				}
			}
			$postdata .= "--".$this->_mime_boundary."--\r\n";
			break;
	}

	return $postdata;
}