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?
- How to include checkbox in widget backend form?
- Upgrading PHP version results in “Use of undefined constant WP_CONTENT_DIR” warning?
- How to hide get_theme_mod if field empty
- renaming an admin menu item with decimal array index number
- How to get the original price of the product in woocommerce?
- How to make sure that only one wp_cron() runs at a time?
- Fatal error: Call to undefined function wpsc_cart_item_count()
- No wp-config.php file on local install of wordpress – site still displays
- Widgets not showing in my custom theme
- Edit category output
- integrating external php library into wordpress- the right way
- To echo or not to echo?
- Different background-image by category
- Renaming post IDs – Okay to do?
- How to speed up admin-ajax.php in wordpress
- My Own layout in WooCommerce pages [closed]
- Add the Name of Products Ordered to Admin New Order Email WooCommerce
- Get WooCommerce product details and transfer them to a custom DB table
- Get Post Meta from ID in functions.php
- How to make a XML/PHP file returning custom field data from page
- Display custom post type title as text if post thumbnail is not available
- Ajax call return 404
- WordPress automatically adds links to uploaded images
- Security for data obtained from the database
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Royalty-Free Sliders used in theme development
- get_template_directory_uri() providing wrong path for img
- Custom Pagination is Broken
- Login redirect. Check user meta and redirect accordingly
- Lost in trying to create user database system
- Local WordPress with WAMP downloads files out of Nowhere
- Remove   from the_excerpt
- Why is my max_upload_filesize being limited to 2M? [duplicate]
- Errors being created by admin-ajax.php
- Posts are not looping through correctly
- Can’t pass the variable from a select to PHP query
- form $_post action value gets truncated after it passes through two forms
- Deactivate a plugin on wp version
- Ajaxurl suddenly not defined
- How to echo the_title from an array of posts?
- the_post_thumbnail issues
- linked php file not executing php
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- WordPress -> If Is Role Subscriber Show Image?
- Using color schemes with Color Picker
- Add other class content with reference class value
- how can i update my postmeta without losing old data?
- Slug duplicates once clicking on link
- Language does not switch while cache is enabled
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- My single.php page skips the first div tag
- Limit content size by character or word in database
- String replace for Login/Logout concatenation problem in menu
- PHP call_user_func_array() error
- Redirect after login depending on the URL
- Searching a custom WP table and displaying results in an HTML table
- Set user status to absent on WordPress
- Customizer: How to Sanitize a Decimal Number Range
- Obtain wordpress user role
- Shortcode’s output to use as other shortcode’s parameter
- Displaying POST content with HTML tags and all
- How to hook into the subscriber /wp-admin/index.php page?
- WordPress 3.0 PHP Error – notice WordPress_product_Type was called incorrectly
- Retrieving specific images from Media Library
- direct query to post_meta table
- Adding unique marketing messages between certain products whilst using isotope/Infinite Scroll
- Notice: Undefined index: fix with isset [closed]
- Include administrator in author list
- Pass php to database in JQuery: With AJAX?
- List sibling pages widget, exclude current page
- WP Simple Fields – Single repeatable field inside repeatable field group
- get_permalink returning first letter
- Path for contact form file
- File Upload with Server in safe_mode
- WP plugin updates [duplicate]
- Custom Archive Page
- Load files content [closed]
- Shortcode for Visual Composer Grid fails turning string to integer
- Upgrade wordpress core programmatically with PHP [closed]
- How to conditionally concatenate and translate two very long strings?