[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Activity Screens. 4 * 5 * The functions in this file detect, with each page load, whether an Activity 6 * component page is being requested. If so, it parses any necessary data from 7 * the URL, and tells BuddyPress to load the appropriate template. 8 * 9 * @package BuddyPress 10 * @subpackage ActivityScreens 11 * @since 1.5.0 12 */ 13 14 // Exit if accessed directly. 15 defined( 'ABSPATH' ) || exit; 16 17 /** 18 * Load the Activity directory. 19 * 20 * @since 1.5.0 21 * 22 */ 23 function bp_activity_screen_index() { 24 if ( bp_is_activity_directory() ) { 25 bp_update_is_directory( true, 'activity' ); 26 27 /** 28 * Fires right before the loading of the Activity directory screen template file. 29 * 30 * @since 1.5.0 31 */ 32 do_action( 'bp_activity_screen_index' ); 33 34 /** 35 * Filters the template to load for the Activity directory screen. 36 * 37 * @since 1.5.0 38 * 39 * @param string $template Path to the activity template to load. 40 */ 41 bp_core_load_template( apply_filters( 'bp_activity_screen_index', 'activity/index' ) ); 42 } 43 } 44 add_action( 'bp_screens', 'bp_activity_screen_index' ); 45 46 /** 47 * Load the 'My Activity' page. 48 * 49 * @since 1.0.0 50 * 51 */ 52 function bp_activity_screen_my_activity() { 53 54 /** 55 * Fires right before the loading of the "My Activity" screen template file. 56 * 57 * @since 1.0.0 58 */ 59 do_action( 'bp_activity_screen_my_activity' ); 60 61 /** 62 * Filters the template to load for the "My Activity" screen. 63 * 64 * @since 1.0.0 65 * 66 * @param string $template Path to the activity template to load. 67 */ 68 bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) ); 69 } 70 71 /** 72 * Load the 'My Friends' activity page. 73 * 74 * @since 1.0.0 75 * 76 */ 77 function bp_activity_screen_friends() { 78 if ( !bp_is_active( 'friends' ) ) 79 return false; 80 81 bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' ); 82 83 /** 84 * Fires right before the loading of the "My Friends" screen template file. 85 * 86 * @since 1.2.0 87 */ 88 do_action( 'bp_activity_screen_friends' ); 89 90 /** 91 * Filters the template to load for the "My Friends" screen. 92 * 93 * @since 1.0.0 94 * 95 * @param string $template Path to the activity template to load. 96 */ 97 bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) ); 98 } 99 100 /** 101 * Load the 'My Groups' activity page. 102 * 103 * @since 1.2.0 104 * 105 */ 106 function bp_activity_screen_groups() { 107 if ( !bp_is_active( 'groups' ) ) 108 return false; 109 110 bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' ); 111 112 /** 113 * Fires right before the loading of the "My Groups" screen template file. 114 * 115 * @since 1.2.0 116 */ 117 do_action( 'bp_activity_screen_groups' ); 118 119 /** 120 * Filters the template to load for the "My Groups" screen. 121 * 122 * @since 1.2.0 123 * 124 * @param string $template Path to the activity template to load. 125 */ 126 bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) ); 127 } 128 129 /** 130 * Load the 'Favorites' activity page. 131 * 132 * @since 1.2.0 133 * 134 */ 135 function bp_activity_screen_favorites() { 136 bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' ); 137 138 /** 139 * Fires right before the loading of the "Favorites" screen template file. 140 * 141 * @since 1.2.0 142 */ 143 do_action( 'bp_activity_screen_favorites' ); 144 145 /** 146 * Filters the template to load for the "Favorites" screen. 147 * 148 * @since 1.2.0 149 * 150 * @param string $template Path to the activity template to load. 151 */ 152 bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) ); 153 } 154 155 /** 156 * Load the 'Mentions' activity page. 157 * 158 * @since 1.2.0 159 * 160 */ 161 function bp_activity_screen_mentions() { 162 bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' ); 163 164 /** 165 * Fires right before the loading of the "Mentions" screen template file. 166 * 167 * @since 1.2.0 168 */ 169 do_action( 'bp_activity_screen_mentions' ); 170 171 /** 172 * Filters the template to load for the "Mentions" screen. 173 * 174 * @since 1.2.0 175 * 176 * @param string $template Path to the activity template to load. 177 */ 178 bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) ); 179 } 180 181 /** 182 * Reset the logged-in user's new mentions data when he visits his mentions screen. 183 * 184 * @since 1.5.0 185 * 186 */ 187 function bp_activity_reset_my_new_mentions() { 188 if ( bp_is_my_profile() ) 189 bp_activity_clear_new_mentions( bp_loggedin_user_id() ); 190 } 191 add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' ); 192 193 /** 194 * Load the page for a single activity item. 195 * 196 * @since 1.2.0 197 * 198 * @return bool|string Boolean on false or the template for a single activity item on success. 199 */ 200 function bp_activity_screen_single_activity_permalink() { 201 // No displayed user or not viewing activity component. 202 if ( ! bp_is_activity_component() ) { 203 return false; 204 } 205 206 $action = bp_current_action(); 207 if ( ! $action || ! is_numeric( $action ) ) { 208 return false; 209 } 210 211 // Get the activity details. 212 $activity = bp_activity_get_specific( array( 213 'activity_ids' => $action, 214 'show_hidden' => true, 215 'spam' => 'ham_only', 216 ) ); 217 218 // 404 if activity does not exist 219 if ( empty( $activity['activities'][0] ) || bp_action_variables() ) { 220 bp_do_404(); 221 return; 222 223 } else { 224 $activity = $activity['activities'][0]; 225 } 226 227 $user_id = bp_displayed_user_id(); 228 229 /** 230 * Check user access to the activity item. 231 * 232 * @since 3.0.0 233 */ 234 $has_access = bp_activity_user_can_read( $activity, $user_id ); 235 236 // If activity author does not match displayed user, block access. 237 // More info:https://buddypress.trac.wordpress.org/ticket/7048#comment:28 238 if ( true === $has_access && $user_id !== $activity->user_id ) { 239 $has_access = false; 240 } 241 242 /** 243 * Fires before the loading of a single activity template file. 244 * 245 * @since 1.2.0 246 * 247 * @param BP_Activity_Activity $activity Object representing the current activity item being displayed. 248 * @param bool $has_access Whether or not the current user has access to view activity. 249 */ 250 do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access ); 251 252 // Access is specifically disallowed. 253 if ( false === $has_access ) { 254 255 // User feedback. 256 bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' ); 257 258 // Redirect based on logged in status. 259 if ( is_user_logged_in() ) { 260 $url = bp_loggedin_user_domain(); 261 262 } else { 263 $url = sprintf( 264 wp_login_url( 'wp-login.php?redirect_to=%s' ), 265 esc_url_raw( bp_activity_get_permalink( $action ) ) 266 ); 267 } 268 269 bp_core_redirect( $url ); 270 } 271 272 /** 273 * Filters the template to load for a single activity screen. 274 * 275 * @since 1.0.0 276 * 277 * @param string $template Path to the activity template to load. 278 */ 279 $template = apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ); 280 281 // Load the template. 282 bp_core_load_template( $template ); 283 } 284 add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' ); 285 286 /** 287 * Add activity notifications settings to the notifications settings page. 288 * 289 * @since 1.2.0 290 * 291 */ 292 function bp_activity_screen_notification_settings() { 293 294 if ( bp_activity_do_mentions() ) { 295 if ( ! $mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) ) { 296 $mention = 'yes'; 297 } 298 } 299 300 if ( ! $reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) ) { 301 $reply = 'yes'; 302 } 303 304 ?> 305 306 <table class="notification-settings" id="activity-notification-settings"> 307 <thead> 308 <tr> 309 <th class="icon"> </th> 310 <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th> 311 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 312 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 313 </tr> 314 </thead> 315 316 <tbody> 317 <?php if ( bp_activity_do_mentions() ) : ?> 318 <tr id="activity-notification-settings-mentions"> 319 <td> </td> 320 <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) ) ?></td> 321 <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-yes" value="yes" <?php checked( $mention, 'yes', true ) ?>/><label for="notification-activity-new-mention-yes" class="bp-screen-reader-text"><?php 322 /* translators: accessibility text */ 323 _e( 'Yes, send email', 'buddypress' ); 324 ?></label></td> 325 <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-no" value="no" <?php checked( $mention, 'no', true ) ?>/><label for="notification-activity-new-mention-no" class="bp-screen-reader-text"><?php 326 /* translators: accessibility text */ 327 _e( 'No, do not send email', 'buddypress' ); 328 ?></label></td> 329 </tr> 330 <?php endif; ?> 331 332 <tr id="activity-notification-settings-replies"> 333 <td> </td> 334 <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td> 335 <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-yes" value="yes" <?php checked( $reply, 'yes', true ) ?>/><label for="notification-activity-new-reply-yes" class="bp-screen-reader-text"><?php 336 /* translators: accessibility text */ 337 _e( 'Yes, send email', 'buddypress' ); 338 ?></label></td> 339 <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-no" value="no" <?php checked( $reply, 'no', true ) ?>/><label for="notification-activity-new-reply-no" class="bp-screen-reader-text"><?php 340 /* translators: accessibility text */ 341 _e( 'No, do not send email', 'buddypress' ); 342 ?></label></td> 343 </tr> 344 345 <?php 346 347 /** 348 * Fires inside the closing </tbody> tag for activity screen notification settings. 349 * 350 * @since 1.2.0 351 */ 352 do_action( 'bp_activity_screen_notification_settings' ) ?> 353 </tbody> 354 </table> 355 356 <?php 357 } 358 add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 ); 359 360 /** Theme Compatibility *******************************************************/ 361 362 new BP_Activity_Theme_Compat();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Mar 4 01:00:55 2018 | Cross-referenced by PHPXref 0.7.1 |