WebDevStudios / php-coding-standards

WebDevStudios PHP Coding Standards
9 stars 2 forks source link

Show warning if $wpdb use and no global $wpdb #10

Open aubreypwd opened 4 years ago

aubreypwd commented 4 years ago

Continuation of https://github.com/WebDevStudios/WDS-Coding-Standards/issues/77


If would be nice to catch these in-code, e.g.:

function method() {
    $wpdb->get_var( "SELECT ..." );
}

In the above example, a warning would show because you didn't add global $wpdb. Note this shouldn't happen if you use e.g. $this->wpdb or $object->wpdb, etc.