There are several things wrong with your code
-
The is no need for translation there. The message should have been translated before it is being passed to that function. At that function there is actually no context at all to create any different translation than
%s
-
Escaping should happen at the output. You should escape the result of the
sprintf
and the translation.
And keep in mind that WPCS is a tool to help you, not the bible. At least at its current stage it lacks too many feature to just blindly follow it all the time. Some of the errors it emits right now are due to bad parsing of modern PHP or lacking features, so if you are 100% sure that in your specific case %s
should be translatable go with it.
Related Posts:
- Running WP Cron on multisite the right way
- Why isn’t WordPress part of Framework Interop Group?
- WP-CLI – Selecting PHP version
- When to use Exceptions vs Error Objects vs just plain false/null
- WordPress and event-driven programming – what is it about?
- WP CLI info showing correct PHP binary but wrong version of PHP
- Utilize WP-CLI from inside WordPress, not SSH
- Setting Up PHPUnit tests for WP development on Windows
- How to set up phpcs with WordPress coding standard with PHP8?
- Configuring WP-CLI on Windows 10
- Different output from WP-CLI in bash vs PHP exec()
- Is it better to create a function or a variable for current_theme_supports?
- wp search-replace on database returns PHP fatal error: Array and string offset access syntax with curly braces is no longer supported
- PHP Parse error on WP-CLI, not on web server
- WP-CLi PHP Warning: mysqli_query(): (HY000/1356): View During Search Replace
- call to undefined function mysql_connect
- Should I use wp_cache in my plugin to make it faster?
- How come there is no error if I upgrade WordPress core after locking .htaccess permissions to 644?
- Full search and replace isn’t enough to make all pictures to be loaded with https
- How can one use variables in a template or template part without polluting the global scope?
- Cannot register a custom WP-CLI command
- Uncaught Error: Class ‘WP_Upgrader_Skin’ not found
- WP-CLI PHP Deprecated Warning
- Run a WP-CLI command from within PHP without using shell_exec()
- Running WP-Cron on Multisite networks the right way?
- How to send form data from WordPress (Meta Box) to an OData service?
- How to Configure Events List in WordPress to Disappear Event Once Date is Past
- Removing WordPress Footer -without access to PHP code?
- dynamic page using php from sql database
- Upload non-featured image to image field
- Usage of call back function of add_meta_box()
- Building a REST API for your web app exposes primary keys of DB records?
- WordPress get_media_embedded
- Change product_base programmatically
- wp_delete_comment takes two tries to delete – then deletes all comments
- php redirect with custom user roles set and working but redirect not working for when users are logged in
- how to get serialized post meta
- Hide Heading if ACF Field is empty
- Scheduling an event inside plugin class is not working
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- How to set a template with wp_insert_post
- WordPress Custom SQL Table with UserID Filter for results
- Automatically add images to a menu
- Display Yoast meta-description `wpseo_desc` within loop of categories and fail silently if no data is set [closed]
- Get access to variable from previous pageview, excluding ajax-calls
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Permission callback to check if user has application password
- Load Posts on Click via Ajax into a DIV
- How to catch wordpress post ID when it’s published
- calling a custom field value inside functions.php
- What is the best way to define constant options for a theme?
- WordPress redirect redirecting too many times or not at all
- Can’t retrieve element with WordPress default @fetch_rss();
- set post limit at load more ajax wordpress
- I have a snippet to redirect all users to a maintenance page. How do I exclude users with admin role?
- php esc_html_e with an html link inside not working
- How to filter custom taxonomy term name, slug, and description?
- An audio player that showcase a random song from playlist every 24h [closed]
- how to prevent wordpress admin from logging in via woocommerce my-account page
- get_the_ID() in the footer returns wrong value
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- Trouble inputting variable into WP query
- How to get the last category name of a child category?
- Add html link in functions.php files of the theme
- How can I add a UTM tag with PHP code to pick up the post slug dynamically in the UTM?
- How do I include SVG file used as featured image?
- Use value from Ajax call in PHP function
- require_once() if a product in woocommerce contains a tag [closed]
- the_posts_pagination() not working in wpquery
- Automatic excerpt is not shown with the_excerpt() command
- Using ob_start and ob_get_clean with wordpress shortcode
- Change “No Comments” link to “My String” on Blog Post (Find Snippet in Code or use CSS, PHP Solution) [closed]
- Return product description
- How to add the sidebar to all the pages except the home page? [closed]
- Header not properly displaying on archive.php
- Custom meta box values are not getting saved for my custom post type
- Get the last 5 products from each category
- How to say if meta_value is greater than 0 in an array?
- Getting users with a specific meta data and then querying their posts?
- Why does the post_type_link hook everything twice?
- Adding a tag_ID column into Categories inside the admin dashboard?
- How to pass a variable into an add_filter() function?
- locale filter function running multiple times
- Multiple requests external data api dynamic block gutenberg
- Why does the Woocommerce grouped template prints the unpublished products?
- Woocommerce with Lazy Load php and ajax
- Adding conditional text to a PHP Shortcode Template
- How do I get the content excerpt of the recent post?
- How to check $_GET isset for a parameter and value? [closed]
- How to deal with too many $_POST variable conditions from ajax request at backend? [closed]
- Making your own custom post views count
- Save Custom CSS file in the upload folder dynamically?
- How to use two meta_compare in an array?
- How to update and save user metadata on page visits?
- Verify if a category is the child of another category
- How to remap one of the TinyMCE Advanced Editor button to open the wordpress media library?
- Simple AJAX notification when the new post is added to the database
- How to optimize update_post_meta?
- Warning: in_array() null given in PHP function
- Contact Form 7 – Replace database configured form template with a static file