wp_handle_upload хук-фильтрWP 2.1.0

Filters the data array for the uploaded file.

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

add_filter( 'wp_handle_upload', 'wp_kama_handle_upload_filter', 10, 2 );

/**
 * Function for `wp_handle_upload` filter-hook.
 * 
 * @param array  $upload  Array of upload data.
 * @param string $context The type of upload action. Values include 'upload' or 'sideload'.
 *
 * @return array
 */
function wp_kama_handle_upload_filter( $upload, $context ){

	// filter...
	return $upload;
}
$upload(массив)

Array of upload data.

  • file(строка)
    Filename of the newly-uploaded file.

  • url(строка)
    URL of the newly-uploaded file.

  • type(строка)
    Mime type of the newly-uploaded file.
$context(строка)
The type of upload action. Values include 'upload' or 'sideload'.

Список изменений

С версии 2.1.0 Введена.

Где вызывается хук

_wp_handle_upload()
wp_handle_upload
wp_upload_bits()
wp_handle_upload
wp-admin/includes/file.php 1066-1074
return apply_filters(
	'wp_handle_upload',
	array(
		'file' => $new_file,
		'url'  => $url,
		'type' => $type,
	),
	'wp_handle_sideload' === $action ? 'sideload' : 'upload'
);
wp-includes/functions.php 2977-2986
return apply_filters(
	'wp_handle_upload',
	array(
		'file'  => $new_file,
		'url'   => $url,
		'type'  => $wp_filetype['type'],
		'error' => false,
	),
	'sideload'
);

Где используется хук в WordPress

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