BP_Nouveau_Friends
Connections Loader class
Description
Source
File: bp-templates/bp-nouveau/includes/friends/loader.php
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | class BP_Nouveau_Friends { /** * Constructor * * @since BuddyPress 3.0.0 */ public function __construct() { $this ->setup_globals(); $this ->includes(); $this ->setup_actions(); $this ->setup_filters(); } /** * Globals * * @since BuddyPress 3.0.0 */ protected function setup_globals() { $this ->dir = trailingslashit( dirname( __FILE__ ) ); } /** * Include needed files * * @since BuddyPress 3.0.0 */ protected function includes() { // Test suite requires the AJAX functions early. if ( function_exists( 'tests_add_filter' ) ) { require $this ->dir . 'ajax.php' ; // Load AJAX code only on AJAX requests. } else { add_action( 'admin_init' , function () { if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX && 0 === strpos ( $_REQUEST [ 'action' ], 'friends_' ) ) { require $this ->dir . 'ajax.php' ; } } ); } } /** * Register do_action() hooks * * @since BuddyPress 3.0.0 */ protected function setup_actions() { // Remove BuddyPress action for the members loop remove_action( 'bp_directory_members_actions' , 'bp_member_add_friend_button' ); // Register the friends Notifications filters add_action( 'bp_nouveau_notifications_init_filters' , array ( $this , 'notification_filters' ) ); } /** * Register add_filter() hooks * * @since BuddyPress 3.0.0 */ protected function setup_filters() { $buttons = array ( 'friends_pending' , 'friends_is_friend' , 'friends_not_friends' , 'friends_member_friendship' , 'friends_accept_friendship' , 'friends_reject_friendship' , ); foreach ( $buttons as $button ) { add_filter( 'bp_button_' . $button , 'bp_nouveau_ajax_button' , 10, 5 ); } } /** * Register notifications filters for the friends component. * * @since BuddyPress 3.0.0 */ public function notification_filters() { $notifications = array ( array ( 'id' => 'friendship_accepted' , 'label' => __( 'Accepted connection requests' , 'buddyboss' ), 'position' => 35, ), array ( 'id' => 'friendship_request' , 'label' => __( 'Pending connection requests' , 'buddyboss' ), 'position' => 45, ), ); foreach ( $notifications as $notification ) { bp_nouveau_notifications_register_filter( $notification ); } } } |
Changelog
Version | Description |
---|---|
BuddyPress 3.0.0 | Introduced. |
Methods
- __construct — Constructor
- includes — Include needed files
- notification_filters — Register notifications filters for the friends component.
- setup_actions — Register do_action() hooks
- setup_filters — Register add_filter() hooks
- setup_globals — Globals
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.