redacademy / rethink-spring-2019

http://rethink.van.cp.academy.red
0 stars 0 forks source link

Code repetition #15

Open benorgan opened 5 years ago

benorgan commented 5 years ago

https://github.com/redacademy/rethink-spring-2019/blob/307420d5cbf582d8ec53264cf482a660768a4ccb/themes/rcforward/single-charity.php#L69-L95

Here you've repeated quite a bit of code in the two conditional code blocks. You'd be better off using the conditional to just set a variable (i.e. the name of the class) and then outputting the markup using this variable. You can also do the same thing for the final block of code by setting a boolean and then doing another if statement when you're outputting the markup.

The idea is to just write the markup once (rather than repeating it) and then use variables for the variable parts (i.e. classnames)