Skip to content

Commit ad0b006

Browse files
committed
Escape the last of unescaped translated strings
1 parent 8a7cf78 commit ad0b006

2 files changed

Lines changed: 15 additions & 21 deletions

File tree

‎add-admin-css.php‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,9 @@ public function recovery_mode_notice() {
443443
$msg = __( "<strong>RECOVERY MODE ENABLED:</strong> CSS output for the Add Admin CSS plugin is disabled on this page view.", 'add-admin-css' );
444444
}
445445

446-
echo <<<HTML
447-
<div class="notice notice-error">
448-
<p>{$msg}</p>
449-
</div>
450-
HTML;
446+
echo '<div class="notice notice-error">' . "\n";
447+
echo "\t<p>" . wp_kses( $msg, array( 'code' => array(), 'strong' => array() ) ). "</p>\n";
448+
echo '</div>' . "\n";
451449
}
452450

453451
/**
@@ -625,11 +623,9 @@ public function add_css() {
625623
$css = trim( apply_filters( 'c2c_add_admin_css', $css ) );
626624

627625
if ( $css ) {
628-
echo "
629-
<style>
630-
$css
631-
</style>
632-
";
626+
echo "<style>\n";
627+
echo esc_html( $css ) . "\n";
628+
echo "</style>\n";
633629
}
634630
}
635631

‎tests/phpunit/tests/add-admin-css.php‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,9 @@ public function test_add_css_to_head_with_just_css( $expected = false ) {
378378
ob_end_clean();
379379

380380
if ( false === $expected ) {
381-
$expected = "
382-
<style>
383-
{$css}
384-
</style>
385-
";
381+
$expected = "<style>
382+
{$css}
383+
</style>\n";
386384
}
387385

388386
$this->assertEquals( $expected, $out );
@@ -612,9 +610,9 @@ public function test_recovery_mode_notice_when_css_disabled_by_query_param_by_ad
612610

613611
$this->test_can_show_css_with_true_query_param_by_admin();
614612

615-
$expected = " <div class=\"notice notice-error\">
616-
<p><strong>RECOVERY MODE ENABLED:</strong> CSS output for the Add Admin CSS plugin is disabled on this page view.</p>
617-
</div>";
613+
$expected = "<div class=\"notice notice-error\">
614+
<p><strong>RECOVERY MODE ENABLED:</strong> CSS output for the Add Admin CSS plugin is disabled on this page view.</p>
615+
</div>\n";
618616

619617
$this->assertEquals( $expected, $this->get_action_output( 'admin_notices' ) );
620618
}
@@ -737,9 +735,9 @@ public function test_recovery_mode_via_constant_disables_add_css() {
737735
public function test_recovery_mode_notice_when_css_disabled_by_constant() {
738736
$this->fake_current_screen();
739737

740-
$expected = " <div class=\"notice notice-error\">
741-
<p><strong>RECOVERY MODE ENABLED:</strong> CSS output for the Add Admin CSS plugin is currently disabled for the entire admin area via use of the <code>C2C_ADD_ADMIN_CSS_DISABLED</code> constant.</p>
742-
</div>";
738+
$expected = "<div class=\"notice notice-error\">
739+
<p><strong>RECOVERY MODE ENABLED:</strong> CSS output for the Add Admin CSS plugin is currently disabled for the entire admin area via use of the <code>C2C_ADD_ADMIN_CSS_DISABLED</code> constant.</p>
740+
</div>\n";
743741

744742
$this->assertEquals( $expected, $this->get_action_output( 'admin_notices' ) );
745743
}

0 commit comments

Comments
 (0)