PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.1
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.1
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | admin/includes/class.notices.php +15 -40 trunk2.7.1 View file →
@@ -294,49 +294,24 @@
294 294 private function render_notice( $notice ) {
295 295 $type = $notice['type'];
296 296 $dismissible = $notice['dismissible'] ? 'is-dismissible' : '';
297 297 $notice_class = "notice notice-{$type} {$dismissible}";
298 - $notice_text = is_string( $notice['text'] ) ? $notice['text'] : '';
298 +
299 + $data_attrs = '';
300 + if ( $notice['dismissible'] ) {
301 + $data_attrs = sprintf(
302 + 'data-notice-id="%s" data-nonce="%s"',
303 + esc_attr( $notice['id'] ),
304 + wp_create_nonce( 'winp_dismiss_notice_' . $notice['id'] )
305 + );
306 + }
299 307
300 - ?>
301 - <div
302 - class="<?php echo esc_attr( $notice_class ); ?> winp-admin-notice"
303 - <?php if ( $notice['dismissible'] ) : ?>
304 - data-notice-id="<?php echo esc_attr( $notice['id'] ); ?>"
305 - data-nonce="<?php echo esc_attr( wp_create_nonce( 'winp_dismiss_notice_' . $notice['id'] ) ); ?>"
306 - <?php endif; ?>
307 - >
308 - <?php echo wp_kses( $notice_text, $this->get_allowed_notice_html() ); ?>
309 - </div>
310 - <?php
311 - }
312 -
313 - /**
314 - * Allowed HTML markup for notice messages.
315 - *
316 - * @return array<string, array<string, bool>>
317 - */
318 - private function get_allowed_notice_html() {
319 - $allowed_html = wp_kses_allowed_html( 'post' );
320 -
321 - $allowed_html['a']['class'] = true;
322 - $allowed_html['a']['target'] = true;
323 - $allowed_html['a']['rel'] = true;
324 - $allowed_html['div']['class'] = true;
325 - $allowed_html['span']['class'] = true;
326 - $allowed_html['details'] = [
327 - 'class' => true,
328 - 'open' => true,
329 - ];
330 - $allowed_html['summary'] = [ 'class' => true ];
331 - $allowed_html['code']['class'] = true;
332 - $allowed_html['button'] = [
333 - 'class' => true,
334 - 'type' => true,
335 - 'disabled' => true,
336 - ];
337 -
338 - return $allowed_html;
308 + printf(
309 + '<div class="%s winp-admin-notice" %s>%s</div>',
310 + esc_attr( $notice_class ),
311 + $data_attrs, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
312 + $notice['text'] // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
313 + );
339 314 }
340 315
341 316 /**
342 317 * Check if notice is dismissed