I am having a bit of an issue right now with the VIP coding standards. I am trying to print out an admin notice as follows:
add_action( 'admin_notices', function() {
$class = 'notice notice-warning is-dismissible';
$message = __( 'We suggest that you use the <b>API Key file</b> for your API Keys.', 'package-wordpress' );
print wp_sprintf( '<div class="%s"><p>%s</p></div>', $class, $message );
});
It is successful in that it prints and displays the notice, however, when I run my code standards check, it throws escaping function errors.
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
----------------------------------------------------------------------
101 | ERROR | Expected next thing to be an escaping function (see
| | Codex for 'Data Validation'), not '$class'
101 | ERROR | Expected next thing to be an escaping function (see
| | Codex for 'Data Validation'), not '$message'
----------------------------------------------------------------------
I have done some research on this issue and found that it really wants me to escape the html when printing it to the screen, however when I do that, it of course removes the ability to have HTML inside of the message. What are the suggestions for doing this while still passing the coding standards?