class-link-table-accessible-notifier.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Links
  6. */
  7. /**
  8. * Represents the notice when the table is not accessible.
  9. */
  10. class WPSEO_Link_Table_Accessible_Notifier {
  11. /**
  12. * Notification id.
  13. *
  14. * @var string
  15. */
  16. const NOTIFICATION_ID = 'wpseo-links-table-not-accessible';
  17. /**
  18. * Adds the notification to the notification center.
  19. */
  20. public function add_notification() {
  21. Yoast_Notification_Center::get()->add_notification( $this->get_notification() );
  22. }
  23. /**
  24. * Removes the notification from the notification center.
  25. */
  26. public function remove_notification() {
  27. Yoast_Notification_Center::get()->remove_notification( $this->get_notification() );
  28. }
  29. /**
  30. * Returns the notification when the table is not accessible.
  31. *
  32. * @return Yoast_Notification The notification.
  33. */
  34. protected function get_notification() {
  35. return new Yoast_Notification(
  36. sprintf(
  37. /* translators: %1$s: Yoast SEO. %2$s: Version number of Yoast SEO. %3$s: strong opening tag, %4$s: strong closing tag */
  38. esc_html__( 'The %3$sText link counter%4$s feature (introduced in %1$s %2$s) is currently disabled.', 'wordpress-seo' ),
  39. 'Yoast SEO',
  40. '5.0',
  41. '<strong>',
  42. '</strong>'
  43. ) . ' ' .
  44. sprintf(
  45. /* translators: %1$s: Yoast SEO. */
  46. esc_html__( 'For this feature to work, %1$s needs to create a table in your database. We were unable to create this table automatically.', 'wordpress-seo' ),
  47. 'Yoast SEO'
  48. ) . '<br><br>' .
  49. sprintf(
  50. /* translators: %1$s: link to knowledge base article about solving table issue. %2$s: is anchor closing. */
  51. esc_html__( 'Please read the following %1$sknowledge base article%2$s to find out how to resolve this problem.', 'wordpress-seo' ),
  52. '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/15o' ) . '">',
  53. '</a>'
  54. ),
  55. [
  56. 'type' => Yoast_Notification::WARNING,
  57. 'id' => self::NOTIFICATION_ID,
  58. 'capabilities' => 'wpseo_manage_options',
  59. 'priority' => 0.8,
  60. ]
  61. );
  62. }
  63. }