WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

Flag when `checked()`, `selected()` etc should be used

Open jrfnl opened this issue 7 years ago • 1 comments

What about a sniff to warn about code which does not use the WP helper functions - checked(), selected(), disabled(), wp_readonly()- for these form attributes ?

<!-- This should be flagged. -->
<input id="<?php echo esc_attr( $field_id ); ?>"
	name="<?php echo esc_attr( $field_name ); ?>" type="checkbox"
	class="prefix_classname"
	value="1" <?php echo ! empty( $current_value ) ? ' checked="checked"' : ''; ?> />

<!-- This should not be flagged. -->
<input type="checkbox" id="input_field_id" checked="checked"/>

jrfnl avatar Jun 29 '18 15:06 jrfnl

Loosely related to #346

jrfnl avatar Jun 29 '18 15:06 jrfnl