The plugin exposes a procedural API in includes/functions/. All functions are prefixed bpfn_. The functions below exist in the source.
| Function |
Returns |
Notes |
bpfn() |
BP_Favorite_Notification |
The singleton. |
bpfn_get_module( $name ) |
object or null |
A module instance, for example notifications, email, favorite_display. |
bpfn_register_module( $name, $instance ) |
bool |
Register a custom module. |
bpfn_get_version() |
string |
The plugin version. |
bpfn_get_plugin_url( $path = '' ) |
string |
Plugin URL, optionally with a path appended. |
bpfn_get_plugin_path( $path = '' ) |
string |
Plugin filesystem path. |
| Function |
Returns |
Notes |
bpfn_get_user_settings( $user_id ) |
array |
Per-type, per-channel preferences, merged with defaults. |
bpfn_save_user_settings( $user_id, $settings ) |
bool |
Write preferences to the plugin table. |
bpfn_is_notification_enabled( $user_id, $type, $channel = 'web' ) |
bool |
Whether a member wants a notification for a type on a channel (web, email, realtime). |
bpfn_get_activity_type( $activity ) |
string |
Map a BuddyPress activity to a preference key (activity_post or activity_comment). Accepts an activity object or ID. |
bpfn_email_meta_keys() |
array |
The user-meta keys BuddyPress writes for the two email rows and the unsubscribe link: activity_post is favorite_activity, activity_comment is favorite_activity_comment. |
| Function |
Returns |
Notes |
bpfn_add_notification( $args ) |
int or false |
Add a favourite-component notification. |
bpfn_delete_notifications( $args ) |
bool |
Delete matching notifications. |
bpfn_mark_notifications_read( $args ) |
bool |
Mark matching notifications read. |
bpfn_get_notifications( $user_id = 0, $args = array() ) |
array |
Formatted notifications for a member. |
bpfn_get_notification_count( $user_id, $args = array() ) |
int |
Count of new favourite notifications. |
bpfn_format_notification_data( $notification ) |
array or false |
Formatted data for one notification object. |
bpfn_register_notification_type( $type, $args ) |
bool |
Register a custom notification type on the notifications module. |
| Function |
Returns |
Notes |
bpfn_clear_old_notifications( $days = 30 ) |
array |
Delete read favourite notifications older than $days. Returns count, remaining, days, or an error key on failure. Only read notifications are removed. |
| Function |
Notes |
bpfn_notification_icon( $type = 'favorite' ) |
Echo an icon for a notification type. |
bpfn_get_notification_count_html( $count, $classes = '' ) |
Return count badge HTML. |
bpfn_notification_count( $count, $classes = '' ) |
Echo the count badge. |
bpfn_get_settings_field( $type, $name, $value, $args ) |
Return a form field (checkbox, radio, select). |
bpfn_settings_field( $type, $name, $value, $args ) |
Echo a form field. |
bpfn_get_template_part( $template, $args = array() ) |
Load a template part, theme override first. |
bpfn_should_show_notifications() |
Whether the current page should render notification UI. |
Get the module with bpfn_get_module( 'favorite_display' ):
get_favorite_count( $activity_id ): cached favourite count.
get_users_who_favorited( $activity_id, $limit = 3, $offset = 0 ): paginated liker list with users, total, remaining.
render_display( $activity_id ): the full display markup, wp_kses()-filtered.
get_display_modes() / get_icon_choices(): the registered modes and icons (static).
get_saved_mode() / get_saved_icon() (static): the saved display mode and icon, normalised to a registered value. The mode defaults to inline. The icon defaults to default_icon(): thumb on Reign, BuddyX and BuddyX Pro, star elsewhere (filter bpfn_default_favorite_icon). Sites upgraded from before 2.2.1 have heart saved.
Get the module with bpfn_get_module( 'admin' ), or call the static methods on BPFN_Module_Admin:
BPFN_Module_Admin::get_retention_days( $days = null ): the cleanup retention period. Returns 7, 15, 30, 60 or 90, and falls back to 30 for any other value. Null reads the saved option.
BPFN_Module_Admin::is_auto_cleanup_enabled(): whether the owner has switched automatic cleanup on. Off unless saved.
Static methods on BPFN_Module_Realtime:
BPFN_Module_Realtime::is_enabled(): whether the owner has switched real-time popups on. Off unless saved.
BPFN_Module_Realtime::get_interval( $seconds = null ): the Heartbeat interval in seconds. Returns 30 or 60, and falls back to 30. Null reads the saved option.