wpfts_admin_notices_in_serie (Filter)
The wpfts_admin_notices_in_serie
filter in WP Fast Total Search controls the display of admin notices in the WordPress admin panel. It acts as a “fuse,” preventing less important notices from being displayed if there are more important ones requiring the user’s attention.
When Used
This filter is called in the admin_notices()
method of the WPFTS_Core
class and is used to determine whether to display plugin-related notices.
Arguments
$is_all_great
(bool): A flag indicating whether everything is fine with the plugin.true
if there are no critical errors or important notices,false
otherwise.
Return Value
$is_all_great
(bool): The modified flag. Iffalse
is returned, less important notices will not be displayed. Iftrue
is returned, less important notices will be displayed if they exist.
Filter Logic
The WPFTS plugin displays notices in a specific order. First, the most important notices are displayed, such as error messages or database update requirements. If such notices exist, the plugin sets the $is_all_great
flag to false
. Then, the wpfts_admin_notices_in_serie
filter is called. If the filter handler returns false
, less important notices, such as reminders about plugin settings or information about new versions, will not be displayed. This avoids overwhelming the user with notifications and focuses their attention on the most important messages. In other words, this filter allows suppressing standard notifications if the add-on needs to display more important notifications.
Example
/**
* Suppresses default notifications if there are custom ones.
*/
add_filter('wpfts_admin_notices_in_serie', 'suppress_default_notices');
function suppress_default_notices($is_all_great) {
// Checks if there are custom notices to display.
if (get_option('my_plugin_has_notices') == 1) {
return false; // Suppresses default notifications.
// Displays custom notices
echo '<div class="notice notice-warning"><p>'.esc_html__('My plugin notice', 'my-plugin').'</p></div>';
}
return $is_all_great; // In other cases, does not change the default behavior.
}
Important Notes
- The
wpfts_admin_notices_in_serie
filter is called in theadmin_notices()
method of theWPFTS_Core
class. - The return value must be a boolean (
true
orfalse
).
This filter provides developers with additional control over the display of WPFTS notifications in the WordPress admin panel.