WC_Admin_Upload_Downloadable_Product::update_filename()publicWC 4.0

Change filename for WooCommerce uploads and prepend unique chars for security.

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

Хуков нет.

Возвращает

Строку. New filename with unique hash.

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

$WC_Admin_Upload_Downloadable_Product = new WC_Admin_Upload_Downloadable_Product();
$WC_Admin_Upload_Downloadable_Product->update_filename( $full_filename, $ext, $dir );
$full_filename(строка) (обязательный)
Original filename.
$ext(строка) (обязательный)
Extension of file.
$dir(строка) (обязательный)
Directory path.

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

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

Код WC_Admin_Upload_Downloadable_Product::update_filename() WC 9.4.2

public function update_filename( $full_filename, $ext, $dir ) {
	// phpcs:disable WordPress.Security.NonceVerification.Missing
	if ( ! isset( $_POST['type'] ) || ! 'downloadable_product' === $_POST['type'] ) {
		return $full_filename;
	}

	if ( ! strpos( $dir, 'woocommerce_uploads' ) ) {
		return $full_filename;
	}

	if ( 'no' === get_option( 'woocommerce_downloads_add_hash_to_filename' ) ) {
		return $full_filename;
	}

	return $this->unique_filename( $full_filename, $ext );
	// phpcs:enable WordPress.Security.NonceVerification.Missing
}