The admin_notices Hook in WPFTS

The admin_notices action is a standard WordPress hook used to display notices at the top of the administration pages. WPFTS utilizes this hook to display various messages to the user, such as welcome messages, update information, error warnings, and other important notifications.

What WPFTS Does When admin_notices is Called:

WPFTS displays notifications in a specific priority order using the WPFTS_Core::admin_notices() method:

  1. Welcome Message (is_welcome_message): Displayed only once after plugin activation, containing brief information about getting started.
  2. Update Information (change_log, change_notices): Messages about new features and important changes in the plugin.
  3. Database Update Error (updatedb_error_message): If an error occurs during a plugin database update, a corresponding message is displayed suggesting retrying or contacting support.
  4. Database Update Required Notification (is_db_outdated): If the plugin’s database version is outdated, a notification with a link to the settings page is displayed.
  5. Detector Messages (detector_message, detector2_message, detector3_message): Warnings about potential issues, such as a large number of files of certain types, insufficient memory limits, or the need to enable theme compatibility. Note that the display of these messages depends on the $is_all_great flag, which can be modified by the wpfts_admin_notices_in_serie filter.
  6. Indexing Rules Mismatch Notification (reqreset_message): If indexing rules have been changed and some index entries don’t comply, a notification is displayed prompting to update the index.

Important Functions Involved in admin_notices Handling:

  • WPFTS_Core::admin_notices()
  • WPFTS_Core::get_option()
  • WPFTS_Core::output_admin_notice()
  • WPFTS_Core::getCurrentIRulesStats()

How to Use This in Addon Development:

Addon developers can use the wpfts_admin_notices_in_serie filter to control the display of WPFTS notifications. If your addon displays a critically important notification, you can return false from the handler of this filter to hide less important WPFTS notifications. You can also use the admin_notices action to display your addon’s own notifications, but consider the notification display priority described above.

Additional Notes:

  • WPFTS uses various CSS classes to style notifications of different types (e.g., notice-error, notice-warning, notice-success).
  • Notifications can be dismissed by the user if they are marked as is-dismissible.

This hook demonstrates the notification display mechanism in WPFTS and allows addon developers to integrate their messages into the plugin’s notification system.