Skip to content

Allow prepared queries to be passed in via a variable #1331

Open
@johnbillion

Description

@johnbillion

Given the following code, a WordPress.WP.PreparedSQL.NotPrepared error is raised:

$query = $wpdb->prepare( "
	SELECT ID
	FROM {$wpdb->posts}
	WHERE post_type = %s
", $post_type );
$all_post_ids = $wpdb->get_col( $query );

The error is raised because the prepared query is passed in via a variable instead of prepare() being called directly inside get_col().

Is there a way that this format can be supported in WPCS?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions