The function for the pre_get_posts
action uses a WP_Query object (http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts)
When using functions such as get_posts or classes such as WP_Query and WP_User_Query, WordPress takes care of the necessary sanitization in querying the database. However, when retrieving data from a custom table, or otherwise performing a direct SQL query on the database – proper sanitization is then up to you.
— Code Tuts+: Data Sanitization and Validation With WordPress
So in this case, you do not have to escape the query vars.
Related Posts:
- What characters do I need to escape in XML documents?
- What characters must be escaped in HTML 5?
- How can I selectively escape percent (%) in Python strings?
- How do I escape a single quote in jQuery?
- Escape Character in SQL Server
- How to escape apostrophe (‘) in MySql?
- Should HTML output be passed through esc_html() AND wp_kses()?
- How to prevent escaping when saving HTML code in an option value?
- esc_attr / esc_html / esc_url in echos
- When do I need to use esc_html()? [duplicate]
- what’s different between esc_attr, htmlspecialchars and htmlentities
- Allow all attributes in $allowedposttags tags
- When outputting a static string to the page, is it necessary to escape the output?
- How Flexible are the WordPress Coding Standards for PHPCS?
- why is esc_html() returning nothing given a string containing a high-bit character?
- How to properly escape a translated string?
- Translate a Constant while appeasing WordPress PHPCS
- Using esc_url() on a url more than once
- Do I need to escape get_theme_mod(‘url’) / (‘mail’) with esc_url?
- How to allow   with wp_kses()?
- Using esc_attr_e
- Why esc_html_() is not used on every text that has a translation (on Twenty Twenty One)?
- Escaping crashes my output
- How to safely escape the title attribute
- How to safely escape data that contains HTML attributes
- Can wp_strip_all_tags be used as a substitute for esc_url, esc_attr & esc_html?
- Echoing a URL to a link
- wp_kses_post escaping doesn’t appear to work as described?
- file_get_contents | escaping doesnt show the page
- Help about Escaping
- How to keep specific tag from an html string?
- Escaping Issues
- Escaping and Special Characters (e.g. &)
- Escaping get_option( ‘time_format’ ) is nesserary?
- How to Git stash pop specific stash in 1.8.3?
- What are all the escape characters?
- Which characters need to be escaped when using Bash?
- Best Practice for PHP
- Escaping and sanitizing SVGs in metabox textarea
- Difference between esc_url() and esc_url_raw()
- What to use instead of wp_kses() in user output
- How to escape custom css?
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- PHP Coding Standards, Widgets and Sanitization
- Should messages in WP_Error already be html escaped?
- Do you need to escape hard coded plain text?
- Passing Variable as URL Parameter — Security concerns?
- Custom Rewrite with Query vars
- Rewrite Rule for Custom Page with Query Vars in URL
- How do I stop HTML entities in a custom meta box from being un-htmlentitied?
- WordPress query through Products variation stock [closed]
- Why should I escape translatable strings? and how shall i do that?
- Do I need to use the esc_html() function on hard coded links?
- Determine WP_Query parameters from URL
- What does query_var do in register_taxonomy
- Rewrite URL Parameter And Force ‘Pretty’ Permalink
- Why query_vars get altered in WP_Query Object?
- add_rewrite_rule query_var not being set
- How Could I sanitize the receive data from this code
- When I re-save a post with [code] sections, the entities are double-escaped (> becomes > etc)
- Escape post image attachments added to template
- wp_query not searching with apostrophe
- Rewrite rule to prettify two $_GET variables while in a new endpoint from a page
- Rewriting get_next_posts_link() for custom loop
- Which escape function to use when escaping an email or plain text?
- Base64 & JSON Encode array in PHP, use as HTML data attribute, decode and parse in JavaScript …. with proper Escaping
- Something is unescaping all html entities before output to browser [closed]
- Securing/Escaping Output of file content – reading via fread() in PHP
- Redirect Uploads Folder to Query Vars in WordPress
- add_rewrite_rule permalinks break in WordPress 4.5
- How to: wordpress job listing and candidates details
- Query arg not available on init
- Unexpected esc_html and esc_attr behaviour
- Integer based rewrite isn’t recognized for value of 1
- HTML escaping data with ajax requests
- should I escape a literal url added in functions.php
- Query_vars support in Rest API
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- How to allow single quote with esc_html__() without sprintf()
- Redirect old query string URLs to new add_rewrite_rule URL
- Pass form input via url variable
- Add pagination to a template loaded by query variable
- Wrapping add_query_arg with esc_url not working
- wordpress post not showing my “” text>?
- WordPress add a rewrite rule to a page to accept a GET variable
- Custom query_var to get URL paramater not working
- Custom permalink question
- CPT year wise archive based on custom date Field
- Single Post (CPT) in two pages – Normal and Extended
- Last query_var not working with rewritten URL
- How to make MySQL search queries with quotes
- Escaping WP_Query tax_query when term has special character(s)
- Escape html structure in php
- site_url() returns with additional backslashes
- Rewrite URL to plugin file
- Allow iframe in custom meta box
- Need help with regex
- query_vars doesn’t return query string (trying to get data from $wpdb)
- Escaping data from database (users table) is necessary?
- esc_url, esc_url_raw or sanitize_url?