I have an issue with custom widgets and WordPress Coding Standards. When you create a custom widget, your class should have a “widget” method that will display the widget. Something like:
<?php
public function widget( $args, $instance ) {
echo $args['before_widget'];
?> <span><?php echo esc_html( 'Great widget', 'text-domain' ); ?></span> <?php
echo $args['after_widget'];
}
?>
While this is perfectly functional, this will not pass PHP code sniffer tests with WordPress coding standards because $args['after_widget'];
and $args['before_widget'];
are not escaped…
What am I doing wrong?