如何为 wordpress WP_QUERY 清理 $_POST?

Ray*_*ger 6 php wordpress advanced-custom-fields

有谁知道如何清理$_POSTfor wordpress?或者它在我使用时已经消毒了WP_QUERY?谢谢!

我在想我是使用mysql_escape()还是esc_sql()[wordpress 功能]。

function checkIfEmailAndPasswordHaveUser( $email, $password ) {   

$args = array(
    'post_type'  => 'my_custom_post_type',
    'meta_query' => array(
        array(
            'key'     => 'email',
            'value'   => $email
        ),
        array(
            'key'       => 'password',
            'value'     => $password
        ),
    ),
);

$query = new WP_Query( $args );
    if( !$query->have_posts() ) {
        return false;
    } else {
        // return the user's ID
        return $query->posts[0]->ID;
    }
}

$post_user_email        = trim( $_POST['user_email'] );
$post_user_password     = trim( $_POST['user_password'] );

// check if user_id exist
$result = checkIfEmailAndPasswordHaveUser($post_user_email, $post_user_password);
Run Code Online (Sandbox Code Playgroud)

Ray*_*ger 6

原来 WP 会自动对其进行消毒。