WC_Admin_Upload_Downloadable_Product::upload_dir()publicWC 1.0

Change upload dir for downloadable files.

Метод класса: WC_Admin_Upload_Downloadable_Product{}

Хуков нет.

Возвращает

Массив.

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

$WC_Admin_Upload_Downloadable_Product = new WC_Admin_Upload_Downloadable_Product();
$WC_Admin_Upload_Downloadable_Product->upload_dir( $pathdata );
$pathdata(массив) (обязательный)
Array of paths.

Код WC_Admin_Upload_Downloadable_Product::upload_dir() WC 9.4.2

public function upload_dir( $pathdata ) {
	// phpcs:disable WordPress.Security.NonceVerification.Missing
	if ( isset( $_POST['type'] ) && 'downloadable_product' === $_POST['type'] ) {

		if ( empty( $pathdata['subdir'] ) ) {
			$pathdata['path']   = $pathdata['path'] . '/woocommerce_uploads';
			$pathdata['url']    = $pathdata['url'] . '/woocommerce_uploads';
			$pathdata['subdir'] = '/woocommerce_uploads';
		} else {
			$new_subdir = '/woocommerce_uploads' . $pathdata['subdir'];

			$pathdata['path']   = str_replace( $pathdata['subdir'], $new_subdir, $pathdata['path'] );
			$pathdata['url']    = str_replace( $pathdata['subdir'], $new_subdir, $pathdata['url'] );
			$pathdata['subdir'] = str_replace( $pathdata['subdir'], $new_subdir, $pathdata['subdir'] );
		}
	}
	return $pathdata;
	// phpcs:enable WordPress.Security.NonceVerification.Missing
}