@@ -460,7 +460,14 @@ public function render_settings_moved() {
460460 ),
461461 )
462462 ),
463- $ link
463+ wp_kses (
464+ $ link ,
465+ array (
466+ 'a ' => array (
467+ 'href ' => array (),
468+ ),
469+ )
470+ )
464471 );
465472 echo '</div> ' ;
466473 }
@@ -470,14 +477,14 @@ public function render_compression_timing_settings() {
470477 'When should new images be compressed? ' ,
471478 'tiny-compress-images '
472479 );
473- echo '<h4> ' . $ heading . '</h4> ' ;
480+ echo '<h4> ' . esc_html ( $ heading ) . '</h4> ' ;
474481 echo '<div class="optimization-options"> ' ;
475482
476483 $ name = self ::get_prefixed_name ( 'compression_timing ' );
477484 $ compression_timing = $ this ->get_compression_timing ();
478485
479486 $ id = self ::get_prefixed_name ( 'background_compress_enabled ' );
480- $ checked = ( 'background ' === $ compression_timing ? ' checked="checked" ' : '' );
487+ $ checked = ( 'background ' === $ compression_timing );
481488
482489 $ label = esc_html__ (
483490 'Compress new images in the background (Recommended) ' ,
@@ -493,12 +500,11 @@ public function render_compression_timing_settings() {
493500 $ label ,
494501 $ description ,
495502 'background ' ,
496- $ checked ,
497- false
503+ $ checked
498504 );
499505
500506 $ id = self ::get_prefixed_name ( 'auto_compress_enabled ' );
501- $ checked = ( 'auto ' === $ compression_timing ? ' checked="checked" ' : '' );
507+ $ checked = ( 'auto ' === $ compression_timing );
502508
503509 $ label = esc_html__ (
504510 'Compress new images during upload ' ,
@@ -514,12 +520,11 @@ public function render_compression_timing_settings() {
514520 $ label ,
515521 $ description ,
516522 'auto ' ,
517- $ checked ,
518- false
523+ $ checked
519524 );
520525
521526 $ id = self ::get_prefixed_name ( 'auto_compress_disabled ' );
522- $ checked = ( 'manual ' === $ compression_timing ? ' checked="checked" ' : '' );
527+ $ checked = ( 'manual ' === $ compression_timing );
523528
524529 $ label = esc_html__ (
525530 'Do not compress new images automatically ' ,
@@ -535,16 +540,16 @@ public function render_compression_timing_settings() {
535540 $ label ,
536541 $ description ,
537542 'manual ' ,
538- $ checked ,
539- false
543+ $ checked
540544 );
541545
542546 echo '</div> ' ;
543547 }
544548
545549 public function render_sizes () {
550+ $ dummy_size_name = self ::get_prefixed_name ( 'sizes[ ' . self ::DUMMY_SIZE . '] ' );
546551 echo '<input type="hidden" name=" ' .
547- self :: get_prefixed_name ( ' sizes[ ' . self :: DUMMY_SIZE . ' ] ' ) . '" value="on"/> ' ;
552+ esc_attr ( $ dummy_size_name ) . '" value="on"/> ' ;
548553
549554 foreach ( $ this ->get_sizes () as $ size => $ option ) {
550555 $ this ->render_size_checkboxes ( $ size , $ option );
@@ -568,7 +573,7 @@ public function render_sizes() {
568573 private function render_size_checkboxes ( $ size , $ option ) {
569574 $ id = self ::get_prefixed_name ( "sizes_ $ size " );
570575 $ name = self ::get_prefixed_name ( 'sizes[ ' . $ size . '] ' );
571- $ checked = ( $ option ['tinify ' ] ? ' checked="checked" ' : '' );
576+ $ checked = ! empty ( $ option ['tinify ' ] );
572577 if ( Tiny_Image::is_original ( $ size ) ) {
573578 $ label = esc_html__ ( 'Original image ' , 'tiny-compress-images ' ) . ' ( ' .
574579 esc_html__ (
@@ -592,9 +597,9 @@ private function render_size_checkboxes( $size, $option ) {
592597 . ' - ' . $ width . 'x ' . $ height ;
593598 }
594599 echo '<p> ' ;
595- echo '<input type="checkbox" id=" ' . $ id . '" name=" ' . $ name .
596- '" value="on" ' . $ checked . '/> ' ;
597- echo '<label for=" ' . $ id . '"> ' . $ label . '</label> ' ;
600+ echo '<input type="checkbox" id=" ' . esc_attr ( $ id ) . '" name=" ' . esc_attr ( $ name ) .
601+ '" value="on" ' . checked ( $ checked, true , false ) . '/> ' ;
602+ echo '<label for=" ' . esc_attr ( $ id ) . '"> ' . esc_html ( $ label ) . '</label> ' ;
598603 echo '</p> ' ;
599604 }
600605
@@ -646,7 +651,7 @@ public function render_size_checkboxes_description(
646651 ),
647652 $ strong
648653 ),
649- $ free_images_per_month
654+ esc_html ( $ free_images_per_month )
650655 );
651656
652657 if ( self ::wr2x_active () ) {
@@ -683,7 +688,7 @@ public function render_compression_timing_radiobutton(
683688 'For compression to work you will need to configure WP Offload S3 to keep a copy of the images on the server. ' ,
684689 'tiny-compress-images '
685690 );
686- echo $ message ;
691+ echo esc_html ( $ message ) ;
687692 echo '</p></div> ' ;
688693 echo '<p class="tiny-radio disabled"> ' ;
689694 } else {
@@ -693,11 +698,11 @@ public function render_compression_timing_radiobutton(
693698 $ id = sprintf ( self ::get_prefixed_name ( 'compression_timing_%s ' ), $ value );
694699 $ label = esc_html ( $ label );
695700 $ desc = esc_html ( $ desc );
696- echo '<input type="radio" id=" ' . $ id . '" name=" ' . $ name .
697- '" value=" ' . $ value . '" ' . $ checked . '/> ' ;
698- echo '<label for=" ' . $ id . '"> ' . $ label . '</label> ' ;
701+ echo '<input type="radio" id=" ' . esc_attr ( $ id ) . '" name=" ' . esc_attr ( $ name ) .
702+ '" value=" ' . esc_attr ( $ value ) . '" ' . checked ( $ checked, true , false ) . '/> ' ;
703+ echo '<label for=" ' . esc_attr ( $ id ) . '"> ' . esc_html ( $ label ) . '</label> ' ;
699704 echo '<br> ' ;
700- echo '<span> ' . $ desc . '</span> ' ;
705+ echo '<span> ' . esc_html ( $ desc ) . '</span> ' ;
701706 echo '</p> ' ;
702707 }
703708
@@ -955,11 +960,11 @@ private static function render_radiobutton(
955960 $ label ,
956961 $ descr
957962 ) {
958- $ checked = ( $ current_value === $ option_value ? ' checked="checked" ' : '' );
963+ $ checked = ( $ current_value === $ option_value );
959964 echo '<p class="tiny-radio"> ' ;
960965 echo '<input type="radio" data-testid=" ' . esc_attr ( $ option_id ) . '" ' ;
961- echo 'id=" ' . esc_attr ( $ option_id ) . '" name=" ' . $ group_name .
962- '" value=" ' . esc_attr ( $ option_value ) . '" ' . $ checked . '/> ' ;
966+ echo 'id=" ' . esc_attr ( $ option_id ) . '" name=" ' . esc_attr ( $ group_name ) .
967+ '" value=" ' . esc_attr ( $ option_value ) . '" ' . checked ( $ checked, true , false ) . '/> ' ;
963968 echo '<label for=" ' . esc_attr ( $ option_id ) . '"> ' . esc_html ( $ label );
964969 echo '<span> ' . esc_html ( $ descr ) . '</span> ' ;
965970 echo '</label> ' ;
0 commit comments