plugin development code standard not matching for SQL query

To be honest, I’m not sure if you can trust this plugin 100%.

I run the test on my plugin, that is already in repo, and it showed me few false alarms. I put your code inside my plugin code and run the test again and… it didn’t show me the error you have.

Also, my Code Sniffer in Visual Studio code shows different errors that are not reported by the plugin:

  • You do not need to use double quote
  • You are not using Yoda condition
  • %i is available only for WordPress 6.2 and above, so it is safer to use %s
  • = are not aligned

Code after changes:

    global $wpdb;
    $table_name        = $wpdb->prefix . 'my_table';
    $current_post_type = get_post_type();
    $current_post_id   = get_the_ID(); // this one is unused

    $script_column = 'header_script';

    $cache_key = 'my_custom_scripts_cache_' . $current_post_type;
    $scripts   = wp_cache_get( $cache_key );

    if ( false === $scripts ) {
        $scripts = $wpdb->get_results(
            $wpdb->prepare(
                'SELECT %s, postsid_to_exclude, inclscripttag_header, inclscripttag_footer FROM %s WHERE FIND_IN_SET(%s, target_post_types) AND status = %d',
                $script_column,
                $table_name,
                $current_post_type,
                1
            )
        ); /* db call ok; no cache ok */
        wp_cache_set( $cache_key, $scripts );
    }

(I recommend to use Code Sniffer inside your IDE, will save you time.

I’m using this one:
https://github.com/wongjn/vscode-php-sniffer
And you need to use it with WordPress Coding Standards (WPCS):
https://github.com/WordPress/WordPress-Coding-Standards?tab=readme-ov-file

deneme bonusu veren sitelerbahis siteleripulibet girişdeneme bonusutürkçe altyazılı pornocanlı bahis casinocanlı bahis casino siteleriOnwin Güncel Girişholiganbetholiganbet girişholiganbet güncel girişnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewslandorbet