Be sure to understand what is going on here.
You are using a LCD display that typically contains INPUT only port pins. The STM32 CPU or any other must be configured for OUTPUT only GPIO direction for the port pins. Typically called push-pull meaning that if you output a "1" (HIGH), the port pin will be raised to +3v3 (since STM32 is a 3v3 CPU on the port pins.
If you output a "0" (LOW), the voltage on the port pin is often close to 0 volts.
Guessing that the initialization was only for D4..D7 pins due to the original code by the author configured the LCD display to use 4 bit mode so D0..D3 were not used at all in the original reference design.
Since this project is for use with 8 bit mode, the init code is required to expand to use the full 8 bits of Port D on the CPU.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.