bp_activity_heartbeat_strings

Set the strings for WP HeartBeat API where needed.

Description

(array) bp_activity_heartbeat_strings( (array) $strings = array() ); 

Returns (array)

$strings

Parameters (1)

0. $strings — Optional. (array) => array()
Localized strings.

Usage

  1. if ( !function_exists( 'bp_activity_heartbeat_strings' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-filters.php'; 
  3.  
  4. // Localized strings. 
  5. $strings = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_heartbeat_strings($strings); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-filters.php  
  1. function bp_activity_heartbeat_strings( $strings = array() ) { 
  2.  
  3. if ( ! bp_activity_do_heartbeat() ) { 
  4. return $strings; 
  5.  
  6. $global_pulse = 0; 
  7.  
  8. /** 
  9. * Filter that checks whether the global heartbeat settings already exist. 
  10. * @since 2.0.0 
  11. * @param array $value Heartbeat settings array. 
  12. */ 
  13. $heartbeat_settings = apply_filters( 'heartbeat_settings', array() ); 
  14. if ( ! empty( $heartbeat_settings['interval'] ) ) { 
  15. // 'Fast' is 5 
  16. $global_pulse = is_numeric( $heartbeat_settings['interval'] ) ? absint( $heartbeat_settings['interval'] ) : 5; 
  17.  
  18. /** 
  19. * Filters the pulse frequency to be used for the BuddyPress Activity heartbeat. 
  20. * @since 2.0.0 
  21. * @param int $value The frequency in seconds between pulses. 
  22. */ 
  23. $bp_activity_pulse = apply_filters( 'bp_activity_heartbeat_pulse', 15 ); 
  24.  
  25. /** 
  26. * Use the global pulse value unless: 
  27. * a. the BP-specific value has been specifically filtered, or 
  28. * b. it doesn't exist (ie, BP will be the only one using the heartbeat,  
  29. * so we're responsible for enabling it) 
  30. */ 
  31. if ( has_filter( 'bp_activity_heartbeat_pulse' ) || empty( $global_pulse ) ) { 
  32. $pulse = $bp_activity_pulse; 
  33. } else { 
  34. $pulse = $global_pulse; 
  35.  
  36. $strings = array_merge( $strings, array( 
  37. 'newest' => __( 'Load Newest', buddypress ),  
  38. 'pulse' => absint( $pulse ),  
  39. ) ); 
  40.  
  41. return $strings;