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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. const NOTIFICATION_ID = 'wpseo-links-table-not-accessible';
  12. /**
  13. * Adds the notification to the notification center.
  14. */
  15. public function add_notification() {
  16. Yoast_Notification_Center::get()->add_notification( $this->get_notification() );
  17. }
  18. /**
  19. * Removes the notification from the notification center.
  20. */
  21. public function remove_notification() {
  22. Yoast_Notification_Center::get()->remove_notification( $this->get_notification() );
  23. }
  24. /**
  25. * Returns the notification when the table is not accessible.
  26. *
  27. * @return Yoast_Notification The notification.
  28. */
  29. protected function get_notification() {
  30. return new Yoast_Notification(
  31. sprintf(
  32. /* translators: %1$s: Yoast SEO. %2$s: Version number of Yoast SEO. %3$s: link to knowledge base article about solving table issue. %4$s: is anchor closing. */
  33. __(
  34. 'The <strong>Text link counter</strong> feature (introduced in %1$s %2$s) is currently disabled. For this feature to work %1$s needs to create a table in your database. We were unable to create this table automatically.
  35. Please read the following %3$sknowledge base article%4$s to find out how to resolve this problem.',
  36. 'wordpress-seo'
  37. ),
  38. 'Yoast SEO',
  39. '5.0',
  40. '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/15o' ) . '">',
  41. '</a>'
  42. ),
  43. array(
  44. 'type' => Yoast_Notification::WARNING,
  45. 'id' => self::NOTIFICATION_ID,
  46. 'capabilities' => 'wpseo_manage_options',
  47. 'priority' => 0.8,
  48. )
  49. );
  50. }
  51. }