You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's perfectly valid code. However, it's more complicated than it needs to be. Remember that conditionals are going to return either true or false. There's no need for the if or else. You merely need one line of code to do the above.
A good rule of thumb in programming is that if you have an else in your code, you most likely don't need it.
I didn't want to point out any specific line numbers and files. This sort of thing is done quite a bit in the plugin. It's just extra, unnecessary code. When working with larger plugins, the less code, the better.
It's not something I'd try to fix all at once. Just keep this tip in mind while working on the plugin. If you come across something, fix it then.
The text was updated successfully, but these errors were encountered:
I'm looking over
includes/template-tags/helpers.php
right now and see a lot ofif
/else
code that looks like this:That's perfectly valid code. However, it's more complicated than it needs to be. Remember that conditionals are going to return either
true
orfalse
. There's no need for theif
orelse
. You merely need one line of code to do the above.Here's a different type of example from the same file:
Write it as (variable always goes on the right, by the way):
There's no need for the
else
statement there.A good rule of thumb in programming is that if you have an
else
in your code, you most likely don't need it.I didn't want to point out any specific line numbers and files. This sort of thing is done quite a bit in the plugin. It's just extra, unnecessary code. When working with larger plugins, the less code, the better.
It's not something I'd try to fix all at once. Just keep this tip in mind while working on the plugin. If you come across something, fix it then.
The text was updated successfully, but these errors were encountered: