Skip to content

Commit 069b12d

Browse files
chore: minor defensive coding improvements
1 parent ef3168c commit 069b12d

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/admin/class-admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ public function save_box_options($box_id, $post)
539539
*/
540540
public function sanitize_settings($opts)
541541
{
542+
$opts['test_mode'] = (int) $opts['test_mode'] ? 1 : 0;
542543
return $opts;
543544
}
544545

src/admin/class-notices.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Notices
1414
*/
1515
public function __construct()
1616
{
17-
add_action('admin_notices', [ $this, 'show' ]);
17+
add_action('admin_notices', [ $this, 'action_admin_notices' ], 10, 0);
1818
}
1919

2020
/**
@@ -36,10 +36,11 @@ public function add($message, $type = 'updated')
3636
/**
3737
* Output the registered notices
3838
*/
39-
public function show()
39+
public function admin_notices(): void
4040
{
41+
$allowed_html = [ 'strong' => [], 'em' => [], 'a' => [ 'href' => [] ] ];
4142
foreach ($this->notices as $notice) {
42-
echo "<div class=\"notice notice-{$notice['type']}\"><p>{$notice['message']}</p></div>";
43+
echo "<div class=\"notice notice-", esc_attr($notice['type']), "><p>", wp_kses($notice['message'], $allowed_html), "</p></div>";
4344
}
4445
}
4546
}

src/licensing/views/license-form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<?php foreach ($notices as $notice) { ?>
3838
<div class="notice notice-<?php echo esc_attr($notice['type']); ?> inline">
39-
<p><?php echo $notice['message']; ?></p>
39+
<p><?php echo wp_kses($notice['message'], ['strong' => [], 'em' => [], 'a' => ['href' => []]]); ?></p>
4040
</div>
4141
<?php } ?>
4242

0 commit comments

Comments
 (0)