wpdevshedcom / WP-Image-Embeds

WP Image Embeds Plugin Repository
0 stars 0 forks source link

Yoda conditions #18

Open justintadlock opened 8 years ago

justintadlock commented 8 years ago

When doing logical comparisons, use Yoda conditions. For example in the ih_social_share_sanitize_checkbox() method, you have this line of code:

if ( $input == 1 ) {

Ideally, that would be:

if ( 1 == $input ) {

See: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#yoda-conditions

Also, you could simplify that entire function's code:

if ( $input == 1 ) {
    return 1;
} else {
    return '';
}

...down to this:

return 1 == $input ? 1 : '';