Changeset 3751
- Timestamp:
- 01/20/2011 03:56:04 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 17 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r3743 r3751 1 1 <?php 2 2 3 // Required Files 4 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' ); 5 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' ); 6 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' ); 7 8 function bp_activity_setup_globals() { 9 global $bp, $current_blog; 10 11 // Define a slug, if necessary 12 if ( !defined( 'BP_ACTIVITY_SLUG' ) ) 13 define( 'BP_ACTIVITY_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->activity->slug ) ); 14 15 // For internal identification 16 $bp->activity->id = 'activity'; 17 $bp->activity->name = $bp->pages->activity->name; 18 19 // Slugs 20 $bp->activity->slug = BP_ACTIVITY_SLUG; 21 $bp->activity->root_slug = $bp->pages->activity->slug; 22 23 // Tables 24 $bp->activity->table_name = $bp->table_prefix . 'bp_activity'; 25 $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta'; 26 27 // Notifications 28 $bp->activity->format_notification_function = 'bp_activity_format_notifications'; 29 30 // Register this in the active components array 31 $bp->active_components[$bp->activity->slug] = $bp->activity->id; 32 33 do_action( 'bp_activity_setup_globals' ); 34 } 35 add_action( 'bp_setup_globals', 'bp_activity_setup_globals' ); 36 37 function bp_activity_setup_nav() { 38 global $bp; 39 40 /* Add 'Activity' to the main navigation */ 41 bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity->name, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) ); 42 43 if ( !is_user_logged_in() && !isset( $bp->displayed_user->id ) ) 44 return; 45 46 $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; 47 $user_login = ( isset( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login; 48 $activity_link = $user_domain . $bp->activity->slug . '/'; 49 50 /* Add the subnav items to the activity nav item if we are using a theme that supports this */ 51 bp_core_new_subnav_item( array( 'name' => __( 'Personal', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) ); 52 53 if ( bp_is_active( 'friends' ) ) 54 bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) ); 55 56 if ( bp_is_active( 'groups' ) ) 57 bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) ); 58 59 bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) ); 60 bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) ); 61 62 if ( $bp->current_component == $bp->activity->slug ) { 63 if ( bp_is_my_profile() ) { 64 $bp->bp_options_title = __( 'My Activity', 'buddypress' ); 65 } else { 66 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 67 $bp->bp_options_title = $bp->displayed_user->fullname; 3 class BP_Activity_Component extends BP_Component { 4 5 /** 6 * Start the activity component creation process 7 */ 8 function BP_Activity_Component() { 9 parent::start( 'activity', __( 'Activity Streams', 'buddypress' ) ); 10 } 11 12 /** 13 * Setup globals 14 * 15 * @global obj $bp 16 */ 17 function _setup_globals() { 18 global $bp; 19 20 // Define a slug, if necessary 21 if ( !defined( 'BP_ACTIVITY_SLUG' ) ) 22 define( 'BP_ACTIVITY_SLUG', 'activity' ); 23 24 // Do some slug checks 25 $this->slug = defined( 'BP_ACTIVITY_SLUG' ) ? BP_ACTIVITY_SLUG : $this->id; 26 $this->root_slug = isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : $this->slug; 27 28 // Tables 29 $this->table_name = $bp->table_prefix . 'bp_activity'; 30 $this->table_name_meta = $bp->table_prefix . 'bp_activity_meta'; 31 } 32 33 /** 34 * Include files 35 * 36 * @global obj $bp 37 */ 38 function _includes() { 39 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-actions.php' ); 40 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' ); 41 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-screens.php' ); 42 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' ); 43 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-functions.php' ); 44 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-template.php' ); 45 } 46 47 /** 48 * Setup BuddyBar navigation 49 * 50 * @global obj $bp 51 */ 52 function _setup_nav() { 53 global $bp; 54 55 // Add 'Activity' to the main navigation 56 bp_core_new_nav_item( array( 57 'name' => __( 'Activity', 'buddypress' ), 58 'slug' => $bp->activity->slug, 59 'position' => 10, 60 'screen_function' => 'bp_activity_screen_my_activity', 61 'default_subnav_slug' => 'just-me', 62 'item_css_id' => $bp->activity->id ) 63 ); 64 65 // Stop if there is no user displayed or logged in 66 if ( !is_user_logged_in() && !isset( $bp->displayed_user->id ) ) 67 return; 68 69 // User links 70 $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; 71 $user_login = ( isset( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login; 72 $activity_link = $user_domain . $bp->activity->slug . '/'; 73 74 // Add the subnav items to the activity nav item if we are using a theme that supports this 75 bp_core_new_subnav_item( array( 76 'name' => __( 'Personal', 'buddypress' ), 77 'slug' => 'just-me', 78 'parent_url' => $activity_link, 79 'parent_slug' => $bp->activity->slug, 80 'screen_function' => 'bp_activity_screen_my_activity', 81 'position' => 10 82 ) ); 83 84 // Additional menu if friends is active 85 if ( bp_is_active( 'friends' ) ) { 86 bp_core_new_subnav_item( array( 87 'name' => __( 'Friends', 'buddypress' ), 88 'slug' => BP_FRIENDS_SLUG, 89 'parent_url' => $activity_link, 90 'parent_slug' => $bp->activity->slug, 91 'screen_function' => 'bp_activity_screen_friends', 92 'position' => 20, 93 'item_css_id' => 'activity-friends' 94 ) ); 68 95 } 69 } 70 71 do_action( 'bp_activity_setup_nav' ); 72 } 73 add_action( 'bp_setup_nav', 'bp_activity_setup_nav' ); 74 75 function bp_activity_directory_activity_setup() { 76 global $bp; 77 78 if ( $bp->current_component == $bp->activity->slug && empty( $bp->current_action ) ) { 79 $bp->is_directory = true; 80 81 do_action( 'bp_activity_directory_activity_setup' ); 82 bp_core_load_template( apply_filters( 'bp_activity_directory_activity_setup', 'activity/index' ) ); 83 } 84 } 85 add_action( 'wp', 'bp_activity_directory_activity_setup', 2 ); 86 87 88 /******************************************************************************** 89 * Screen Functions 90 * 91 * Screen functions are the controllers of BuddyPress. They will execute when their 92 * specific URL is caught. They will first save or manipulate data using business 93 * functions, then pass on the user to a template file. 94 */ 95 96 function bp_activity_screen_my_activity() { 97 do_action( 'bp_activity_screen_my_activity' ); 98 bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) ); 99 } 100 101 function bp_activity_screen_friends() { 102 global $bp; 103 104 if ( !bp_is_active( 'friends' ) ) 105 return false; 106 107 if ( !is_super_admin() ) 108 $bp->is_item_admin = false; 109 110 do_action( 'bp_activity_screen_friends' ); 111 bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) ); 112 } 113 114 function bp_activity_screen_groups() { 115 global $bp; 116 117 if ( !bp_is_active( 'groups' ) ) 118 return false; 119 120 if ( !is_super_admin() ) 121 $bp->is_item_admin = false; 122 123 do_action( 'bp_activity_screen_groups' ); 124 bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) ); 125 } 126 127 function bp_activity_screen_favorites() { 128 global $bp; 129 130 if ( !is_super_admin() ) 131 $bp->is_item_admin = false; 132 133 do_action( 'bp_activity_screen_favorites' ); 134 bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) ); 135 } 136 137 function bp_activity_screen_mentions() { 138 global $bp; 139 140 if ( !is_super_admin() ) 141 $bp->is_item_admin = false; 142 143 do_action( 'bp_activity_screen_mentions' ); 144 bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) ); 145 } 146 147 /** 148 * bp_activity_remove_screen_notifications() 149 * 150 * Removes activity notifications from the notification menu when a user clicks on them and 151 * is taken to a specific screen. 152 * 153 * @package BuddyPress Activity 154 */ 155 function bp_activity_remove_screen_notifications() { 156 global $bp; 157 158 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->activity->id, 'new_at_mention' ); 159 } 160 add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' ); 161 add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' ); 162 add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' ); 163 164 function bp_activity_screen_single_activity_permalink() { 165 global $bp; 166 167 if ( !$bp->displayed_user->id || $bp->current_component != $bp->activity->name ) 168 return false; 169 170 if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) ) 171 return false; 172 173 /* Get the activity details */ 174 $activity = bp_activity_get_specific( array( 'activity_ids' => $bp->current_action ) ); 175 176 if ( !$activity = $activity['activities'][0] ) 177 bp_core_redirect( $bp->root_domain ); 178 179 $has_access = true; 180 /* Redirect based on the type of activity */ 181 if ( $activity->component == $bp->groups->id ) { 182 if ( !function_exists( 'groups_get_group' ) ) 183 bp_core_redirect( $bp->root_domain ); 184 185 if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) { 186 /* Check to see if the group is not public, if so, check the user has access to see this activity */ 187 if ( 'public' != $group->status ) { 188 if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) 189 $has_access = false; 96 97 // Additional menu if groups is active 98 if ( bp_is_active( 'groups' ) ) { 99 bp_core_new_subnav_item( array( 100 'name' => __( 'Groups', 'buddypress' ), 101 'slug' => BP_GROUPS_SLUG, 102 'parent_url' => $activity_link, 103 'parent_slug' => $bp->activity->slug, 104 'screen_function' => 'bp_activity_screen_groups', 105 'position' => 30, 106 'item_css_id' => 'activity-groups' 107 ) ); 108 } 109 110 // Favorite activity items 111 bp_core_new_subnav_item( array( 112 'name' => __( 'Favorites', 'buddypress' ), 113 'slug' => 'favorites', 114 'parent_url' => $activity_link, 115 'parent_slug' => $bp->activity->slug, 116 'screen_function' => 'bp_activity_screen_favorites', 117 'position' => 40, 118 'item_css_id' => 'activity-favs' 119 ) ); 120 121 // @ mentions 122 bp_core_new_subnav_item( array( 123 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 124 'slug' => 'mentions', 125 'parent_url' => $activity_link, 126 'parent_slug' => $bp->activity->slug, 127 'screen_function' => 'bp_activity_screen_mentions', 128 'position' => 50, 129 'item_css_id' => 'activity-mentions' 130 ) ); 131 132 // Adjust title based on view 133 if ( bp_is_activity_component() ) { 134 if ( bp_is_my_profile() ) { 135 $bp->bp_options_title = __( 'My Activity', 'buddypress' ); 136 } else { 137 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 138 'item_id' => $bp->displayed_user->id, 139 'type' => 'thumb' 140 ) ); 141 $bp->bp_options_title = $bp->displayed_user->fullname; 190 142 } 191 143 } 192 144 } 193 194 $has_access = apply_filters( 'bp_activity_permalink_access', $has_access, &$activity ); 195 196 do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access ); 197 198 if ( !$has_access ) { 199 bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' ); 200 201 if ( is_user_logged_in() ) 202 bp_core_redirect( $bp->loggedin_user->domain ); 203 else 204 bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . esc_url( $bp->root_domain . '/' . $bp->activity->slug . '/p/' . $bp->current_action ) ) ); 205 } 206 207 bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) ); 208 } 209 /* This screen is not attached to a nav item, so we need to add an action for it. */ 210 add_action( 'wp', 'bp_activity_screen_single_activity_permalink', 3 ); 211 212 function bp_activity_screen_notification_settings() { 213 global $bp; 214 215 $mention = get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true ); 216 if ( !$mention ) 217 $mention = 'yes'; 218 219 $reply = get_user_meta( $bp->displayed_user->id, 'notification_activity_new_reply', true ); 220 if ( !$reply ) 221 $reply = 'yes'; 222 ?> 223 <table class="notification-settings zebra" id="activity-notification-settings"> 224 <thead> 225 <tr> 226 <th class="icon"></th> 227 <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th> 228 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 229 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 230 </tr> 231 </thead> 232 233 <tbody> 234 <tr id="activity-notification-settings-mentions"> 235 <td></td> 236 <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ?></td> 237 <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td> 238 <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td> 239 </tr> 240 <tr id="activity-notification-settings-replies"> 241 <td></td> 242 <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td> 243 <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php checked( $reply, 'yes', true ) ?>/></td> 244 <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php checked( $reply, 'no', true ) ?>/></td> 245 </tr> 246 247 <?php do_action( 'bp_activity_screen_notification_settings' ) ?> 248 </tbody> 249 </table> 250 <?php 251 } 252 add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 ); 253 254 /******************************************************************************** 255 * Action Functions 256 * 257 * Action functions are exactly the same as screen functions, however they do not 258 * have a template screen associated with them. Usually they will send the user 259 * back to the default screen after execution. 145 } 146 // Create the activity component 147 $bp->activity = new BP_Activity_Component(); 148 149 /** 150 * @todo Figure out if this is still needed 151 * 152 * @global obj $bp 260 153 */ 261 262 function bp_activity_action_permalink_router() { 263 global $bp; 264 265 if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'p' ) 266 return false; 267 268 if ( empty( $bp->action_variables[0] ) || !is_numeric( $bp->action_variables[0] ) ) 269 return false; 270 271 /* Get the activity details */ 272 $activity = bp_activity_get_specific( array( 'activity_ids' => $bp->action_variables[0] ) ); 273 274 if ( !$activity = $activity['activities'][0] ) 275 bp_core_redirect( $bp->root_domain ); 276 277 $redirect = false; 278 /* Redirect based on the type of activity */ 279 if ( $activity->component == $bp->groups->id ) { 280 if ( $activity->user_id ) { 281 $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id . '/'; 282 } else { 283 if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) 284 $redirect = bp_get_group_permalink( $group ) . $bp->activity->slug . '/' . $activity->id . '/'; 285 } 286 } else { 287 $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id; 288 } 289 290 $redirect = apply_filters( 'bp_activity_permalink_redirect_url', $redirect, &$activity ); 291 292 if ( !$redirect ) 293 bp_core_redirect( $bp->root_domain ); 294 295 /* Redirect to the actual activity permalink page */ 296 bp_core_redirect( $redirect ); 297 } 298 add_action( 'wp', 'bp_activity_action_permalink_router', 3 ); 299 300 function bp_activity_action_delete_activity() { 301 global $bp; 302 303 if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'delete' ) 304 return false; 305 306 if ( empty( $bp->action_variables[0] ) || !is_numeric( $bp->action_variables[0] ) ) 307 return false; 308 309 /* Check the nonce */ 310 check_admin_referer( 'bp_activity_delete_link' ); 311 312 $activity_id = $bp->action_variables[0]; 313 $activity = new BP_Activity_Activity( $activity_id ); 314 315 /* Check access */ 316 if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id ) 317 return false; 318 319 /* Call the action before the delete so plugins can still fetch information about it */ 320 do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id ); 321 322 /* Now delete the activity item */ 323 if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) ) 324 bp_core_add_message( __( 'Activity deleted', 'buddypress' ) ); 325 else 326 bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' ); 327 328 bp_core_redirect( wp_get_referer() ); 329 } 330 add_action( 'wp', 'bp_activity_action_delete_activity', 3 ); 331 332 function bp_activity_action_post_update() { 333 global $bp; 334 335 if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'post' ) 336 return false; 337 338 /* Check the nonce */ 339 check_admin_referer( 'post_update', '_wpnonce_post_update' ); 340 341 $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] ); 342 $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] ); 343 $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] ); 344 345 if ( empty( $content ) ) { 346 bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' ); 347 bp_core_redirect( wp_get_referer() ); 348 } 349 350 if ( !(int)$item_id ) { 351 $activity_id = bp_activity_post_update( array( 'content' => $content ) ); 352 353 } else if ( 'groups' == $object && function_exists( 'groups_post_update' ) ) { 354 if ( (int)$item_id ) { 355 $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) ); 356 } 357 } else 358 $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content ); 359 360 if ( !empty( $activity_id ) ) 361 bp_core_add_message( __( 'Update Posted!', 'buddypress' ) ); 362 else 363 bp_core_add_message( __( 'There was an error when posting your update, please try again.', 'buddypress' ), 'error' ); 364 365 bp_core_redirect( wp_get_referer() ); 366 } 367 add_action( 'wp', 'bp_activity_action_post_update', 3 ); 368 369 function bp_activity_action_post_comment() { 370 global $bp; 371 372 if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'reply' ) 373 return false; 374 375 /* Check the nonce */ 376 check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' ); 377 378 $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] ); 379 $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] ); 380 381 if ( empty( $content ) ) { 382 bp_core_add_message( __( 'Please do not leave the comment area blank.', 'buddypress' ), 'error' ); 383 bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id ); 384 } 385 386 $comment_id = bp_activity_new_comment( array( 387 'content' => $content, 388 'activity_id' => $activity_id, 389 'parent_id' => $parent_id 390 )); 391 392 if ( !empty( $comment_id ) ) 393 bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) ); 394 else 395 bp_core_add_message( __( 'There was an error posting that reply, please try again.', 'buddypress' ), 'error' ); 396 397 bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id ); 398 } 399 add_action( 'wp', 'bp_activity_action_post_comment', 3 ); 400 401 function bp_activity_action_mark_favorite() { 402 global $bp; 403 404 if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'favorite' ) 405 return false; 406 407 /* Check the nonce */ 408 check_admin_referer( 'mark_favorite' ); 409 410 if ( bp_activity_add_user_favorite( $bp->action_variables[0] ) ) 411 bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) ); 412 else 413 bp_core_add_message( __( 'There was an error marking that activity as a favorite, please try again.', 'buddypress' ), 'error' ); 414 415 bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] ); 416 } 417 add_action( 'wp', 'bp_activity_action_mark_favorite', 3 ); 418 419 function bp_activity_action_remove_favorite() { 420 global $bp; 421 422 if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'unfavorite' ) 423 return false; 424 425 /* Check the nonce */ 426 check_admin_referer( 'unmark_favorite' ); 427 428 if ( bp_activity_remove_user_favorite( $bp->action_variables[0] ) ) 429 bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) ); 430 else 431 bp_core_add_message( __( 'There was an error removing that activity as a favorite, please try again.', 'buddypress' ), 'error' ); 432 433 bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] ); 434 } 435 add_action( 'wp', 'bp_activity_action_remove_favorite', 3 ); 436 437 function bp_activity_action_sitewide_feed() { 438 global $bp, $wp_query; 439 440 if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'feed' || ( isset( $bp->displayed_user->id ) && $bp->displayed_user->id ) || isset( $bp->groups->current_group ) ) 441 return false; 442 443 $wp_query->is_404 = false; 444 status_header( 200 ); 445 446 include_once( 'bp-activity/feeds/bp-activity-sitewide-feed.php' ); 447 die; 448 } 449 add_action( 'wp', 'bp_activity_action_sitewide_feed', 3 ); 450 451 function bp_activity_action_personal_feed() { 452 global $bp, $wp_query; 453 454 if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'feed' ) 455 return false; 456 457 $wp_query->is_404 = false; 458 status_header( 200 ); 459 460 include_once( 'bp-activity/feeds/bp-activity-personal-feed.php' ); 461 die; 462 } 463 add_action( 'wp', 'bp_activity_action_personal_feed', 3 ); 464 465 function bp_activity_action_friends_feed() { 466 global $bp, $wp_query; 467 468 if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != $bp->friends->slug || !isset( $bp->action_variables[0] ) || $bp->action_variables[0] != 'feed' ) 469 return false; 470 471 $wp_query->is_404 = false; 472 status_header( 200 ); 473 474 include_once( 'bp-activity/feeds/bp-activity-friends-feed.php' ); 475 die; 476 } 477 add_action( 'wp', 'bp_activity_action_friends_feed', 3 ); 478 479 function bp_activity_action_my_groups_feed() { 480 global $bp, $wp_query; 481 482 if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != $bp->groups->slug || !isset( $bp->action_variables[0] ) || $bp->action_variables[0] != 'feed' ) 483 return false; 484 485 $wp_query->is_404 = false; 486 status_header( 200 ); 487 488 include_once( 'bp-activity/feeds/bp-activity-mygroups-feed.php' ); 489 die; 490 } 491 add_action( 'wp', 'bp_activity_action_my_groups_feed', 3 ); 492 493 function bp_activity_action_mentions_feed() { 494 global $bp, $wp_query; 495 496 if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'mentions' || !isset( $bp->action_variables[0] ) || $bp->action_variables[0] != 'feed' ) 497 return false; 498 499 $wp_query->is_404 = false; 500 status_header( 200 ); 501 502 include_once( 'bp-activity/feeds/bp-activity-mentions-feed.php' ); 503 die; 504 } 505 add_action( 'wp', 'bp_activity_action_mentions_feed', 3 ); 506 507 function bp_activity_action_favorites_feed() { 508 global $bp, $wp_query; 509 510 if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'favorites' || !isset( $bp->action_variables[0] ) || $bp->action_variables[0] != 'feed' ) 511 return false; 512 513 $wp_query->is_404 = false; 514 status_header( 200 ); 515 516 include_once( 'bp-activity/feeds/bp-activity-favorites-feed.php' ); 517 die; 518 } 519 add_action( 'wp', 'bp_activity_action_favorites_feed', 3 ); 154 function bp_activity_directory_activity_setup() { 155 global $bp; 156 157 if ( bp_is_activity_component() && empty( $bp->current_action ) ) { 158 $bp->is_directory = true; 159 160 do_action( 'bp_activity_directory_activity_setup' ); 161 162 bp_core_load_template( apply_filters( 'bp_activity_directory_activity_setup', 'activity/index' ) ); 163 } 164 } 165 add_action( 'wp', 'bp_activity_directory_activity_setup', 2 ); 520 166 521 167 /** 522 * bp_activity_find_mentions()523 *524 168 * Searches through the content of an activity item to locate usernames, designated by an @ sign 525 169 * … … 542 186 543 187 /** 544 * bp_activity_reduce_mention_count()545 *546 188 * Reduces new mention count for mentioned users when activity items are deleted 547 189 * … … 571 213 572 214 /** 573 * bp_activity_format_notifications()574 *575 215 * Formats notifications related to activity 576 216 * … … 586 226 switch ( $action ) { 587 227 case 'new_at_mention': 588 $activity_id = $item_id; 589 $poster_user_id = $secondary_item_id; 590 591 $at_mention_link = $bp->loggedin_user->domain . $bp->activity->slug . '/mentions/'; 228 $activity_id = $item_id; 229 $poster_user_id = $secondary_item_id; 230 $at_mention_link = $bp->loggedin_user->domain . $bp->activity->slug . '/mentions/'; 592 231 $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), $bp->loggedin_user->userdata->user_nicename ); 593 232 … … 607 246 } 608 247 609 /******************************************************************************** 610 * Business Functions 611 * 612 * Business functions are where all the magic happens in BuddyPress. They will 613 * handle the actual saving or manipulation of information. Usually they will 614 * hand off to a database class for data access, then return 615 * true or false on success or failure. 616 */ 617 618 function bp_activity_get( $args = '' ) { 619 $defaults = array( 620 'max' => false, // Maximum number of results to return 621 'page' => 1, // page 1 without a per_page will result in no pagination. 622 'per_page' => false, // results per page 623 'sort' => 'DESC', // sort ASC or DESC 624 'display_comments' => false, // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item 625 626 'search_terms' => false, // Pass search terms as a string 627 'show_hidden' => false, // Show activity items that are hidden site-wide? 628 'exclude' => false, // Comma-separated list of activity IDs to exclude 629 'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query 630 631 /** 632 * Pass filters as an array -- all filter items can be multiple values comma separated: 633 * array( 634 * 'user_id' => false, // user_id to filter on 635 * 'object' => false, // object to filter on e.g. groups, profile, status, friends 636 * 'action' => false, // action to filter on e.g. activity_update, profile_updated 637 * 'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc. 638 * 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id 639 * ); 640 */ 641 'filter' => array() 642 ); 643 644 $r = wp_parse_args( $args, $defaults ); 645 extract( $r, EXTR_SKIP ); 646 647 /* Attempt to return a cached copy of the first page of sitewide activity. */ 648 if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && 'DESC' == $sort && empty( $exclude ) ) { 649 if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) { 650 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ); 651 wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); 652 } 653 } else 654 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $exclude, $in ); 655 656 return apply_filters( 'bp_activity_get', $activity, &$r ); 657 } 658 659 function bp_activity_get_specific( $args = '' ) { 660 $defaults = array( 661 'activity_ids' => false, // A single activity_id or array of IDs. 662 'page' => 1, // page 1 without a per_page will result in no pagination. 663 'per_page' => false, // results per page 664 'max' => false, // Maximum number of results to return 665 'sort' => 'DESC', // sort ASC or DESC 666 'display_comments' => false // true or false to display threaded comments for these specific activity items 667 ); 668 669 $r = wp_parse_args( $args, $defaults ); 670 extract( $r, EXTR_SKIP ); 671 672 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids ) ); 673 } 674 675 function bp_activity_add( $args = '' ) { 676 global $bp; 677 678 $defaults = array( 679 'id' => false, // Pass an existing activity ID to update an existing entry. 680 681 'action' => '', // The activity action - e.g. "Jon Doe posted an update" 682 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!" 683 684 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent 685 'type' => false, // The activity type e.g. activity_update, profile_updated 686 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink) 687 688 'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user. 689 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id 690 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id 691 'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded 692 'hide_sitewide' => false // Should this be hidden on the sitewide activity stream? 693 ); 694 695 $params = wp_parse_args( $args, $defaults ); 696 extract( $params, EXTR_SKIP ); 697 698 /* Make sure we are backwards compatible */ 699 if ( empty( $component ) && !empty( $component_name ) ) 700 $component = $component_name; 701 702 if ( empty( $type ) && !empty( $component_action ) ) 703 $type = $component_action; 704 705 $activity = new BP_Activity_Activity( $id ); 706 707 $activity->user_id = $user_id; 708 $activity->component = $component; 709 $activity->type = $type; 710 $activity->action = $action; 711 $activity->content = $content; 712 $activity->primary_link = $primary_link; 713 $activity->item_id = $item_id; 714 $activity->secondary_item_id = $secondary_item_id; 715 $activity->date_recorded = $recorded_time; 716 $activity->hide_sitewide = $hide_sitewide; 717 718 if ( !$activity->save() ) 719 return false; 720 721 /* If this is an activity comment, rebuild the tree */ 722 if ( 'activity_comment' == $activity->type ) 723 BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id ); 724 725 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 726 do_action( 'bp_activity_add', $params ); 727 728 return $activity->id; 729 } 730 731 function bp_activity_post_update( $args = '' ) { 732 global $bp; 733 734 $defaults = array( 735 'content' => false, 736 'user_id' => $bp->loggedin_user->id 737 ); 738 739 $r = wp_parse_args( $args, $defaults ); 740 extract( $r, EXTR_SKIP ); 741 742 if ( empty( $content ) || !strlen( trim( $content ) ) ) 743 return false; 744 745 /* Record this on the user's profile */ 746 $from_user_link = bp_core_get_userlink( $user_id ); 747 $activity_action = sprintf( __( '%s posted an update:', 'buddypress' ), $from_user_link ); 748 $activity_content = $content; 749 750 $primary_link = bp_core_get_userlink( $user_id, false, true ); 751 752 /* Now write the values */ 753 $activity_id = bp_activity_add( array( 754 'user_id' => $user_id, 755 'action' => apply_filters( 'bp_activity_new_update_action', $activity_action ), 756 'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ), 757 'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ), 758 'component' => $bp->activity->id, 759 'type' => 'activity_update' 760 ) ); 761 762 /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */ 763 update_user_meta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) ); 764 765 /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */ 766 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-notifications.php' ); 767 768 do_action( 'bp_activity_posted_update', $content, $user_id, $activity_id ); 769 770 return $activity_id; 771 } 772 773 function bp_activity_new_comment( $args = '' ) { 774 global $bp; 775 776 $defaults = array( 777 'id' => false, 778 'content' => false, 779 'user_id' => $bp->loggedin_user->id, 780 'activity_id' => false, // ID of the root activity item 781 'parent_id' => false // ID of a parent comment (optional) 782 ); 783 784 $params = wp_parse_args( $args, $defaults ); 785 extract( $params, EXTR_SKIP ); 786 787 if ( empty($content) || empty($user_id) || empty($activity_id) ) 788 return false; 789 790 if ( empty($parent_id) ) 791 $parent_id = $activity_id; 792 793 /* Check to see if the parent activity is hidden, and if so, hide this comment publically. */ 794 $activity = new BP_Activity_Activity( $activity_id ); 795 $is_hidden = ( (int)$activity->hide_sitewide ) ? 1 : 0; 796 797 /* Insert the activity comment */ 798 $comment_id = bp_activity_add( array( 799 'id' => $id, 800 'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment:', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ), 801 'content' => apply_filters( 'bp_activity_comment_content', $content ), 802 'component' => $bp->activity->id, 803 'type' => 'activity_comment', 804 'user_id' => $user_id, 805 'item_id' => $activity_id, 806 'secondary_item_id' => $parent_id, 807 'hide_sitewide' => $is_hidden 808 ) ); 809 810 /* Send an email notification if settings allow */ 811 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-notifications.php' ); 812 bp_activity_new_comment_notification( $comment_id, $user_id, $params ); 813 814 /* Clear the comment cache for this activity */ 815 wp_cache_delete( 'bp_activity_comments_' . $parent_id ); 816 817 do_action( 'bp_activity_comment_posted', $comment_id, $params ); 818 819 return $comment_id; 820 } 821 822 /** 823 * bp_activity_get_activity_id() 824 * 825 * Fetch the activity_id for an existing activity entry in the DB. 826 * 827 * @package BuddyPress Activity 828 */ 829 function bp_activity_get_activity_id( $args = '' ) { 830 $defaults = array( 831 'user_id' => false, 832 'component' => false, 833 'type' => false, 834 'item_id' => false, 835 'secondary_item_id' => false, 836 'action' => false, 837 'content' => false, 838 'date_recorded' => false, 839 ); 840 841 $r = wp_parse_args( $args, $defaults ); 842 extract( $r, EXTR_SKIP ); 843 844 return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) ); 845 } 846 847 /*** 848 * Deleting Activity 849 * 850 * If you're looking to hook into one action that provides the ID(s) of 851 * the activity/activities deleted, then use: 852 * 853 * add_action( 'bp_activity_deleted_activities', 'my_function' ); 854 * 855 * The action passes one parameter that is a single activity ID or an 856 * array of activity IDs depending on the number deleted. 857 * 858 * If you are deleting an activity comment please use bp_activity_delete_comment(); 859 */ 860 861 function bp_activity_delete( $args = '' ) { 862 global $bp; 863 864 /* Pass one or more the of following variables to delete by those variables */ 865 $defaults = array( 866 'id' => false, 867 'action' => false, 868 'content' => false, 869 'component' => false, 870 'type' => false, 871 'primary_link' => false, 872 'user_id' => false, 873 'item_id' => false, 874 'secondary_item_id' => false, 875 'date_recorded' => false, 876 'hide_sitewide' => false 877 ); 878 879 $args = wp_parse_args( $args, $defaults ); 880 881 if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) ) 882 return false; 883 884 /* Check if the user's latest update has been deleted */ 885 if ( empty( $args['user_id'] ) ) 886 $user_id = $bp->loggedin_user->id; 887 else 888 $user_id = $args['user_id']; 889 890 $latest_update = get_user_meta( $user_id, 'bp_latest_update', true ); 891 if ( !empty( $latest_update ) ) { 892 if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) ) 893 delete_user_meta( $user_id, 'bp_latest_update' ); 894 } 895 896 do_action( 'bp_activity_delete', $args ); 897 do_action( 'bp_activity_deleted_activities', $activity_ids_deleted ); 898 899 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 900 901 return true; 902 } 903 /* The following functions have been deprecated in place of bp_activity_delete() */ 904 function bp_activity_delete_by_item_id( $args = '' ) { 905 global $bp; 906 907 $defaults = array( 'item_id' => false, 'component' => false, 'type' => false, 'user_id' => false, 'secondary_item_id' => false ); 908 $r = wp_parse_args( $args, $defaults ); 909 extract( $r, EXTR_SKIP ); 910 911 return bp_activity_delete( array( 'item_id' => $item_id, 'component' => $component, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ); 912 } 913 914 function bp_activity_delete_by_activity_id( $activity_id ) { 915 return bp_activity_delete( array( 'id' => $activity_id ) ); 916 } 917 918 function bp_activity_delete_by_content( $user_id, $content, $component, $type ) { 919 return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) ); 920 } 921 922 function bp_activity_delete_for_user_by_component( $user_id, $component ) { 923 return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) ); 924 } 925 /* End deprecation */ 926 927 function bp_activity_delete_comment( $activity_id, $comment_id ) { 928 /*** 929 * You may want to hook into this filter if you want to override this function and 930 * handle the deletion of child comments differently. Make sure you return false. 931 */ 932 if ( !apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) 933 return false; 934 935 /* Delete any children of this comment. */ 936 bp_activity_delete_children( $activity_id, $comment_id ); 937 938 /* Delete the actual comment */ 939 if ( !bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) 940 return false; 941 942 /* Recalculate the comment tree */ 943 BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id ); 944 945 do_action( 'bp_activity_delete_comment', $activity_id, $comment_id ); 946 947 return true; 948 } 949 function bp_activity_delete_children( $activity_id, $comment_id) { 950 /* Recursively delete all children of this comment. */ 951 if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) { 952 foreach( (array)$children as $child ) 953 bp_activity_delete_children( $activity_id, $child->id ); 954 } 955 bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) ); 956 } 957 958 function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 959 global $bp; 960 961 if ( !$activity_obj ) 962 $activity_obj = new BP_Activity_Activity( $activity_id ); 963 964 if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type ) 965 $link = $activity_obj->primary_link; 966 else { 967 if ( 'activity_comment' == $activity_obj->type ) 968 $link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->item_id . '/'; 969 else 970 $link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->id . '/'; 971 } 972 973 return apply_filters( 'bp_activity_get_permalink', $link ); 974 } 975 976 function bp_activity_hide_user_activity( $user_id ) { 977 return BP_Activity_Activity::hide_all_for_user( $user_id ); 978 } 979 980 /** 981 * bp_activity_thumbnail_content_images() 982 * 983 * Take content, remove all images and replace them with one thumbnail image. 984 * 985 * @package BuddyPress Activity 986 * @param $content str - The content to work with 987 * @param $link str - Optional. The URL that the image should link to 988 * @return $content str - The content with images stripped and replaced with a single thumb. 989 */ 990 function bp_activity_thumbnail_content_images( $content, $link = false ) { 991 global $post; 992 993 preg_match_all( '/<img[^>]*>/Ui', $content, $matches ); 994 $content = preg_replace('/<img[^>]*>/Ui', '', $content ); 995 996 if ( !empty( $matches ) && !empty( $matches[0] ) ) { 997 /* Get the SRC value */ 998 preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src ); 999 1000 /* Get the width and height */ 1001 preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height ); 1002 preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width ); 1003 1004 if ( !empty( $src ) ) { 1005 $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 ); 1006 $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 ); 1007 $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 ); 1008 1009 if ( empty( $width ) || empty( $height ) ) { 1010 $width = 100; 1011 $height = 100; 1012 } 1013 1014 $ratio = (int)$width / (int)$height; 1015 $new_height = (int)$height >= 100 ? 100 : $height; 1016 $new_width = $new_height * $ratio; 1017 1018 $image = '<img src="' . esc_attr( $src ) . '" width="' . $new_width . '" height="' . $new_height . '" alt="' . __( 'Thumbnail', 'buddypress' ) . '" class="align-left thumbnail" />'; 1019 1020 if ( !empty( $link ) ) { 1021 $image = '<a href="' . $link . '">' . $image . '</a>'; 1022 } 1023 1024 $content = $image . $content; 1025 } 1026 } 1027 1028 return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches ); 1029 } 248 /** Actions *******************************************************************/ 1030 249 1031 250 function bp_activity_set_action( $component_id, $key, $value ) { … … 1036 255 1037 256 $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array( 1038 'key' => $key,257 'key' => $key, 1039 258 'value' => $value 1040 259 ), $component_id, $key, $value ); … … 1049 268 return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key ); 1050 269 } 270 271 /** Favorites *****************************************************************/ 1051 272 1052 273 function bp_activity_get_user_favorites( $user_id ) { … … 1069 290 $user_id = $bp->loggedin_user->id; 1070 291 1071 / * Update the user's personal favorites */292 // Update the user's personal favorites 1072 293 $my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) ); 1073 294 $my_favs[] = $activity_id; 1074 295 1075 / * Update the total number of users who have favorited this activity */296 // Update the total number of users who have favorited this activity 1076 297 $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' ); 1077 298 … … 1095 316 $user_id = $bp->loggedin_user->id; 1096 317 1097 / * Remove the fav from the user's favs */318 // Remove the fav from the user's favs 1098 319 $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) ); 1099 320 $my_favs = array_flip( (array) $my_favs ); … … 1101 322 $my_favs = array_unique( array_flip( $my_favs ) ); 1102 323 1103 / * Update the total number of users who have favorited this activity */324 // Update the total number of users who have favorited this activity 1104 325 $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' ); 1105 326 … … 1133 354 } 1134 355 1135 /******************************************************************************** 1136 * Activity Meta Functions 1137 * 1138 * Meta functions allow you to store extra data for a particular item. 1139 */ 356 /** Meta **********************************************************************/ 357 1140 358 1141 359 function bp_activity_delete_meta( $activity_id, $meta_key = false, $meta_value = false ) { … … 1152 370 $meta_value = trim( $meta_value ); 1153 371 1154 if ( !$meta_key ) {372 if ( !$meta_key ) 1155 373 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) ); 1156 } else if ( $meta_value ) {374 else if ( $meta_value ) 1157 375 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s AND meta_value = %s", $activity_id, $meta_key, $meta_value ) ); 1158 } else {376 else 1159 377 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) ); 1160 }1161 378 1162 379 wp_cache_delete( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' ); … … 1207 424 $meta_value = maybe_serialize( $meta_value ); 1208 425 1209 if ( empty( $meta_value ) ) {426 if ( empty( $meta_value ) ) 1210 427 return bp_activity_delete_meta( $activity_id, $meta_key ); 1211 }1212 428 1213 429 $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) ); 1214 430 1215 if ( !$cur ) {431 if ( !$cur ) 1216 432 $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_meta} ( activity_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $activity_id, $meta_key, $meta_value ) ); 1217 } else if ( $cur->meta_value != $meta_value ) {433 else if ( $cur->meta_value != $meta_value ) 1218 434 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name_meta} SET meta_value = %s WHERE activity_id = %d AND meta_key = %s", $meta_value, $activity_id, $meta_key ) ); 1219 } else { 1220 return false; 1221 } 435 else 436 return false; 1222 437 1223 438 wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $meta_value, 'bp' ); … … 1225 440 return true; 1226 441 } 442 443 /** Clean up ******************************************************************/ 1227 444 1228 445 function bp_activity_remove_data( $user_id ) { … … 1236 453 do_action( 'bp_activity_remove_data', $user_id ); 1237 454 } 1238 add_action( 'wpmu_delete_user', 'bp_activity_remove_data' );1239 add_action( 'delete_user', 'bp_activity_remove_data' );455 add_action( 'wpmu_delete_user', 'bp_activity_remove_data' ); 456 add_action( 'delete_user', 'bp_activity_remove_data' ); 1240 457 add_action( 'bp_make_spam_user', 'bp_activity_remove_data' ); 1241 458 1242 459 /** 1243 * updates_register_activity_actions()1244 *1245 460 * Register the activity stream actions for updates 1246 461 * … … 1256 471 add_action( 'bp_register_activity_actions', 'updates_register_activity_actions' ); 1257 472 1258 /********************************************************************************1259 * Custom Actions1260 *1261 * Functions to set up custom BuddyPress actions that all other components can1262 * hook in to.1263 */1264 1265 /* Allow core components and dependent plugins to register activity actions */1266 function bp_register_activity_actions() {1267 do_action( 'bp_register_activity_actions' );1268 }1269 add_action( 'bp_init', 'bp_register_activity_actions', 8 );1270 1271 473 ?> -
trunk/bp-activity/bp-activity-filters.php
r3666 r3751 1 1 <?php 2 2 3 / * Apply WordPress defined filters */3 // Apply WordPress defined filters 4 4 add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 ); 5 5 add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 ); … … 64 64 add_filter( 'bp_get_activity_feed_item_description', 'stripslashes_deep' ); 65 65 66 / * Apply BuddyPress defined filters */66 // Apply BuddyPress defined filters 67 67 add_filter( 'bp_get_activity_content', 'bp_activity_make_nofollow_filter' ); 68 68 add_filter( 'bp_get_activity_content_body', 'bp_activity_make_nofollow_filter' ); … … 74 74 add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' ); 75 75 76 / * Allow shortcodes in activity posts */76 // Allow shortcodes in activity posts 77 77 add_filter( 'bp_get_activity_content', 'do_shortcode' ); 78 78 add_filter( 'bp_get_activity_content_body', 'do_shortcode' ); -
trunk/bp-activity/bp-activity-template.php
r3739 r3751 1 1 <?php 2 2 3 /** 4 * BuddyPress Activity Template Functions 5 * 6 * @package BuddyPress 7 * @subpackage Activity Template 8 */ 9 10 /** 11 * Output the activity component slug 12 * 13 * @package BuddyPress 14 * @subpackage Activity Template 15 * @since BuddyPress {unknown} 16 * 17 * @uses bp_get_activity_slug() 18 */ 19 function bp_activity_slug() { 20 echo bp_get_activity_slug(); 21 } 22 /** 23 * Return the activity component slug 24 * 25 * @package BuddyPress 26 * @subpackage Activity Template 27 * @since BuddyPress {unknown} 28 */ 29 function bp_get_activity_slug() { 30 global $bp; 31 return apply_filters( 'bp_get_activity_slug', $bp->activation->slug ); 32 } 33 34 /** 35 * Output the activity component root slug 36 * 37 * @package BuddyPress 38 * @subpackage Activity Template 39 * @since BuddyPress {unknown} 40 * 41 * @uses bp_get_activity_root_slug() 42 */ 43 function bp_activity_root_slug() { 44 echo bp_get_activity_root_slug(); 45 } 46 /** 47 * Return the activity component root slug 48 * 49 * @package BuddyPress 50 * @subpackage Activity Template 51 * @since BuddyPress {unknown} 52 */ 53 function bp_get_activity_root_slug() { 54 global $bp; 55 return apply_filters( 'bp_get_activity_root_slug', $bp->activity->root_slug ); 56 } 57 58 /** 59 * The main activity template loop 60 * 61 * This is responsible for loading a group of activity items and displaying them 62 * 63 * @package BuddyPress 64 * @subpackage Activity Template 65 * @since {unknown} 66 */ 3 67 class BP_Activity_Template { 4 68 var $current_activity = -1; … … 811 875 } 812 876 function bp_get_activity_comment_form_action() { 813 return apply_filters( 'bp_get_activity_comment_form_action', site_url( BP_ACTIVITY_SLUG . '/reply/' ) ); 877 global $bp; 878 879 return apply_filters( 'bp_get_activity_comment_form_action', home_url( $bp->activity->root_slug . '/reply/' ) ); 814 880 } 815 881 … … 838 904 } 839 905 function bp_get_activity_favorite_link() { 840 global $ activities_template;841 return apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG. '/favorite/' . $activities_template->activity->id . '/' ), 'mark_favorite' ) );906 global $bp, $activities_template; 907 return apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( home_url( $bp->activity->root_slug . '/favorite/' . $activities_template->activity->id . '/' ), 'mark_favorite' ) ); 842 908 } 843 909 … … 846 912 } 847 913 function bp_get_activity_unfavorite_link() { 848 global $ activities_template;849 return apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG. '/unfavorite/' . $activities_template->activity->id . '/' ), 'unmark_favorite' ) );914 global $bp, $activities_template; 915 return apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( home_url( $bp->activity->root_slug . '/unfavorite/' . $activities_template->activity->id . '/' ), 'unmark_favorite' ) ); 850 916 } 851 917 … … 897 963 898 964 $latest_update = '"' . apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 180 ) ) ) ) . '"'; 899 $latest_update .= ' · <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG. '/p/' . $update['id'] . '/"> ' . __( 'View', 'buddypress' ) . '</a>';965 $latest_update .= ' · <a href="' . $bp->root_domain . '/' . $bp->activity->root_slug . '/p/' . $update['id'] . '/"> ' . __( 'View', 'buddypress' ) . '</a>'; 900 966 901 967 return apply_filters( 'bp_get_activity_latest_update', $latest_update ); … … 1065 1131 } 1066 1132 function bp_get_activity_post_form_action() { 1067 return apply_filters( 'bp_get_activity_post_form_action', site_url( BP_ACTIVITY_SLUG. '/post/' ) );1133 return apply_filters( 'bp_get_activity_post_form_action', home_url( bp_get_activity_root_slug() . '/post/' ) ); 1068 1134 } 1069 1135 … … 1074 1140 } 1075 1141 function bp_get_sitewide_activity_feed_link() { 1076 global $bp; 1077 1078 return apply_filters( 'bp_get_sitewide_activity_feed_link', site_url( $bp->activity->slug . '/feed/' ) ); 1142 return apply_filters( 'bp_get_sitewide_activity_feed_link', home_url( bp_get_activity_root_slug() . '/feed/' ) ); 1079 1143 } 1080 1144 -
trunk/bp-activity/feeds/bp-activity-favorites-feed.php
r3503 r3751 5 5 * @package BuddyPress 6 6 */ 7 header('Content-Type: text/xml; charset=' . get_option( 'blog_charset'), true);7 header('Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); 8 8 header('Status: 200 OK'); 9 9 ?> 10 <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> 10 11 <?php echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>'; ?> 11 12 12 13 <rss version="2.0" … … 21 22 <title><?php bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Favorite Activity', 'buddypress' ) ?></title> 22 23 <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> 23 <link><?php echo site_url( BP_ACTIVITY_SLUG. '/#my-favorites/' ) ?></link>24 <link><?php echo home_url( bp_get_activity_root_slug() . '/#my-favorites/' ) ?></link> 24 25 <description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Favorite Activity', 'buddypress' ) ?></description> 25 26 <pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate> 26 27 <generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator> 27 28 <language><?php echo get_option('rss_language'); ?></language> 29 28 30 <?php do_action('bp_activity_favorites_feed_head'); ?> 29 31 … … 35 37 <?php if ( bp_has_activities( 'include=' . $fav_ids . '&max=50&display_comments=stream' ) ) : ?> 36 38 <?php while ( bp_activities() ) : bp_the_activity(); ?> 39 37 40 <item> 38 41 <guid><?php bp_activity_thread_permalink() ?></guid> … … 55 58 ]]> 56 59 </description> 60 57 61 <?php do_action('bp_activity_favorites_feed_item'); ?> 62 58 63 </item> 64 59 65 <?php endwhile; ?> 66 <?php endif; ?> 60 67 61 <?php endif; ?>62 68 </channel> 63 69 </rss> -
trunk/bp-activity/feeds/bp-activity-mentions-feed.php
r3503 r3751 21 21 <title><?php bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Mentions', 'buddypress' ) ?></title> 22 22 <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> 23 <link><?php echo site_url( BP_ACTIVITY_SLUG. '/#mentions/' ) ?></link>23 <link><?php echo home_url( bp_get_activity_root_slug() . '/#mentions/' ) ?></link> 24 24 <description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Mentions', 'buddypress' ) ?></description> 25 25 <pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate> -
trunk/bp-activity/feeds/bp-activity-mygroups-feed.php
r3503 r3751 21 21 <title><?php bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'My Groups - Public Activity', 'buddypress' ) ?></title> 22 22 <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> 23 <link><?php echo site_url( BP_ACTIVITY_SLUG. '/#my-groups/' ) ?></link>23 <link><?php echo home_url( bp_get_activity_root_slug() . '/#my-groups/' ) ?></link> 24 24 <description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'My Groups - Public Activity', 'buddypress' ) ?></description> 25 25 <pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate> -
trunk/bp-blogs.php
r3736 r3751 30 30 31 31 // Notifications 32 $bp->blogs-> format_notification_function= 'bp_blogs_format_notifications';32 $bp->blogs->notification_callback = 'bp_blogs_format_notifications'; 33 33 34 34 // Register this in the active components array -
trunk/bp-core.php
r3745 r3751 28 28 29 29 // Load the files containing functions that we globally will need. 30 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php' ); 30 31 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php' ); 31 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' ); … … 132 133 if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) { 133 134 if ( isset( $bp->pages->activity ) ) 134 $bp->default_component = $bp-> pages->activity->name;135 $bp->default_component = $bp->activity->id; 135 136 else 136 $bp->default_component = $bp->p ages->profile->name;137 $bp->default_component = $bp->profile->id; 137 138 } else { 138 139 $bp->default_component = BP_DEFAULT_COMPONENT; … … 188 189 do_action( 'bp_core_setup_globals' ); 189 190 } 190 add_action( 'bp_setup_globals', 'bp_core_setup_globals' );191 add_action( 'bp_setup_globals', 'bp_core_setup_globals', 1 ); 191 192 192 193 /** -
trunk/bp-core/admin/bp-core-update.php
r3745 r3751 323 323 324 324 function step_pages() { 325 global $bp; 326 325 327 if ( !current_user_can( 'activate_plugins' ) ) 326 328 return false; 327 329 330 // Determine where to get the pages from 328 331 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) 329 332 $existing_pages = get_blog_option( BP_ROOT_BLOG, 'bp-pages' ); … … 331 334 $existing_pages = get_option( 'bp-pages' ); 332 335 336 // Get disabled components 333 337 $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) ); 334 338 335 339 // Check for defined slugs 336 if ( defined( 'BP_MEMBERS_SLUG' ) && BP_MEMBERS_SLUG)337 $members_slug = constant( 'BP_MEMBERS_SLUG' );340 if ( isset( $bp->members->slug ) ) 341 $members_slug = $bp->members->slug; 338 342 else 339 $members_slug = __( 'members', 'buddypress' ); 340 341 if ( defined( 'BP_GROUPS_SLUG' ) && BP_GROUPS_SLUG ) 343 $members_slug = __( 'Members', 'buddypress' ); 344 345 // Groups 346 if ( isset( $bp->groups->slug ) ) 342 347 $groups_slug = constant( 'BP_GROUPS_SLUG' ); 343 348 else 344 $groups_slug = __( 'groups', 'buddypress' ); 345 346 if ( defined( 'BP_ACTIVITY_SLUG' ) && BP_ACTIVITY_SLUG ) 347 $activity_slug = constant( 'BP_ACTIVITY_SLUG' ); 349 $groups_slug = __( 'Groups', 'buddypress' ); 350 351 // Activity 352 if ( isset( $bp->activity->slug ) ) 353 $activity_slug = $bp->activity->slug; 348 354 else 349 355 $activity_slug = __( 'activity', 'buddypress' ); 350 356 351 if ( defined( 'BP_FORUMS_SLUG' ) && BP_FORUMS_SLUG ) 352 $forums_slug = constant( 'BP_FORUMS_SLUG' ); 357 // Forums 358 if ( isset( $bp->forums->slug ) ) 359 $forums_slug = $bp->forums->slug; 353 360 else 354 361 $forums_slug = __( 'forums', 'buddypress' ); 355 362 356 if ( defined( 'BP_BLOGS_SLUG' ) && BP_BLOGS_SLUG ) 357 $blogs_slug = constant( 'BP_BLOGS_SLUG' ); 363 // Blogs 364 if ( isset( $bp->blogs->slug ) ) 365 $blogs_slug = $bp->blogs->slug; 358 366 else 359 367 $blogs_slug = __( 'blogs', 'buddypress' ); 360 368 361 if ( defined( 'BP_REGISTER_SLUG' ) && BP_REGISTER_SLUG ) 362 $register_slug = constant( 'BP_REGISTER_SLUG' ); 369 // Register 370 if ( isset( $bp->register->slug ) ) 371 $register_slug = $bp->register->slug; 363 372 else 364 373 $register_slug = __( 'register', 'buddypress' ); 365 374 366 if ( defined( 'BP_ACTIVATION_SLUG' ) && BP_ACTIVATION_SLUG)367 $activation_slug = constant( 'BP_ACTIVATION_SLUG' );375 if ( isset( $bp->activation->slug ) ) 376 $activation_slug = $bp->activation->slug; 368 377 else 369 378 $activation_slug = __( 'activate', 'buddypress' ); 370 379 380 // What kind of setup is taking place 371 381 if ( 'new' == $this->setup_type ) : ?> 372 382 -
trunk/bp-core/bp-core-notifications.php
r3357 r3751 60 60 continue; 61 61 62 if ( function_exists( $bp->{$component_name}-> format_notification_function) ) {63 $renderable[] = call_user_func( $bp->{$component_name}-> format_notification_function, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );62 if ( function_exists( $bp->{$component_name}->notification_callback ) ) { 63 $renderable[] = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count ); 64 64 } 65 65 } -
trunk/bp-core/bp-core-templatetags.php
r3749 r3751 390 390 391 391 if ( !empty( $update['id'] ) ) 392 $update_content .= ' · <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG. '/p/' . $update['id'] . '">' . __( 'View', 'buddypress' ) . '</a>';392 $update_content .= ' · <a href="' . $bp->root_domain . '/' . $bp->activity->root_slug . '/p/' . $update['id'] . '">' . __( 'View', 'buddypress' ) . '</a>'; 393 393 394 394 return apply_filters( 'bp_get_member_latest_update', $update_content ); … … 1774 1774 } 1775 1775 1776 function bp_is_page( $page) {1776 function bp_is_page( $page ) { 1777 1777 global $bp; 1778 1778 … … 1796 1796 1797 1797 function bp_is_profile_component() { 1798 if ( bp_is_current_component( BP_XPROFILE_SLUG) )1798 if ( bp_is_current_component( 'xprofile' ) ) 1799 1799 return true; 1800 1800 … … 1803 1803 1804 1804 function bp_is_activity_component() { 1805 if ( defined( 'BP_ACTIVITY_SLUG' ) && bp_is_current_component( BP_ACTIVITY_SLUG) )1805 if ( bp_is_current_component( 'activity' ) ) 1806 1806 return true; 1807 1807 … … 1810 1810 1811 1811 function bp_is_blogs_component() { 1812 if ( is_multisite() && defined( 'BP_BLOGS_SLUG' ) && bp_is_current_component( BP_BLOGS_SLUG) )1812 if ( is_multisite() && bp_is_current_component( 'blogs' ) ) 1813 1813 return true; 1814 1814 … … 1817 1817 1818 1818 function bp_is_messages_component() { 1819 if ( defined( 'BP_MESSAGES_SLUG' ) && bp_is_current_component( BP_MESSAGES_SLUG) )1819 if ( bp_is_current_component( 'messages' ) ) 1820 1820 return true; 1821 1821 … … 1824 1824 1825 1825 function bp_is_friends_component() { 1826 if ( defined( 'BP_FRIENDS_SLUG' ) && bp_is_current_component( BP_FRIENDS_SLUG ) ) 1826 1827 if ( bp_is_current_component( 'friends' ) ) 1827 1828 return true; 1828 1829 … … 1831 1832 1832 1833 function bp_is_groups_component() { 1833 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) )1834 if ( bp_is_current_component( 'groups' ) ) 1834 1835 return true; 1835 1836 … … 1838 1839 1839 1840 function bp_is_settings_component() { 1840 if ( bp_is_current_component( BP_SETTINGS_SLUG) )1841 if ( bp_is_current_component( 'settings' ) ) 1841 1842 return true; 1842 1843 … … 1856 1857 global $bp; 1857 1858 1858 if ( !empty( $bp->activity->slug ) && bp_is_current_component( $bp->activity->slug) )1859 if ( bp_is_current_component( 'activity' ) ) 1859 1860 return true; 1860 1861 … … 1865 1866 global $bp; 1866 1867 1867 if ( !empty( $bp->activity->slug ) && bp_is_current_component( $bp->activity->slug) && 'my-friends' == $bp->current_action )1868 if ( bp_is_current_component( 'activity' ) && 'my-friends' == $bp->current_action ) 1868 1869 return true; 1869 1870 … … 1874 1875 global $bp; 1875 1876 1876 if ( defined( 'BP_ACTIVITY_SLUG' ) && bp_is_current_component( BP_ACTIVITY_SLUG) && is_numeric( $bp->current_action ) )1877 if ( bp_is_current_component( 'activity' ) && is_numeric( $bp->current_action ) ) 1877 1878 return true; 1878 1879 … … 1883 1884 global $bp; 1884 1885 1885 if ( defined( 'BP_XPROFILE_SLUG' ) && bp_is_current_component( BP_XPROFILE_SLUG ) || isset( $bp->core->profile->slug ) && bp_is_current_component( $bp->core->profile->slug) )1886 if ( bp_is_current_component( 'xprofile' ) ) 1886 1887 return true; 1887 1888 … … 1892 1893 global $bp; 1893 1894 1894 if ( defined( 'BP_XPROFILE_SLUG' ) && bp_is_current_component( BP_XPROFILE_SLUG) && 'edit' == $bp->current_action )1895 if ( bp_is_current_component( 'xprofile' ) && 'edit' == $bp->current_action ) 1895 1896 return true; 1896 1897 … … 1901 1902 global $bp; 1902 1903 1903 if ( defined( 'BP_XPROFILE_SLUG' ) && bp_is_current_component( BP_XPROFILE_SLUG) && 'change-avatar' == $bp->current_action )1904 if ( bp_is_current_component( 'xprofile' ) && 'change-avatar' == $bp->current_action ) 1904 1905 return true; 1905 1906 … … 1910 1911 global $bp; 1911 1912 1912 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) )1913 if ( bp_is_current_component( 'groups' ) ) 1913 1914 return true; 1914 1915 … … 1919 1920 global $bp; 1920 1921 1921 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && isset( $bp->groups->current_group ) && $bp->groups->current_group )1922 if ( bp_is_current_component( 'groups' ) && isset( $bp->groups->current_group ) && $bp->groups->current_group ) 1922 1923 return true; 1923 1924 … … 1928 1929 global $bp; 1929 1930 1930 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )1931 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) ) 1931 1932 return true; 1932 1933 … … 1937 1938 global $bp; 1938 1939 1939 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && 'create' == $bp->current_action )1940 if ( bp_is_current_component( 'groups' ) && 'create' == $bp->current_action ) 1940 1941 return true; 1941 1942 … … 1947 1948 global $bp; 1948 1949 1949 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item && 'admin' == $bp->current_action )1950 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'admin' == $bp->current_action ) 1950 1951 return true; 1951 1952 … … 1956 1957 global $bp; 1957 1958 1958 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item && 'forum' == $bp->current_action )1959 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action ) 1959 1960 return true; 1960 1961 … … 1965 1966 global $bp; 1966 1967 1967 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item && 'activity' == $bp->current_action )1968 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'activity' == $bp->current_action ) 1968 1969 return true; 1969 1970 … … 1974 1975 global $bp; 1975 1976 1976 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )1977 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] ) 1977 1978 return true; 1978 1979 … … 1983 1984 global $bp; 1984 1985 1985 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] )1986 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] ) 1986 1987 return true; 1987 1988 … … 1992 1993 global $bp; 1993 1994 1994 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item && 'members' == $bp->current_action )1995 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'members' == $bp->current_action ) 1995 1996 return true; 1996 1997 … … 2001 2002 global $bp; 2002 2003 2003 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && 'send-invites' == $bp->current_action )2004 if ( bp_is_current_component( 'groups' ) && 'send-invites' == $bp->current_action ) 2004 2005 return true; 2005 2006 … … 2010 2011 global $bp; 2011 2012 2012 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && 'request-membership' == $bp->current_action )2013 if ( bp_is_current_component( 'groups' ) && 'request-membership' == $bp->current_action ) 2013 2014 return true; 2014 2015 … … 2019 2020 global $bp; 2020 2021 2021 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item && 'leave-group' == $bp->current_action )2022 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'leave-group' == $bp->current_action ) 2022 2023 return true; 2023 2024 … … 2028 2029 global $bp; 2029 2030 2030 if ( defined( 'BP_GROUPS_SLUG' ) && bp_is_current_component( BP_GROUPS_SLUG) && $bp->is_single_item )2031 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item ) 2031 2032 return true; 2032 2033 … … 2037 2038 global $bp; 2038 2039 2039 if ( is_multisite() && defined( 'BP_BLOGS_SLUG' ) && bp_is_current_component( BP_BLOGS_SLUG) )2040 if ( is_multisite() && bp_is_current_component( 'blogs' ) ) 2040 2041 return true; 2041 2042 … … 2046 2047 global $bp; 2047 2048 2048 if ( is_multisite() && defined( 'BP_BLOGS_SLUG' ) && bp_is_current_component( BP_BLOGS_SLUG) && 'recent-posts' == $bp->current_action )2049 if ( is_multisite() && bp_is_current_component( 'blogs' ) && 'recent-posts' == $bp->current_action ) 2049 2050 return true; 2050 2051 … … 2055 2056 global $bp; 2056 2057 2057 if ( is_multisite() && defined( 'BP_BLOGS_SLUG' ) && bp_is_current_component( BP_BLOGS_SLUG) && 'recent-comments' == $bp->current_action )2058 if ( is_multisite() && bp_is_current_component( 'blogs' ) && 'recent-comments' == $bp->current_action ) 2058 2059 return true; 2059 2060 … … 2064 2065 global $bp; 2065 2066 2066 if ( is_multisite() && defined( 'BP_BLOGS_SLUG' ) && bp_is_current_component( BP_BLOGS_SLUG) && 'create' == $bp->current_action )2067 if ( is_multisite() && bp_is_current_component( 'blogs' ) && 'create' == $bp->current_action ) 2067 2068 return true; 2068 2069 … … 2071 2072 2072 2073 function bp_is_user_friends() { 2073 if ( defined( 'BP_FRIENDS_SLUG' ) && bp_is_current_component( BP_FRIENDS_SLUG ) ) 2074 2075 if ( bp_is_current_component( 'friends' ) ) 2074 2076 return true; 2075 2077 … … 2080 2082 global $bp; 2081 2083 2082 if ( defined( 'BP_FRIENDS_SLUG' ) && bp_is_current_component( BP_FRIENDS_SLUG) && 'requests' == $bp->current_action )2084 if ( bp_is_current_component( 'friends' ) && 'requests' == $bp->current_action ) 2083 2085 return true; 2084 2086 … … 2087 2089 2088 2090 function bp_is_user_messages() { 2089 if ( defined( 'BP_MESSAGES_SLUG' ) && bp_is_current_component( BP_MESSAGES_SLUG ) ) 2091 2092 if ( bp_is_current_component( 'messages' ) ) 2090 2093 return true; 2091 2094 … … 2096 2099 global $bp; 2097 2100 2098 if ( defined( 'BP_MESSAGES_SLUG' ) && bp_is_current_component( BP_MESSAGES_SLUG) && ( !$bp->current_action || 'inbox' == $bp->current_action ) )2101 if ( bp_is_current_component( 'messages' ) && ( !$bp->current_action || 'inbox' == $bp->current_action ) ) 2099 2102 return true; 2100 2103 … … 2105 2108 global $bp; 2106 2109 2107 if ( defined( 'BP_MESSAGES_SLUG' ) && bp_is_current_component( BP_MESSAGES_SLUG) && 'sentbox' == $bp->current_action )2110 if ( bp_is_current_component( 'messages' ) && 'sentbox' == $bp->current_action ) 2108 2111 return true; 2109 2112 … … 2115 2118 global $bp; 2116 2119 2117 if ( defined( 'BP_MESSAGES_SLUG' ) && bp_is_current_component( BP_MESSAGES_SLUG) && 'notices' == $bp->current_action )2120 if ( bp_is_current_component( 'messages' ) && 'notices' == $bp->current_action ) 2118 2121 return true; 2119 2122 … … 2125 2128 global $bp; 2126 2129 2127 if ( defined( 'BP_MESSAGES_SLUG' ) && bp_is_current_component( BP_MESSAGES_SLUG) && 'compose' == $bp->current_action )2130 if ( bp_is_current_component( 'messages' ) && 'compose' == $bp->current_action ) 2128 2131 return true; 2129 2132 … … 2141 2144 2142 2145 function bp_is_activation_page() { 2143 if ( bp_is_current_component( BP_ACTIVATION_SLUG) )2146 if ( bp_is_current_component( 'activation' ) ) 2144 2147 return true; 2145 2148 … … 2148 2151 2149 2152 function bp_is_register_page() { 2150 if ( bp_is_current_component( BP_REGISTER_SLUG) )2153 if ( bp_is_current_component( 'register' ) ) 2151 2154 return true; 2152 2155 -
trunk/bp-core/css/admin.dev.css
r3745 r3751 1 html {2 padding-top: 28px !important;3 }4 5 1 div#bp-admin { 6 2 margin: 25px 15px 25px 0; -
trunk/bp-friends.php
r3742 r3751 24 24 25 25 // Notifications 26 $bp->friends-> format_notification_function= 'friends_format_notifications';26 $bp->friends->notification_callback = 'friends_format_notifications'; 27 27 28 28 // Register this in the active components array -
trunk/bp-groups.php
r3728 r3751 34 34 35 35 // Notifications 36 $bp->groups-> format_notification_function= 'groups_format_notifications';36 $bp->groups->notification_callback = 'groups_format_notifications'; 37 37 38 38 // Register this in the active components array -
trunk/bp-messages.php
r3728 r3751 25 25 26 26 // Notifications 27 $bp->messages-> format_notification_function= 'messages_format_notifications';27 $bp->messages->notification_callback = 'messages_format_notifications'; 28 28 29 29 // Register this in the active components array -
trunk/bp-themes/bp-default/_inc/ajax.php
r3698 r3751 95 95 add_action( 'wp_ajax_forums_filter', 'bp_dtheme_object_template_loader' ); 96 96 97 / * This function will load the activity loop template when activity is requested via AJAX */97 // This function will load the activity loop template when activity is requested via AJAX 98 98 function bp_dtheme_activity_template_loader() { 99 99 global $bp; 100 100 101 / * We need to calculate and return the feed URL for each scope */102 $feed_url = site_url( BP_ACTIVITY_SLUG. '/feed/' );101 // We need to calculate and return the feed URL for each scope 102 $feed_url = home_url( bp_get_activity_root_slug() . '/feed/' ); 103 103 104 104 switch ( $_POST['scope'] ) { 105 105 case 'friends': 106 $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG. '/friends/feed/';106 $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/friends/feed/'; 107 107 break; 108 108 case 'groups': 109 $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG. '/groups/feed/';109 $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/groups/feed/'; 110 110 break; 111 111 case 'favorites': 112 $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG. '/favorites/feed/';112 $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/favorites/feed/'; 113 113 break; 114 114 case 'mentions': 115 $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG. '/mentions/feed/';115 $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/mentions/feed/'; 116 116 delete_user_meta( $bp->loggedin_user->id, 'bp_new_mention_count' ); 117 117 break; -
trunk/bp-themes/bp-default/activity/index.php
r3698 r3751 1 <?php 2 3 /** 4 * Template Name: BuddyPress - Activity Directory 5 * 6 * @package bbPress 7 * @subpackage Theme 8 */ 9 10 ?> 11 1 12 <?php get_header() ?> 2 13 … … 5 16 6 17 <?php if ( !is_user_logged_in() ) : ?> 18 7 19 <h3><?php _e( 'Site Activity', 'buddypress' ) ?></h3> 20 8 21 <?php endif; ?> 9 22 … … 11 24 12 25 <?php if ( is_user_logged_in() ) : ?> 26 13 27 <?php locate_template( array( 'activity/post-form.php'), true ) ?> 28 14 29 <?php endif; ?> 15 30 … … 20 35 <?php do_action( 'bp_before_activity_type_tab_all' ) ?> 21 36 22 <li class="selected" id="activity-all"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG. '/' ?>" title="<?php _e( 'The public activity for everyone on this site.', 'buddypress' ) ?>"><?php printf( __( 'All Members (%s)', 'buddypress' ), bp_get_total_site_member_count() ) ?></a></li>37 <li class="selected" id="activity-all"><a href="<?php echo bp_loggedin_user_domain() . bp_get_group_slug() . '/' ?>" title="<?php _e( 'The public activity for everyone on this site.', 'buddypress' ) ?>"><?php printf( __( 'All Members (%s)', 'buddypress' ), bp_get_total_site_member_count() ) ?></a></li> 23 38 24 39 <?php if ( is_user_logged_in() ) : ?> … … 27 42 28 43 <?php if ( bp_is_active( 'friends' ) ) : ?> 44 29 45 <?php if ( bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?> 30 <li id="activity-friends"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/' . BP_FRIENDS_SLUG . '/' ?>" title="<?php _e( 'The activity of my friends only.', 'buddypress' ) ?>"><?php printf( __( 'My Friends (%s)', 'buddypress' ), bp_get_total_friend_count( bp_loggedin_user_id() ) ) ?></a></li> 46 47 <li id="activity-friends"><a href="<?php echo bp_loggedin_user_domain() . bp_get_group_slug() . '/' . BP_FRIENDS_SLUG . '/' ?>" title="<?php _e( 'The activity of my friends only.', 'buddypress' ) ?>"><?php printf( __( 'My Friends (%s)', 'buddypress' ), bp_get_total_friend_count( bp_loggedin_user_id() ) ) ?></a></li> 48 31 49 <?php endif; ?> 50 32 51 <?php endif; ?> 33 52 … … 35 54 36 55 <?php if ( bp_is_active( 'groups' ) ) : ?> 56 37 57 <?php if ( bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) : ?> 38 <li id="activity-groups"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/' . BP_GROUPS_SLUG . '/' ?>" title="<?php _e( 'The activity of groups I am a member of.', 'buddypress' ) ?>"><?php printf( __( 'My Groups (%s)', 'buddypress' ), bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) ?></a></li> 58 59 <li id="activity-groups"><a href="<?php echo bp_loggedin_user_domain() . bp_get_group_slug() . '/' . BP_GROUPS_SLUG . '/' ?>" title="<?php _e( 'The activity of groups I am a member of.', 'buddypress' ) ?>"><?php printf( __( 'My Groups (%s)', 'buddypress' ), bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) ?></a></li> 60 39 61 <?php endif; ?> 62 40 63 <?php endif; ?> 41 64 … … 43 66 44 67 <?php if ( bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ) : ?> 45 <li id="activity-favorites"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/favorites/' ?>" title="<?php _e( "The activity I've marked as a favorite.", 'buddypress' ) ?>"><?php printf( __( 'My Favorites (<span>%s</span>)', 'buddypress' ), bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ) ?></a></li> 68 69 <li id="activity-favorites"><a href="<?php echo bp_loggedin_user_domain() . bp_get_group_slug() . '/favorites/' ?>" title="<?php _e( "The activity I've marked as a favorite.", 'buddypress' ) ?>"><?php printf( __( 'My Favorites (<span>%s</span>)', 'buddypress' ), bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ) ?></a></li> 70 46 71 <?php endif; ?> 47 72 48 73 <?php do_action( 'bp_before_activity_type_tab_mentions' ) ?> 49 74 50 <li id="activity-mentions"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG. '/mentions/' ?>" title="<?php _e( 'Activity that I have been mentioned in.', 'buddypress' ) ?>"><?php printf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() ) ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><?php printf( __( '(%s new)', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) ?></strong><?php endif; ?></a></li>75 <li id="activity-mentions"><a href="<?php echo bp_loggedin_user_domain() . bp_get_group_slug() . '/mentions/' ?>" title="<?php _e( 'Activity that I have been mentioned in.', 'buddypress' ) ?>"><?php printf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() ) ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><?php printf( __( '(%s new)', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) ?></strong><?php endif; ?></a></li> 51 76 52 77 <?php endif; ?> … … 68 93 69 94 <?php if ( bp_is_active( 'blogs' ) ) : ?> 95 70 96 <option value="new_blog_post"><?php _e( 'Show Blog Posts', 'buddypress' ) ?></option> 71 97 <option value="new_blog_comment"><?php _e( 'Show Blog Comments', 'buddypress' ) ?></option> 98 72 99 <?php endif; ?> 73 100 74 101 <?php if ( bp_is_active( 'forums' ) ) : ?> 75 <option value="new_forum_topic"><?php _e( 'Show New Forum Topics', 'buddypress' ) ?></option> 76 <option value="new_forum_post"><?php _e( 'Show Forum Replies', 'buddypress' ) ?></option> 102 103 <option value="new_forum_topic"><?php _e( 'Show New Forum Topics', 'buddypress' ); ?></option> 104 <option value="new_forum_post"><?php _e( 'Show Forum Replies', 'buddypress' ); ?></option> 105 77 106 <?php endif; ?> 78 107 79 108 <?php if ( bp_is_active( 'groups' ) ) : ?> 80 <option value="created_group"><?php _e( 'Show New Groups', 'buddypress' ) ?></option> 81 <option value="joined_group"><?php _e( 'Show New Group Memberships', 'buddypress' ) ?></option> 109 110 <option value="created_group"><?php _e( 'Show New Groups', 'buddypress' ); ?></option> 111 <option value="joined_group"><?php _e( 'Show New Group Memberships', 'buddypress' ); ?></option> 112 82 113 <?php endif; ?> 83 114 84 115 <?php if ( bp_is_active( 'friends' ) ) : ?> 85 <option value="friendship_accepted,friendship_created"><?php _e( 'Show Friendship Connections', 'buddypress' ) ?></option> 116 117 <option value="friendship_accepted,friendship_created"><?php _e( 'Show Friendship Connections', 'buddypress' ); ?></option> 118 86 119 <?php endif; ?> 87 120 88 <option value="new_member"><?php _e( 'Show New Members', 'buddypress' ) ?></option>121 <option value="new_member"><?php _e( 'Show New Members', 'buddypress' ); ?></option> 89 122 90 <?php do_action( 'bp_activity_filter_options' ) ?> 123 <?php do_action( 'bp_activity_filter_options' ); ?> 124 91 125 </select> 92 126 </li> … … 97 131 98 132 <div class="activity" role="main"> 133 99 134 <?php locate_template( array( 'activity/activity-loop.php' ), true ) ?> 135 100 136 </div><!-- .activity --> 101 137 … … 107 143 </div><!-- #content --> 108 144 109 145 <?php get_sidebar() ?> 110 146 111 147 <?php get_footer() ?> -
trunk/bp-xprofile.php
r3728 r3751 43 43 44 44 // Notifications 45 $bp->profile-> format_notification_function= 'xprofile_format_notifications';45 $bp->profile->notification_callback = 'xprofile_format_notifications'; 46 46 47 47 // Register this in the active components array
Note: See TracChangeset
for help on using the changeset viewer.