WP HOOKS
filtrod 2.0.0

upload_dir

Args 1Plik wp-includes/functions.phpDokumentacja WP ↗

Opis

Zmienia katalog docelowy uploadów.

Przykład użycia

add_filter( 'upload_dir', ... )php
add_filter( 'upload_dir', 'wpdocs_upload_dir' );

function wpdocs_upload_dir( $upload ) {
	$upload['subdir'] = '/custom/' . gmdate( 'Y/m' );
	$upload['path']   = $upload['basedir'] . $upload['subdir'];
	$upload['url']    = $upload['baseurl'] . $upload['subdir'];

	return $upload;
}

Parametry

ParametrTypOpis
$uploadsarray{ Array of information about the upload directory. @type string $path Base directory and subdirectory or full path to upload directory. @type string $url Base URL and subdirectory or absolute URL to upload directory. @type string $subdir Subdirectory if uploads use year/month folders option is on. @type string $basedir Path without subdir. @type string $baseurl URL path without subdir. @type string|false $error False or error message. }

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej
add_filter( 'upload_dir', 'twoja_funkcja' );

function twoja_funkcja($param_1) {
	// Twój kod
}

Popularne w tej kategorii