Closed farhadsakhaei closed 10 months ago
@farhadsakhaei Can you please share more of the code, indicating line numbers, and the line numbers from the error message please, and the precise command you ran?
I'm unable to replicate with a test file of just:
<label for="<?php esc_attr_e( $this->get_field_id( 'display-mode' ) ); ?>">
and a command of:
phpcs --standard=WordPress-VIP-Go phpcs-test.php --severity=1 -s
@GaryJones Hi, Thank you for reply, this is my full line of code:
<label for="<?php echo esc_attr( $this->get_field_id( 'display-mode' ) ); ?>"><?php esc_attr_e( 'Display Mode:', 'aparat-feed' ); ?></label>
@farhadsakhaei Your error is for the <?php esc_attr_e( 'Display Mode:', 'aparat-feed' ); ?>
and the sniff is correct as that's HTML context, not attribute context.
@jrfnl
Yes, You are right, That was because the pointer was pointing another tag Thank you
@farhadsakhaei When in doubt, you can use the --report=code
option to see which bit of the code is being flagged by which sniff. Hope that helps.
Shall we close this issue ?
@jrfnl Thank you so much for help and recommendation Yes, of course Sincerly
My code:
<label for="<?php echo esc_attr( $this->get_field_id( 'display-mode' ) ); ?>">
or
<label for="<?php esc_attr_e( $this->get_field_id( 'display-mode' ) ); ?>">
I get this error:
Wrong escaping function, using
esc_attr_e()in a context outside of HTML attributes may not escape properly.PHPCS(WordPressVIPMinimum.Security.ProperEscapingFunction.notAttrEscAttr)