[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Activity: RSS feed actions 4 * 5 * @package BuddyPress 6 * @subpackage ActivityActions 7 * @since 3.0.0 8 */ 9 10 /** 11 * Load the sitewide activity feed. 12 * 13 * @since 1.0.0 14 * 15 * @return bool False on failure. 16 */ 17 function bp_activity_action_sitewide_feed() { 18 $bp = buddypress(); 19 20 if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) ) 21 return false; 22 23 // Setup the feed. 24 buddypress()->activity->feed = new BP_Activity_Feed( array( 25 'id' => 'sitewide', 26 27 /* translators: %s Site Name */ 28 'title' => sprintf( __( '%s | Site-Wide Activity', 'buddypress' ), bp_get_site_name() ), 29 'link' => bp_get_activity_directory_permalink(), 30 'description' => __( 'Activity feed for the entire site.', 'buddypress' ), 31 'activity_args' => 'display_comments=threaded' 32 ) ); 33 } 34 add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' ); 35 36 /** 37 * Load a user's personal activity feed. 38 * 39 * @since 1.0.0 40 * 41 * @return bool False on failure. 42 */ 43 function bp_activity_action_personal_feed() { 44 if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) { 45 return false; 46 } 47 48 // Setup the feed. 49 buddypress()->activity->feed = new BP_Activity_Feed( array( 50 'id' => 'personal', 51 52 /* translators: 1: Site Name. 2: User Display Name. */ 53 'title' => sprintf( _x( '%1$s | %2$s | Activity', 'Personal activity feed title', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ), 54 'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() ), 55 56 /* translators: %s: User Display Name */ 57 'description' => sprintf( __( 'Activity feed for %s.', 'buddypress' ), bp_get_displayed_user_fullname() ), 58 'activity_args' => 'user_id=' . bp_displayed_user_id() 59 ) ); 60 } 61 add_action( 'bp_actions', 'bp_activity_action_personal_feed' ); 62 63 /** 64 * Load a user's friends' activity feed. 65 * 66 * @since 1.0.0 67 * 68 * @return bool False on failure. 69 */ 70 function bp_activity_action_friends_feed() { 71 if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) { 72 return false; 73 } 74 75 // Setup the feed. 76 buddypress()->activity->feed = new BP_Activity_Feed( array( 77 'id' => 'friends', 78 79 /* translators: 1: Site Name 2: User Display Name */ 80 'title' => sprintf( __( '%1$s | %2$s | Friends Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ), 81 'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() ), 82 83 /* translators: %s: User Display Name */ 84 'description' => sprintf( __( "Activity feed for %s's friends.", 'buddypress' ), bp_get_displayed_user_fullname() ), 85 'activity_args' => 'scope=friends' 86 ) ); 87 } 88 add_action( 'bp_actions', 'bp_activity_action_friends_feed' ); 89 90 /** 91 * Load the activity feed for a user's groups. 92 * 93 * @since 1.2.0 94 * 95 * @return bool False on failure. 96 */ 97 function bp_activity_action_my_groups_feed() { 98 if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) { 99 return false; 100 } 101 102 // Get displayed user's group IDs. 103 $groups = groups_get_user_groups(); 104 $group_ids = implode( ',', $groups['groups'] ); 105 106 // Setup the feed. 107 buddypress()->activity->feed = new BP_Activity_Feed( array( 108 'id' => 'mygroups', 109 110 /* translators: 1: Site Name 2: User Display Name */ 111 'title' => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ), 112 'link' => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() ), 113 114 /* translators: %s: User Display Name */ 115 'description' => sprintf( __( "Public group activity feed of which %s is a member.", 'buddypress' ), bp_get_displayed_user_fullname() ), 116 'activity_args' => array( 117 'object' => buddypress()->groups->id, 118 'primary_id' => $group_ids, 119 'display_comments' => 'threaded' 120 ) 121 ) ); 122 } 123 add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' ); 124 125 /** 126 * Load a user's @mentions feed. 127 * 128 * @since 1.2.0 129 * 130 * @return bool False on failure. 131 */ 132 function bp_activity_action_mentions_feed() { 133 if ( ! bp_activity_do_mentions() ) { 134 return false; 135 } 136 137 if ( !bp_is_user_activity() || ! bp_is_current_action( 'mentions' ) || ! bp_is_action_variable( 'feed', 0 ) ) { 138 return false; 139 } 140 141 // Setup the feed. 142 buddypress()->activity->feed = new BP_Activity_Feed( array( 143 'id' => 'mentions', 144 145 /* translators: 1: Site Name 2: User Display Name */ 146 'title' => sprintf( __( '%1$s | %2$s | Mentions', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ), 147 'link' => bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/', 148 149 /* translators: %s: User Display Name */ 150 'description' => sprintf( __( "Activity feed mentioning %s.", 'buddypress' ), bp_get_displayed_user_fullname() ), 151 'activity_args' => array( 152 'search_terms' => '@' . bp_core_get_username( bp_displayed_user_id() ) 153 ) 154 ) ); 155 } 156 add_action( 'bp_actions', 'bp_activity_action_mentions_feed' ); 157 158 /** 159 * Load a user's favorites feed. 160 * 161 * @since 1.2.0 162 * 163 * @return bool False on failure. 164 */ 165 function bp_activity_action_favorites_feed() { 166 if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) { 167 return false; 168 } 169 170 // Get displayed user's favorite activity IDs. 171 $favs = bp_activity_get_user_favorites( bp_displayed_user_id() ); 172 $fav_ids = implode( ',', (array) $favs ); 173 174 // Setup the feed. 175 buddypress()->activity->feed = new BP_Activity_Feed( array( 176 'id' => 'favorites', 177 178 /* translators: 1: Site Name 2: User Display Name */ 179 'title' => sprintf( __( '%1$s | %2$s | Favorites', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ), 180 'link' => bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/', 181 182 /* translators: %s: User Display Name */ 183 'description' => sprintf( __( "Activity feed of %s's favorites.", 'buddypress' ), bp_get_displayed_user_fullname() ), 184 'activity_args' => 'include=' . $fav_ids 185 ) ); 186 } 187 add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Apr 18 01:01:43 2021 | Cross-referenced by PHPXref 0.7.1 |