partial-alerts-template.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin
  6. */
  7. if ( ! function_exists( '_yoast_display_alerts' ) ) {
  8. /**
  9. * Create the alert HTML with restore/dismiss button
  10. *
  11. * @param array $list List of alerts.
  12. * @param string $status Status of the alerts (active/dismissed).
  13. */
  14. function _yoast_display_alerts( $list, $status ) {
  15. foreach ( $list as $notification ) {
  16. switch ( $status ) {
  17. case 'active':
  18. $button = sprintf( '<button type="button" class="button dismiss"><span class="screen-reader-text">%1$s</span><span class="dashicons dashicons-no-alt"></span></button>', esc_html__( 'Dismiss this item.', 'wordpress-seo' ) );
  19. break;
  20. case 'dismissed':
  21. $button = sprintf( '<button type="button" class="button restore"><span class="screen-reader-text">%1$s</span><span class="dashicons dashicons-hidden"></span></button>', esc_html__( 'Restore this item.', 'wordpress-seo' ) );
  22. break;
  23. }
  24. printf(
  25. '<div class="yoast-alert-holder" id="%1$s" data-nonce="%2$s" data-json="%3$s">%4$s%5$s</div>',
  26. esc_attr( $notification->get_id() ),
  27. esc_attr( $notification->get_nonce() ),
  28. esc_attr( $notification->get_json() ),
  29. $notification,
  30. $button
  31. );
  32. }
  33. }
  34. }
  35. $wpseo_i18n_summary = $i18n_issues;
  36. if ( ! $active ) {
  37. $dashicon = 'yes';
  38. $wpseo_i18n_summary = $i18n_no_issues;
  39. }
  40. ?>
  41. <h3><span class="dashicons <?php echo esc_attr( 'dashicons-' . $dashicon ); ?>"></span> <?php echo esc_html( $i18n_title ); ?> (<?php echo (int) $active_total; ?>)</h3>
  42. <div id="<?php echo esc_attr( 'yoast-' . $type ); ?>">
  43. <?php if ( $total ) : ?>
  44. <p><?php echo esc_html( $wpseo_i18n_summary ); ?></p>
  45. <div class="container" id="<?php echo esc_attr( 'yoast-' . $type . '-active' ); ?>">
  46. <?php _yoast_display_alerts( $active, 'active' ); ?>
  47. </div>
  48. <?php if ( $dismissed ) : ?>
  49. <h4 class="yoast-muted-title"><?php echo esc_html( $i18n_muted_issues_title ); ?></h4>
  50. <?php endif; ?>
  51. <div class="container" id="<?php echo esc_attr( 'yoast-' . $type . '-dismissed' ); ?>">
  52. <?php _yoast_display_alerts( $dismissed, 'dismissed' ); ?>
  53. </div>
  54. <?php else : ?>
  55. <p><?php echo esc_html( $i18n_no_issues ); ?></p>
  56. <?php endif; ?>
  57. </div>