Changeset 3728
- Timestamp:
- 01/18/2011 12:53:31 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r3666 r3728 1 1 <?php 2 3 // Required Files 2 4 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' ); 3 5 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' ); … … 7 9 global $bp, $current_blog; 8 10 11 // Define a slug, if necessary 9 12 if ( !defined( 'BP_ACTIVITY_SLUG' ) ) 10 define ( 'BP_ACTIVITY_SLUG', $bp->pages->activity->slug );13 define( 'BP_ACTIVITY_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->activity->slug ) ); 11 14 12 15 // For internal identification 13 $bp->activity->id = 'activity';16 $bp->activity->id = 'activity'; 14 17 $bp->activity->name = $bp->pages->activity->name; 15 $bp->activity->slug = BP_ACTIVITY_SLUG; 16 18 19 // Slugs 20 $bp->activity->slug = BP_ACTIVITY_SLUG; 21 $bp->activity->root_slug = $bp->pages->activity->slug; 22 23 // Tables 17 24 $bp->activity->table_name = $bp->table_prefix . 'bp_activity'; 18 25 $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta'; 19 26 27 // Notifications 20 28 $bp->activity->format_notification_function = 'bp_activity_format_notifications'; 21 29 … … 38 46 $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; 39 47 $user_login = ( isset( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login; 40 $activity_link = $user_domain . $bp->activity-> name. '/';48 $activity_link = $user_domain . $bp->activity->slug . '/'; 41 49 42 50 /* Add the subnav items to the activity nav item if we are using a theme that supports this */ … … 44 52 45 53 if ( bp_is_active( 'friends' ) ) 46 bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity-> name, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-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' ) ); 47 55 48 56 if ( bp_is_active( 'groups' ) ) 49 bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity-> name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-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' ) ); 50 58 51 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 68 } 61 69 } 62 70 63 71 do_action( 'bp_activity_setup_nav' ); 64 72 } -
trunk/bp-activity/bp-activity-templatetags.php
r3685 r3728 176 176 177 177 // The default scope should recognize custom slugs 178 if ( array_key_exists( $bp->current_action, (array)$bp->active_components ) ) {178 if ( array_key_exists( $bp->current_action, (array)$bp->active_components ) ) 179 179 $scope = $bp->active_components[$bp->current_action]; 180 } else {180 else 181 181 $scope = $bp->current_action; 182 } 183 184 /* Support for permalinks on single item pages: /groups/my-group/activity/124/ */ 182 183 // Support for permalinks on single item pages: /groups/my-group/activity/124/ 185 184 if ( $bp->current_action == $bp->activity->slug ) 186 185 $include = $bp->action_variables[0]; 187 186 188 / * Note: any params used for filtering can be a single value, or multiple values comma separated. */187 // Note: any params used for filtering can be a single value, or multiple values comma separated. 189 188 $defaults = array( 190 'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items191 'include' => $include,// pass an activity_id or string of IDs comma-separated192 'exclude' => $exclude,// pass an activity_id or string of IDs comma-separated193 'in' => $in,// comma-separated list or array of activity IDs among which to search194 'sort' => 'DESC',// sort DESC or ASC195 'page' => 1,// which page to load196 'per_page' => 20,// number of items per page197 'max' => false,// max number to return198 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?199 200 / * Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) */201 'scope' => $bp->current_action,202 203 / * Filtering */204 'user_id' => $user_id,// user_id to filter on205 'object' => $object,// object to filter on e.g. groups, profile, status, friends206 'action' => false,// action to filter on e.g. activity_update, new_forum_post, profile_updated207 'primary_id' => $primary_id,// object ID to filter on e.g. a group_id or forum_id or blog_id etc.208 'secondary_id' => false,// secondary object ID to filter on e.g. a post_id209 210 / * Searching */211 'search_terms' => false// specify terms to search on189 'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items 190 'include' => $include, // pass an activity_id or string of IDs comma-separated 191 'exclude' => $exclude, // pass an activity_id or string of IDs comma-separated 192 'in' => $in, // comma-separated list or array of activity IDs among which to search 193 'sort' => 'DESC', // sort DESC or ASC 194 'page' => 1, // which page to load 195 'per_page' => 20, // number of items per page 196 'max' => false, // max number to return 197 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide? 198 199 // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) 200 'scope' => $scope, 201 202 // Filtering 203 'user_id' => $user_id, // user_id to filter on 204 'object' => $object, // object to filter on e.g. groups, profile, status, friends 205 'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated 206 'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc. 207 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id 208 209 // Searching 210 'search_terms' => false // specify terms to search on 212 211 ); 213 212 … … 215 214 extract( $r ); 216 215 217 / * If you have passed a "scope" then this will override any filters you have passed. */216 // If you have passed a "scope" then this will override any filters you have passed. 218 217 if ( 'just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope ) { 219 218 if ( 'just-me' == $scope ) … … 272 271 } 273 272 274 /* Support for basic filters in earlier BP versions. */ 275 $filter = false; 273 // Support for basic filters in earlier BP versions. 276 274 if ( isset( $_GET['afilter'] ) ) 277 275 $filter = array( 'object' => $_GET['afilter'] ); 278 276 else if ( !empty( $user_id ) || !empty( $object ) || !empty( $action ) || !empty( $primary_id ) || !empty( $secondary_id ) ) 279 277 $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id ); 278 else 279 $filter = false; 280 280 281 281 $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in ); -
trunk/bp-blogs.php
r3708 r3728 1 1 <?php 2 3 // Required Files 2 4 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' ); 3 5 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' ); 4 6 5 / * Include the sitewide blog posts widget if this is a multisite installation */7 // Include the sitewide blog posts widget if this is a multisite installation 6 8 if ( is_multisite() ) 7 9 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' ); … … 11 13 12 14 if ( !defined( 'BP_BLOGS_SLUG' ) && isset( $bp->pages->blogs->slug ) ) 13 define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug);14 else if( !defined( 'BP_BLOGS_SLUG' ) )15 define ( 'BP_BLOGS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->blogs->slug ) ); 16 else if( !defined( 'BP_BLOGS_SLUG' ) ) 15 17 define ( 'BP_BLOGS_SLUG', 'blogs' ); 16 18 17 19 // For internal identification 18 $bp->blogs->id = 'blogs'; 19 20 $bp->blogs->slug = BP_BLOGS_SLUG; 21 20 $bp->blogs->id = 'blogs'; 21 $bp->blogs->name = $bp->pages->blogs->name; 22 23 // Slugs 24 $bp->blogs->slug = BP_BLOGS_SLUG; 25 $bp->blogs->root_slug = $bp->pages->blogs->slug; 26 27 // Tables 22 28 $bp->blogs->table_name = $bp->table_prefix . 'bp_user_blogs'; 23 29 $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta'; 24 30 25 $bp->blogs->format_notification_function = 'bp_blogs_format_notifications'; 31 // Notifications 32 $bp->blogs->format_notification_function = 'bp_blogs_format_notifications'; 26 33 27 34 // Register this in the active components array 28 $bp->active_components[$bp->blogs->slug] = $bp->blogs->id;35 $bp->active_components[$bp->blogs->slug] = $bp->blogs->id; 29 36 30 37 // The default text for the blogs directory search box … … 36 43 37 44 /** 38 * bp_blogs_setup_nav()39 *40 45 * Adds "Blog" to the navigation arrays for the current and logged in user. 41 46 * … … 47 52 global $bp; 48 53 49 /* Blog/post/comment menus should not appear on single WordPress setups. Although comments 50 and posts made by users will still show on their activity stream .*/ 54 /** 55 * Blog/post/comment menus should not appear on single WordPress setups. 56 * Although comments and posts made by users will still show on their 57 * activity stream. 58 */ 51 59 if ( !is_multisite() ) 52 60 return false; 53 61 54 / * Add 'Blogs' to the main navigation */62 // Add 'Blogs' to the main navigation 55 63 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) ); 56 64 57 65 $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/'; 58 66 59 / * Set up the component options navigation for Blog */67 // Set up the component options navigation for Blog 60 68 if ( $bp->blogs->slug == $bp->current_component ) { 61 69 if ( bp_is_my_profile() ) { … … 64 72 } 65 73 } else { 66 /* If we are not viewing the logged in user, set up the current users avatar and name */ 74 // If we are not viewing the logged in user, set up the current 75 // users avatar and name 67 76 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 68 77 $bp->bp_options_title = $bp->displayed_user->fullname; … … 87 96 88 97 89 /******************************************************************************* *98 /******************************************************************************* 90 99 * Screen Functions 91 100 * … … 117 126 bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) ); 118 127 } 119 /* The create screen is not attached to a nav item, so we need to attach it to an action */120 128 add_action( 'wp', 'bp_blogs_screen_create_a_blog', 3 ); 121 129 122 130 123 /******************************************************************************* *131 /******************************************************************************* 124 132 * Activity & Notification Functions 125 133 * … … 148 156 return false; 149 157 150 /* Because blog, comment, and blog post code execution happens before anything else 151 we may need to manually instantiate the activity component globals */ 158 /** 159 * Because blog, comment, and blog post code execution happens before 160 * anything else we may need to manually instantiate the activity 161 * component globals. 162 */ 152 163 if ( !$bp->activity && function_exists('bp_activity_setup_globals') ) 153 164 bp_activity_setup_globals(); 154 165 155 166 $defaults = array( 156 'user_id' => $bp->loggedin_user->id,157 'action' => '',158 'content' => '',159 'primary_link' => '',160 'component' => $bp->blogs->id,161 'type' => false,162 'item_id' => false,167 'user_id' => $bp->loggedin_user->id, 168 'action' => '', 169 'content' => '', 170 'primary_link' => '', 171 'component' => $bp->blogs->id, 172 'type' => false, 173 'item_id' => false, 163 174 'secondary_item_id' => false, 164 'recorded_time' => bp_core_current_time(),165 'hide_sitewide' => false175 'recorded_time' => bp_core_current_time(), 176 'hide_sitewide' => false 166 177 ); 167 178 … … 169 180 extract( $r, EXTR_SKIP ); 170 181 171 / * Remove large images and replace them with just one image thumbnail */182 // Remove large images and replace them with just one image thumbnail 172 183 if ( function_exists( 'bp_activity_thumbnail_content_images' ) && !empty( $content ) ) 173 184 $content = bp_activity_thumbnail_content_images( $content, $primary_link ); … … 179 190 $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content ); 180 191 181 / * Check for an existing entry and update if one exists. */192 // Check for an existing entry and update if one exists. 182 193 $id = bp_activity_get_activity_id( array( 183 194 'user_id' => $user_id, … … 194 205 global $bp; 195 206 196 if ( function_exists( 'bp_activity_delete_by_item_id') ) {207 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 197 208 $defaults = array( 198 'item_id' => false,199 'component' => $bp->blogs->id,200 'type' => false,201 'user_id' => false,209 'item_id' => false, 210 'component' => $bp->blogs->id, 211 'type' => false, 212 'user_id' => false, 202 213 'secondary_item_id' => false 203 214 ); … … 229 240 230 241 $defaults = array( 231 'type' => 'active', // active, alphabetical, newest, or random. 232 'user_id' => false, // Pass a user_id to limit to only blogs that this user has privilages higher than subscriber on. 233 'search_terms' => false, // Limit to blogs that match these search terms 234 235 'per_page' => 20, // The number of results to return per page 236 'page' => 1, // The page to return if limiting per page 242 'type' => 'active', // active, alphabetical, newest, or random 243 'user_id' => false, // Pass a user_id to limit to only blogs that this user has privilages higher than subscriber on 244 'search_terms' => false, // Limit to blogs that match these search terms 245 'per_page' => 20, // The number of results to return per page 246 'page' => 1, // The page to return if limiting per page 237 247 ); 238 248 … … 246 256 global $bp, $wpdb; 247 257 248 / * Truncate user blogs table and re-record. */258 // Truncate user blogs table and re-record. 249 259 $wpdb->query( "TRUNCATE TABLE {$bp->blogs->table_name}" ); 250 260 … … 320 330 321 331 /** 322 * bp_blogs_update_option_blogname()323 *324 332 * Updates blogname in BuddyPress blogmeta table 325 333 * … … 330 338 function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) { 331 339 global $wpdb; 340 332 341 bp_blogs_update_blogmeta( $wpdb->blogid, 'name', $newvalue ); 333 342 } … … 335 344 336 345 /** 337 * bp_blogs_update_option_blogdescription()338 *339 346 * Updates blogdescription in BuddyPress blogmeta table 340 347 * … … 345 352 function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) { 346 353 global $wpdb; 354 347 355 bp_blogs_update_blogmeta( $wpdb->blogid, 'description', $newvalue ); 348 356 } … … 380 388 381 389 bp_blogs_record_activity( array( 382 'user_id' 390 'user_id' => (int)$post->post_author, 383 391 'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ), 384 392 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ), … … 402 410 403 411 /** 404 * bp_blogs_record_comment()405 *406 412 * Record blog comment activity. Checks if blog is public and post is not 407 413 * password protected. … … 428 434 429 435 // Get the user_id from the comment author email. 430 $user = get_user_by_email( $recorded_comment->comment_author_email );436 $user = get_user_by_email( $recorded_comment->comment_author_email ); 431 437 $user_id = (int)$user->ID; 432 438 … … 436 442 437 443 // Get blog and post data 438 $blog_id = (int)$wpdb->blogid;444 $blog_id = (int)$wpdb->blogid; 439 445 $recorded_comment->post = get_post( $recorded_comment->comment_post_ID ); 440 446 … … 451 457 452 458 // Prepare to record in activity streams 453 if ( is_multisite() ) { 454 $activity_action = sprintf( __( '%1$s commented on the blog post %2$s on the blog %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ); 455 } else { 456 $activity_action = sprintf( __( '%1$s commented on the blog post %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' ); 457 } 459 if ( is_multisite() ) 460 $activity_action = sprintf( __( '%1$s commented on the blog post %2$s on the blog %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ); 461 else 462 $activity_action = sprintf( __( '%1$s commented on the blog post %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' ); 458 463 459 464 $activity_content = $recorded_comment->comment_content; … … 478 483 } 479 484 add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 480 add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );485 add_action( 'edit_comment', 'bp_blogs_record_comment', 10 ); 481 486 482 487 function bp_blogs_manage_comment( $comment_id, $comment_status ) { … … 509 514 } 510 515 add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 ); 511 add_action( 'profile_update', 'bp_blogs_add_user_to_blog');512 add_action( 'user_register', 'bp_blogs_add_user_to_blog');516 add_action( 'profile_update', 'bp_blogs_add_user_to_blog' ); 517 add_action( 'user_register', 'bp_blogs_add_user_to_blog' ); 513 518 514 519 function bp_blogs_remove_user_from_blog( $user_id, $blog_id = false ) { … … 605 610 global $bp; 606 611 607 / * If this is regular blog, delete all data for that blog. */612 // If this is regular blog, delete all data for that blog. 608 613 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 609 614 … … 643 648 644 649 645 // 646 // Blog meta functions 647 // These functions are used to store specific blogmeta in one global table, rather than in each 648 // blog's options table. Significantly speeds up global blog queries. 649 // By default each blog's name, description and last updated time are stored and synced here. 650 // 650 /******************************************************************************* 651 * Blog meta functions 652 * 653 * These functions are used to store specific blogmeta in one global table, 654 * rather than in each blog's options table. Significantly speeds up global blog 655 * queries. By default each blog's name, description and last updated time are 656 * stored and synced here. 657 */ 651 658 652 659 function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) { … … 663 670 $meta_value = trim( $meta_value ); 664 671 665 if ( !$meta_key ) {672 if ( !$meta_key ) 666 673 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) ); 667 } else if ( $meta_value ) {674 else if ( $meta_value ) 668 675 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value ) ); 669 } else {676 else 670 677 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) ); 671 }672 678 673 679 wp_cache_delete( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, 'bp' ); … … 723 729 $meta_value = maybe_serialize($meta_value); 724 730 725 if (empty( $meta_value)) {731 if (empty( $meta_value ) ) 726 732 return bp_blogs_delete_blogmeta( $blog_id, $meta_key ); 727 }728 733 729 734 $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) ); 730 735 731 if ( !$cur ) {736 if ( !$cur ) 732 737 $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blogmeta} ( blog_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $blog_id, $meta_key, $meta_value ) ); 733 } else if ( $cur->meta_value != $meta_value ) {738 else if ( $cur->meta_value != $meta_value ) 734 739 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blogmeta} SET meta_value = %s WHERE blog_id = %d AND meta_key = %s", $meta_value, $blog_id, $meta_key ) ); 735 } else { 736 return false; 737 } 740 else 741 return false; 738 742 739 743 wp_cache_set( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, $meta_value, 'bp' ); … … 746 750 return false; 747 751 748 / * If this is regular blog, delete all data for that blog. */752 // If this is regular blog, delete all data for that blog. 749 753 BP_Blogs_Blog::delete_blogs_for_user( $user_id ); 750 754 751 755 do_action( 'bp_blogs_remove_data', $user_id ); 752 756 } 753 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' );754 add_action( 'delete_user', 'bp_blogs_remove_data' );757 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' ); 758 add_action( 'delete_user', 'bp_blogs_remove_data' ); 755 759 add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' ); 756 760 757 761 758 /******************************************************************************* *762 /******************************************************************************* 759 763 * Caching 760 764 * … … 775 779 // List actions to clear object caches on 776 780 add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 ); 777 add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );781 add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 ); 778 782 779 783 // List actions to clear super cached pages on, if super cache is installed 780 784 add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' ); 781 add_action( 'bp_blogs_remove_comment', 'bp_core_clear_cache' );782 add_action( 'bp_blogs_remove_post', 'bp_core_clear_cache' );785 add_action( 'bp_blogs_remove_comment', 'bp_core_clear_cache' ); 786 add_action( 'bp_blogs_remove_post', 'bp_core_clear_cache' ); 783 787 add_action( 'bp_blogs_remove_blog_for_user', 'bp_core_clear_cache' ); 784 add_action( 'bp_blogs_remove_blog', 'bp_core_clear_cache' );785 add_action( 'bp_blogs_new_blog_comment', 'bp_core_clear_cache' );786 add_action( 'bp_blogs_new_blog_post', 'bp_core_clear_cache' );787 add_action( 'bp_blogs_new_blog', 'bp_core_clear_cache' );788 add_action( 'bp_blogs_remove_data', 'bp_core_clear_cache' );788 add_action( 'bp_blogs_remove_blog', 'bp_core_clear_cache' ); 789 add_action( 'bp_blogs_new_blog_comment', 'bp_core_clear_cache' ); 790 add_action( 'bp_blogs_new_blog_post', 'bp_core_clear_cache' ); 791 add_action( 'bp_blogs_new_blog', 'bp_core_clear_cache' ); 792 add_action( 'bp_blogs_remove_data', 'bp_core_clear_cache' ); 789 793 790 794 ?> -
trunk/bp-core.php
r3720 r3728 9 9 define( 'BP_PLUGIN_URL', plugins_url( $path = '/buddypress' ) ); 10 10 11 / * Load the WP abstraction file so BuddyPress can run on all WordPress setups. */11 // Load the WP abstraction file so BuddyPress can run on all WordPress setups. 12 12 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' ); 13 13 14 / * Place your custom code (actions/filters) in a file called /plugins/bp-custom.php and it will be loaded before anything else. */14 // Place your custom code (actions/filters) in a file called /plugins/bp-custom.php and it will be loaded before anything else. 15 15 if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) ) 16 16 require( WP_PLUGIN_DIR . '/bp-custom.php' ); 17 17 18 / * Define the user and usermeta table names, useful if you are using custom or shared tables. */18 // Define the user and usermeta table names, useful if you are using custom or shared tables. 19 19 if ( !defined( 'CUSTOM_USER_TABLE' ) ) 20 20 define( 'CUSTOM_USER_TABLE', $wpdb->base_prefix . 'users' ); … … 25 25 // The search slug has to be defined nice and early because of the way search requests are loaded 26 26 if ( !defined( 'BP_SEARCH_SLUG' ) ) 27 28 29 / * Load the files containing functions that we globally will need. */30 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' );31 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' );32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' );33 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' );34 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' );35 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-templatetags.php' );36 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php' );37 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' );27 define( 'BP_SEARCH_SLUG', 'search' ); 28 29 // Load the files containing functions that we globally will need. 30 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' ); 31 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' ); 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' ); 33 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' ); 34 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' ); 35 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-templatetags.php' ); 36 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php' ); 37 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' ); 38 38 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' ); 39 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' ); 40 41 /* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. */ 39 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' ); 40 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-deprecated.php' ); 41 42 // If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. 42 43 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) ) 43 44 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' ); 44 45 45 / * Register BuddyPress themes contained within the bp-theme folder */46 // Register BuddyPress themes contained within the bp-theme folder 46 47 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' ); 47 48 48 49 /* "And now for something completely different" .... */ 50 51 52 /** 53 * bp_core_setup_globals() 54 * 49 /** "And now for something completely different" ******************************/ 50 51 /** 55 52 * Sets up default global BuddyPress configuration settings and stores 56 53 * them in a $bp variable. … … 76 73 77 74 // The domain for the root of the site where the main blog resides 78 $bp->root_domain = bp_core_get_root_domain();75 $bp->root_domain = bp_core_get_root_domain(); 79 76 80 77 // The names of the core WordPress pages used to display BuddyPress content 81 $bp->pages = $bp_pages; 78 $bp->pages = $bp_pages; 79 80 /** Members Component *****************************************************/ 82 81 83 82 // Set up the members id and active components entry 84 $bp->members->id = 'members'; 85 83 $bp->members->id = 'members'; 84 85 // Members Slugs 86 86 $bp->members->slug = $bp->pages->members->slug; 87 87 $bp->active_components[$bp->members->slug] = $bp->members->id; … … 89 89 // The user ID of the user who is currently logged in. 90 90 $bp->loggedin_user->id = $current_user->ID; 91 92 /** Logged in user ********************************************************/ 91 93 92 94 // The domain for the user currently logged in. eg: http://domain.com/members/andy … … 100 102 $bp->loggedin_user->is_site_admin = $bp->loggedin_user->is_super_admin; // deprecated 1.2.6 101 103 104 /** Displayed user ********************************************************/ 105 102 106 // The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php 103 107 $bp->displayed_user->id = $displayed_user_id; … … 109 113 $bp->displayed_user->userdata = bp_core_get_core_userdata( $bp->displayed_user->id ); 110 114 115 /** Component and Action **************************************************/ 116 111 117 // The component being used eg: http://domain.com/members/andy/ [profile] 112 118 $bp->current_component = $current_component; // type: string … … 121 127 $bp->current_item = ''; // type: string 122 128 123 // Used for overriding the 2nd level navigation menu so it can be used to display custom navigation for an item (for example a group) 129 // Used for overriding the 2nd level navigation menu so it can be used to 130 // display custom navigation for an item (for example a group) 124 131 $bp->is_single_item = false; 125 132 … … 134 141 } 135 142 136 // Fetches all of the core database based BuddyPress settings in one foul swoop143 // Fetches all of the core BuddyPress settings in one fell swoop 137 144 $bp->site_options = bp_core_get_site_options(); 138 145 139 // Sets up the array container for the component navigation rendered by bp_get_nav() 146 // Sets up the array container for the component navigation rendered 147 // by bp_get_nav() 140 148 $bp->bp_nav = array(); 141 149 142 // Sets up the array container for the component options navigation rendered by bp_get_options_nav() 150 // Sets up the array container for the component options navigation 151 // rendered by bp_get_options_nav() 143 152 $bp->bp_options_nav = array(); 144 153 145 // Contains an array of all the active components. The key is the slug, value the internal ID of the component 154 // Contains an array of all the active components. The key is the slug, 155 // value the internal ID of the component. 146 156 $bp->active_components = array(); 157 158 /** Avatars ***************************************************************/ 147 159 148 160 // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar … … 155 167 $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id ); 156 168 157 /* Used to determine if user has admin rights on current content. If the logged in user is viewing 158 their own profile and wants to delete something, is_item_admin is used. This is a 159 generic variable so it can be used by other components. It can also be modified, so when viewing a group 160 'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */ 169 /** 170 * Used to determine if user has admin rights on current content. If the logged in user is viewing 171 * their own profile and wants to delete something, is_item_admin is used. This is a 172 * generic variable so it can be used by other components. It can also be modified, so when viewing a group 173 * 'is_item_admin' would be 1 if they are a group admin, 0 if they are not. 174 */ 161 175 $bp->is_item_admin = bp_user_has_access(); 162 176 … … 164 178 $bp->is_item_mod = false; 165 179 180 // Notifications Table 166 181 $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications'; 167 182 183 // Default Component 168 184 if ( !$bp->current_component && $bp->displayed_user->id ) 169 185 $bp->current_component = $bp->default_component; 170 186 171 187 // The default text for the members directory search box 172 188 $bp->default_search_strings[$bp->members->slug] = __( 'Search Members...', 'buddypress' ); 173 189 174 190 do_action( 'bp_core_setup_globals' ); … … 177 193 178 194 /** 179 * bp_core_get_table_prefix()180 *181 195 * Allow filtering of database prefix. Intended for use in multinetwork installations. 182 196 * … … 191 205 192 206 /** 193 * bp_core_define_slugs()194 *195 207 * Define the slugs used for BuddyPress pages, based on the slugs of the WP pages used. 196 208 * These can be overridden manually by defining these slugs in wp-config.php. … … 215 227 216 228 /** 217 * bp_core_get_page_meta()218 *219 229 * Fetches BP pages from the meta table, depending on setup 220 230 * … … 231 241 232 242 /** 233 * bp_core_update_page_meta()234 *235 243 * Stores BP pages in the meta table, depending on setup 236 244 * … … 285 293 } 286 294 287 /** 288 * bp_core_admin_menu_init() 289 * 295 /** 296 * Creates a default component slug from a WP page root_slug 297 * 298 * Since 1.3, BP components get their root_slug (the slug used immediately 299 * following the root domain) from the slug of a corresponding WP page. 300 * 301 * E.g. if your BP installation at example.com has its members page at 302 * example.com/community/people, $bp->members->root_slug will be 'community/people'. 303 * 304 * By default, this function creates a shorter version of the root_slug for 305 * use elsewhere in the URL, by returning the content after the final '/' 306 * in the root_slug ('people' in the example above). 307 * 308 * Filter on 'bp_core_component_slug_from_root_slug' to override this method 309 * in general, or define a specific component slug constant (e.g. BP_MEMBERS_SLUG) 310 * to override specific component slugs. 311 * 312 * @package BuddyPress Core 313 * @since 1.3 314 * 315 * @param str $root_slug The root slug, which comes from $bp->pages->[component]->slug 316 * @return str $slug The short slug for use in the middle of URLs 317 */ 318 function bp_core_component_slug_from_root_slug( $root_slug ) { 319 $slug_chunks = explode( '/', $root_slug ); 320 $slug = array_pop( $slug_chunks ); 321 322 return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug ); 323 } 324 325 /** 290 326 * Initializes the wp-admin area "BuddyPress" menus and sub menus. 291 327 * … … 302 338 303 339 /** 304 * bp_core_add_admin_menu()305 *306 340 * Adds the "BuddyPress" admin submenu item to the Site Admin tab. 307 341 * … … 334 368 335 369 /** 336 * bp_core_is_root_component()337 *338 * Checks to see if a component's URL should be in the root, not under a member page:339 * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group340 *341 * @package BuddyPress Core342 * @return true if root component, else false.343 */344 function bp_core_is_root_component( $component_name ) {345 global $bp;346 347 foreach ( (array) $bp->pages as $key => $page ) {348 if ( $key == $component_name || $page->slug == $component_name )349 return true;350 }351 352 return false;353 }354 355 /**356 * bp_core_setup_nav()357 *358 370 * Sets up the profile navigation item if the Xprofile component is not installed. 359 371 * … … 419 431 420 432 /** 421 * bp_core_action_directory_members()422 *423 433 * Listens to the $bp component and action variables to determine if the user is viewing the members 424 434 * directory page. If they are, it will set up the directory and load the members directory template. … … 442 452 443 453 /** 444 * bp_core_action_set_spammer_status()445 *446 454 * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu 447 455 * this action will fire and mark or unmark the user and their blogs as spam. … … 458 466 459 467 if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) { 460 / * Check the nonce */468 // Check the nonce 461 469 check_admin_referer( 'mark-unmark-spammer' ); 462 470 463 / * Get the functions file */471 // Get the functions file 464 472 if ( is_multisite() ) 465 473 require_once( ABSPATH . 'wp-admin/includes/ms.php' ); … … 470 478 $is_spam = 0; 471 479 472 / * Get the blogs for the user */480 // Get the blogs for the user 473 481 $blogs = get_blogs_of_user( $bp->displayed_user->id, true ); 474 482 475 483 foreach ( (array) $blogs as $key => $details ) { 476 / * Do not mark the main or current root blog as spam */484 // Do not mark the main or current root blog as spam 477 485 if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id ) 478 486 continue; 479 487 480 / * Update the blog status */488 // Update the blog status 481 489 update_blog_status( $details->userblog_id, 'spam', $is_spam ); 482 490 483 / * Fire the standard WPMU hook */491 // Fire the standard multisite hook 484 492 do_action( 'make_spam_blog', $details->userblog_id ); 485 493 } 486 494 487 / * Finally, mark this user as a spammer */495 // Finally, mark this user as a spammer 488 496 if ( is_multisite() ) 489 497 $wpdb->update( $wpdb->users, array( 'spam' => $is_spam ), array( 'ID' => $bp->displayed_user->id ) ); … … 496 504 bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) ); 497 505 498 / * Hide this user's activity */506 // Hide this user's activity 499 507 if ( $is_spam && function_exists( 'bp_activity_hide_user_activity' ) ) 500 508 bp_activity_hide_user_activity( $bp->displayed_user->id ); 501 509 502 // We need a special hook for is_spam so that components can delete data at spam time 510 // We need a special hook for is_spam so that components can 511 // delete data at spam time 503 512 if ( $is_spam ) 504 513 do_action( 'bp_make_spam_user', $bp->displayed_user->id ); 505 514 506 515 do_action( 'bp_core_action_set_spammer_status', $bp->displayed_user->id, $is_spam ); … … 512 521 513 522 /** 514 * bp_core_action_delete_user()515 *516 523 * Allows a site admin to delete a user from the adminbar menu. 517 524 * … … 526 533 527 534 if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) { 528 / * Check the nonce */535 // Check the nonce 529 536 check_admin_referer( 'delete-user' ); 530 537 … … 559 566 560 567 /** 561 * bp_core_get_users()562 *563 568 * Return an array of users IDs based on the parameters passed. 564 569 * … … 587 592 588 593 /** 589 * bp_core_get_user_domain() 590 * 591 * Returns the domain for the passed user: 592 * e.g. http://domain.com/members/andy/ 594 * Returns the domain for the passed user: e.g. http://domain.com/members/andy/ 593 595 * 594 596 * @package BuddyPress Core … … 605 607 $username = bp_core_get_username( $user_id, $user_nicename, $user_login ); 606 608 607 / * If we are using a members slug, include it. */609 // If we are using a members slug, include it. 608 610 if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) 609 611 $domain = $bp->root_domain . '/' . $bp->members->slug . '/' . $username . '/'; … … 611 613 $domain = $bp->root_domain . '/' . $username . '/'; 612 614 613 / * Cache the link */615 // Cache the link 614 616 if ( !empty( $domain ) ) 615 617 wp_cache_set( 'bp_user_domain_' . $user_id, $domain, 'bp' ); … … 620 622 621 623 /** 622 * bp_core_get_core_userdata()623 *624 624 * Fetch everything in the wp_users table for a user, without any usermeta. 625 625 * … … 640 640 641 641 /** 642 * bp_core_get_root_domain()643 *644 642 * Returns the domain for the root blog. 645 643 * eg: http://domain.com/ OR https://domain.com … … 661 659 662 660 /** 663 * bp_core_get_displayed_userid()664 *665 661 * Returns the user id for the user that is currently being displayed. 666 662 * eg: http://andy.domain.com/ or http://domain.com/andy/ … … 675 671 676 672 /** 677 * bp_core_new_nav_item()678 *679 673 * Adds a navigation item to the main navigation array used in BuddyPress themes. 680 674 * … … 686 680 687 681 $defaults = array( 688 'name' => false, // Display name for the nav item689 'slug' => false, // URL slug for the nav item690 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item691 'show_for_displayed_user' => true, // When viewing another user does this nav item show up?692 'site_admin_only' => false, // Can only site admins see this nav item?693 'position' => 99,// Index of where this nav item should be positioned694 'screen_function' => false, // The name of the function to run when clicked695 'default_subnav_slug' => false// The slug of the default subnav item to select when clicked682 'name' => false, // Display name for the nav item 683 'slug' => false, // URL slug for the nav item 684 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item 685 'show_for_displayed_user' => true, // When viewing another user does this nav item show up? 686 'site_admin_only' => false, // Can only site admins see this nav item? 687 'position' => 99, // Index of where this nav item should be positioned 688 'screen_function' => false, // The name of the function to run when clicked 689 'default_subnav_slug' => false // The slug of the default subnav item to select when clicked 696 690 ); 697 691 … … 699 693 extract( $r, EXTR_SKIP ); 700 694 701 / * If we don't have the required info we need, don't create this subnav item */695 // If we don't have the required info we need, don't create this subnav item 702 696 if ( empty($name) || empty($slug) ) 703 697 return false; 704 698 705 / * If this is for site admins only and the user is not one, don't create the subnav item */699 // If this is for site admins only and the user is not one, don't create the subnav item 706 700 if ( $site_admin_only && !is_super_admin() ) 707 701 return false; … … 711 705 712 706 $bp->bp_nav[$slug] = array( 713 'name' => $name,714 'slug' => $slug,715 'link' => $bp->loggedin_user->domain . $slug . '/',716 'css_id' => $item_css_id,707 'name' => $name, 708 'slug' => $slug, 709 'link' => $bp->loggedin_user->domain . $slug . '/', 710 'css_id' => $item_css_id, 717 711 'show_for_displayed_user' => $show_for_displayed_user, 718 'position' => $position,719 'screen_function' => &$screen_function712 'position' => $position, 713 'screen_function' => &$screen_function 720 714 ); 721 715 … … 732 726 * default subnav function so we can display a directory or something else. 733 727 */ 734 if ( bp_ core_is_root_component( $slug ) && !$bp->displayed_user->id )728 if ( bp_is_root_component( $slug ) && !$bp->displayed_user->id ) 735 729 return; 736 730 … … 747 741 748 742 /** 749 * bp_core_new_nav_default()750 *751 743 * Modify the default subnav item to load when a top level nav item is clicked. 752 744 * … … 758 750 759 751 $defaults = array( 760 'parent_slug' => false, // Slug of the parent752 'parent_slug' => false, // Slug of the parent 761 753 'screen_function' => false, // The name of the function to run when clicked 762 'subnav_slug' => false// The slug of the subnav item to select when clicked754 'subnav_slug' => false // The slug of the subnav item to select when clicked 763 755 ); 764 756 … … 787 779 788 780 /** 789 * bp_core_sort_nav_items()790 *791 781 * We can only sort nav items by their position integer at a later point in time, once all 792 782 * plugins have registered their navigation items. … … 817 807 $bp->bp_nav = &$temp; 818 808 } 819 add_action( 'wp_head', 'bp_core_sort_nav_items' );809 add_action( 'wp_head', 'bp_core_sort_nav_items' ); 820 810 add_action( 'admin_head', 'bp_core_sort_nav_items' ); 821 811 822 812 /** 823 * bp_core_new_subnav_item()824 *825 813 * Adds a navigation item to the sub navigation array used in BuddyPress themes. 826 814 * … … 832 820 833 821 $defaults = array( 834 'name' => false, // Display name for the nav item835 'slug' => false, // URL slug for the nav item836 'parent_slug' => false, // URL slug of the parent nav item837 'parent_url' => false, // URL of the parent item838 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item839 'user_has_access' => true, // Can the logged in user see this nav item?822 'name' => false, // Display name for the nav item 823 'slug' => false, // URL slug for the nav item 824 'parent_slug' => false, // URL slug of the parent nav item 825 'parent_url' => false, // URL of the parent item 826 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item 827 'user_has_access' => true, // Can the logged in user see this nav item? 840 828 'site_admin_only' => false, // Can only site admins see this nav item? 841 'position' => 90,// Index of where this nav item should be positioned842 'screen_function' => false // The name of the function to run when clicked829 'position' => 90, // Index of where this nav item should be positioned 830 'screen_function' => false // The name of the function to run when clicked 843 831 ); 844 832 … … 846 834 extract( $r, EXTR_SKIP ); 847 835 848 / * If we don't have the required info we need, don't create this subnav item */849 if ( empty( $name) || empty($slug) || empty($parent_slug) || empty($parent_url) || empty($screen_function) )850 return false; 851 852 / * If this is for site admins only and the user is not one, don't create the subnav item */836 // If we don't have the required info we need, don't create this subnav item 837 if ( empty( $name ) || empty( $slug ) || empty( $parent_slug ) || empty( $parent_url ) || empty( $screen_function ) ) 838 return false; 839 840 // If this is for site admins only and the user is not one, don't create the subnav item 853 841 if ( $site_admin_only && !is_super_admin() ) 854 842 return false; … … 858 846 859 847 $bp->bp_options_nav[$parent_slug][$slug] = array( 860 'name' => $name,861 'link' => $parent_url . $slug . '/',862 'slug' => $slug,863 'css_id' => $item_css_id,864 'position' => $position,848 'name' => $name, 849 'link' => $parent_url . $slug . '/', 850 'slug' => $slug, 851 'css_id' => $item_css_id, 852 'position' => $position, 865 853 'user_has_access' => $user_has_access, 866 854 'screen_function' => &$screen_function 867 855 ); 868 856 869 857 if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) { 870 858 if ( !is_object( $screen_function[0] ) ) … … 899 887 ksort( $temp ); 900 888 $bp->bp_options_nav[$parent_slug] = &$temp; 901 unset( $temp);902 } 903 } 904 add_action( 'wp_head', 'bp_core_sort_subnav_items' );889 unset( $temp ); 890 } 891 } 892 add_action( 'wp_head', 'bp_core_sort_subnav_items' ); 905 893 add_action( 'admin_head', 'bp_core_sort_subnav_items' ); 906 894 907 895 /** 908 * bp_core_remove_nav_item()909 *910 896 * Removes a navigation item from the sub navigation array used in BuddyPress themes. 911 897 * … … 917 903 global $bp; 918 904 919 / * Unset subnav items for this nav item */905 // Unset subnav items for this nav item 920 906 if ( is_array( $bp->bp_options_nav[$parent_id] ) ) { 921 907 foreach( (array)$bp->bp_options_nav[$parent_id] as $subnav_item ) { … … 935 921 936 922 /** 937 * bp_core_remove_subnav_item()938 *939 923 * Removes a navigation item from the sub navigation array used in BuddyPress themes. 940 924 * … … 962 946 963 947 /** 964 * bp_core_reset_subnav_items()965 *966 948 * Clear the subnav items for a specific nav item. 967 949 * … … 970 952 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 971 953 */ 972 function bp_core_reset_subnav_items($parent_slug) { 973 global $bp; 974 975 unset($bp->bp_options_nav[$parent_slug]); 976 } 977 978 /** 979 * bp_core_get_random_member() 980 * 954 function bp_core_reset_subnav_items( $parent_slug ) { 955 global $bp; 956 957 unset( $bp->bp_options_nav[$parent_slug] ); 958 } 959 960 /** 981 961 * Returns the user_id for a user based on their username. 982 962 * … … 997 977 998 978 /** 999 * bp_core_get_userid()1000 *1001 979 * Returns the user_id for a user based on their username. 1002 980 * … … 1017 995 1018 996 /** 1019 * bp_core_get_userid_from_nicename()1020 *1021 997 * Returns the user_id for a user based on their user_nicename. 1022 998 * … … 1037 1013 1038 1014 /** 1039 * bp_core_get_username()1040 *1041 1015 * Returns the username for a user based on their user id. 1042 1016 * … … 1076 1050 } 1077 1051 1078 / * Add this to cache */1052 // Add this to cache 1079 1053 if ( !empty( $username ) ) 1080 1054 wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' ); … … 1084 1058 1085 1059 /** 1086 * bp_core_get_user_email()1087 *1088 1060 * Returns the email address for the user based on user ID 1089 1061 * … … 1105 1077 1106 1078 /** 1107 * bp_core_get_userlink()1108 *1109 1079 * Returns a HTML formatted link for a user with the user's full name as the link text. 1110 1080 * eg: <a href="http://andy.domain.com/">Andy Peatling</a> … … 1146 1116 1147 1117 /** 1148 * bp_core_get_user_displayname()1149 *1150 1118 * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed. 1151 1119 * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set. … … 1203 1171 } 1204 1172 add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 ); 1205 add_filter( 'bp_core_get_user_displayname', 'trim' ); 1206 add_filter( 'bp_core_get_user_displayname', 'stripslashes' ); 1207 1208 1209 /** 1210 * bp_core_get_userlink_by_email() 1211 * 1173 add_filter( 'bp_core_get_user_displayname', 'trim' ); 1174 add_filter( 'bp_core_get_user_displayname', 'stripslashes' ); 1175 1176 1177 /** 1212 1178 * Returns the user link for the user based on user email address 1213 1179 * … … 1224 1190 1225 1191 /** 1226 * bp_core_get_userlink_by_username()1227 *1228 1192 * Returns the user link for the user based on user's username 1229 1193 * … … 1241 1205 1242 1206 /** 1243 * bp_core_get_total_member_count()1244 *1245 1207 * Returns the total number of members for the installation. 1246 1208 * … … 1261 1223 1262 1224 /** 1263 * bp_core_is_user_spammer()1264 *1265 1225 * Checks if the user has been marked as a spammer. 1266 1226 * … … 1281 1241 1282 1242 /** 1283 * bp_core_is_user_deleted()1284 *1285 1243 * Checks if the user has been marked as deleted. 1286 1244 * … … 1296 1254 1297 1255 /** 1298 * bp_core_current_time()1299 *1300 1256 * Get the current GMT time to save into the DB 1301 1257 * … … 1311 1267 1312 1268 /** 1313 * bp_core_add_message()1314 *1315 1269 * Adds a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads. 1316 1270 * … … 1323 1277 $type = 'success'; 1324 1278 1325 / * Send the values to the cookie for page reload display */1279 // Send the values to the cookie for page reload display 1326 1280 @setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH ); 1327 1281 @setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH ); … … 1331 1285 * without a page reload 1332 1286 */ 1333 $bp->template_message = $message;1287 $bp->template_message = $message; 1334 1288 $bp->template_message_type = $type; 1335 1289 } 1336 1290 1337 1291 /** 1338 * bp_core_setup_message() 1339 * 1340 * Checks if there is a feedback message in the WP cookie, if so, adds a "template_notices" action 1341 * so that the message can be parsed into the template and displayed to the user. 1342 * 1343 * After the message is displayed, it removes the message vars from the cookie so that the message 1344 * is not shown to the user multiple times. 1292 * Checks if there is a feedback message in the WP cookie, if so, adds a 1293 * "template_notices" action so that the message can be parsed into the template 1294 * and displayed to the user. 1295 * 1296 * After the message is displayed, it removes the message vars from the cookie 1297 * so that the message is not shown to the user multiple times. 1345 1298 * 1346 1299 * @package BuddyPress Core … … 1366 1319 1367 1320 /** 1368 * bp_core_render_message()1369 *1370 1321 * Renders a feedback message (either error or success message) to the theme template. 1371 1322 * The hook action 'template_notices' is used to call this function, it is not called directly. … … 1378 1329 1379 1330 if ( isset( $bp->template_message ) && $bp->template_message ) { 1380 $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error'; 1381 ?> 1331 $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error'; ?> 1332 1382 1333 <div id="message" class="<?php echo $type; ?>"> 1383 1334 <p><?php echo stripslashes( esc_attr( $bp->template_message ) ); ?></p> 1384 1335 </div> 1336 1385 1337 <?php 1338 1386 1339 do_action( 'bp_core_render_message' ); 1387 1340 } … … 1389 1342 1390 1343 /** 1391 * bp_core_time_since()1392 *1393 1344 * Based on function created by Dunstan Orchard - http://1976design.com 1394 1345 * … … 1424 1375 } 1425 1376 1426 /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */ 1427 /* $newer_date will have a value if we want to work out time elapsed between two known dates */ 1377 /** 1378 * $newer_date will equal false if we want to know the time elapsed between 1379 * a date and the current time. $newer_date will have a value if we want to 1380 * work out time elapsed between two known dates. 1381 */ 1428 1382 $newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time() ) : $newer_date; 1429 1383 1430 / * Difference in seconds */1384 // Difference in seconds 1431 1385 $since = $newer_date - $older_date; 1432 1386 1433 / * Something went wrong with date calculation and we ended up with a negative date. */1387 // Something went wrong with date calculation and we ended up with a negative date. 1434 1388 if ( 0 > $since ) 1435 1389 return __( 'sometime', 'buddypress' ); … … 1442 1396 */ 1443 1397 1444 / * Step one: the first chunk */1398 // Step one: the first chunk 1445 1399 for ( $i = 0, $j = count($chunks); $i < $j; $i++) { 1446 1400 $seconds = $chunks[$i][0]; 1447 1401 1448 / * Finding the biggest chunk (if the chunk fits, break) */1402 // Finding the biggest chunk (if the chunk fits, break) 1449 1403 if ( ( $count = floor($since / $seconds) ) != 0 ) 1450 1404 break; 1451 1405 } 1452 1406 1453 1454 1407 // If $i iterates all the way to $j, then the event happened 0 seconds ago 1408 if ( !isset( $chunks[$i] ) ) 1455 1409 return '0 ' . __( 'seconds', 'buddypress' ); 1456 1410 1457 / * Set output var */1411 // Set output var 1458 1412 $output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2]; 1459 1413 1460 / * Step two: the second chunk */1414 // Step two: the second chunk 1461 1415 if ( $i + 2 < $j ) { 1462 1416 $seconds2 = $chunks[$i + 1][0]; … … 1469 1423 } 1470 1424 1471 if ( !(int)trim( $output) )1425 if ( !(int)trim( $output ) ) 1472 1426 $output = '0 ' . __( 'seconds', 'buddypress' ); 1473 1427 … … 1477 1431 1478 1432 /** 1479 * bp_core_record_activity()1480 *1481 1433 * Record user activity to the database. Many functions use a "last active" feature to 1482 1434 * show the length of time since the user was last active. … … 1501 1453 $current_time = bp_core_current_time(); 1502 1454 1503 if ( '' == $activity|| strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )1455 if ( empty( $activity ) || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) ) 1504 1456 update_user_meta( $bp->loggedin_user->id, 'last_activity', $current_time ); 1505 1457 } … … 1508 1460 1509 1461 /** 1510 * bp_core_get_last_activity()1511 *1512 1462 * Formats last activity based on time since date given. 1513 1463 * … … 1519 1469 */ 1520 1470 function bp_core_get_last_activity( $last_activity_date, $string ) { 1521 if ( !$last_activity_date || empty( $last_activity_date ) ) {1471 if ( !$last_activity_date || empty( $last_activity_date ) ) 1522 1472 $last_active = __( 'not recently active', 'buddypress' ); 1523 } else {1473 else 1524 1474 $last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) ); 1525 }1526 1475 1527 1476 return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string ); … … 1529 1478 1530 1479 function bp_core_number_format( $number, $decimals = false ) { 1531 / * Check we actually have a number first. */1480 // Check we actually have a number first. 1532 1481 if ( empty( $number ) ) 1533 1482 return $number; … … 1537 1486 1538 1487 /** 1539 * bp_core_get_all_posts_for_user()1540 *1541 1488 * Fetch every post that is authored by the given user for the current blog. 1542 1489 * … … 1546 1493 * @return array of post ids. 1547 1494 */ 1548 function bp_core_get_all_posts_for_user( $user_id = null) {1495 function bp_core_get_all_posts_for_user( $user_id = 0 ) { 1549 1496 global $bp, $wpdb; 1550 1497 1551 if ( !$user_id)1498 if ( empty( $user_id ) ) 1552 1499 $user_id = $bp->displayed_user->id; 1553 1500 … … 1556 1503 1557 1504 /** 1558 * bp_core_get_site_path()1559 *1560 1505 * Get the path of of the current site. 1561 1506 * … … 1577 1522 $site_path = '/'; 1578 1523 else { 1579 / * Unset the first three segments (http(s)://domain.com part) */1524 // Unset the first three segments (http(s)://domain.com part) 1580 1525 unset( $site_path[0] ); 1581 1526 unset( $site_path[1] ); … … 1593 1538 1594 1539 /** 1595 * bp_core_redirect()1596 *1597 1540 * Performs a status safe wp_redirect() that is compatible with bp_catch_uri() 1598 1541 * … … 1614 1557 1615 1558 /** 1616 * bp_core_referrer()1617 *1618 1559 * Returns the referrer URL without the http(s):// 1619 1560 * … … 1628 1569 1629 1570 /** 1630 * bp_core_add_illegal_names()1631 *1632 1571 * Adds illegal names to WP so that root components will not conflict with 1633 1572 * blog names on a subdirectory installation. … … 1640 1579 1641 1580 /** 1642 * bp_core_delete_account()1643 *1644 1581 * Allows a user to completely remove their account from the system 1645 1582 * … … 1657 1594 $user_id = $bp->loggedin_user->id; 1658 1595 1659 / * Make sure account deletion is not disabled */1596 // Make sure account deletion is not disabled 1660 1597 if ( !empty( $bp->site_options['bp-disable-account-deletion'] ) && !$bp->loggedin_user->is_super_admin ) 1661 1598 return false; 1662 1599 1663 / * Site admins cannot be deleted */1600 // Site admins cannot be deleted 1664 1601 if ( is_super_admin( bp_core_get_username( $user_id ) ) ) 1665 1602 return false; 1666 1603 1667 / * Specifically handle multi-site environment */1604 // Specifically handle multi-site environment 1668 1605 if ( is_multisite() ) { 1669 1606 if ( $wp_version >= '3.0' ) … … 1676 1613 return wpmu_delete_user( $user_id ); 1677 1614 1678 / * Single site user deletion */1615 // Single site user deletion 1679 1616 } else { 1680 1617 require_once( ABSPATH . '/wp-admin/includes/user.php' ); … … 1684 1621 1685 1622 /** 1686 * bp_core_search_site()1687 *1688 1623 * A javascript free implementation of the search functions in BuddyPress 1689 1624 * … … 1712 1647 $slug = bp_is_active( 'blogs' ) ? $bp->blogs->slug : ''; 1713 1648 break; 1649 1714 1650 case 'forums': 1715 1651 $slug = bp_is_active( 'forums' ) ? $bp->forums->slug : ''; 1716 1652 $query_string = '/?fs='; 1717 1653 break; 1654 1718 1655 case 'groups': 1719 1656 $slug = bp_is_active( 'groups' ) ? $bp->groups->slug : ''; 1720 1657 break; 1658 1721 1659 case 'members': 1722 1660 default: … … 1735 1673 add_action( 'init', 'bp_core_action_search_site', 5 ); 1736 1674 1737 1738 /** 1739 * bp_core_ucfirst() 1740 * 1675 /** 1741 1676 * Localization safe ucfirst() support. 1742 1677 * … … 1752 1687 } 1753 1688 1754 1755 /** 1756 * bp_core_strip_username_spaces() 1757 * 1689 /** 1758 1690 * Strips spaces from usernames that are created using add_user() and wp_insert_user() 1759 1691 * … … 1761 1693 */ 1762 1694 function bp_core_strip_username_spaces( $username ) { 1763 1764 1765 1766 1695 // Don't alter the user_login of existing users, as it causes user_nicename problems. 1696 // See http://trac.buddypress.org/ticket/2642 1697 if ( username_exists( $username ) && ( !defined( 'BP_ENABLE_USER_COMPATIBILITY_MODE' ) || !BP_ENABLE_USER_COMPATIBILITY_MODE ) ) 1698 return $username; 1767 1699 1768 1700 return str_replace( ' ', '-', $username ); … … 1770 1702 add_action( 'pre_user_login', 'bp_core_strip_username_spaces' ); 1771 1703 1772 1773 /** 1774 * bp_core_clear_cache() 1704 /** 1775 1705 * REQUIRES WP-SUPER-CACHE 1776 1706 * … … 1791 1721 1792 1722 /** 1793 * bp_core_print_generation_time()1794 *1795 1723 * Prints the generation time in the footer of the site. 1796 1724 * … … 1807 1735 1808 1736 /** 1809 * bp_core_add_admin_menu_page()1810 *1811 1737 * A better version of add_admin_menu_page() that allows positioning of menus. 1812 1738 * … … 1854 1780 1855 1781 /** 1856 * bp_core_boot_spammer()1857 *1858 1782 * When a user logs in, check if they have been marked as a spammer. If yes then simply 1859 1783 * redirect them to the home page and stop them from logging in. … … 1870 1794 1871 1795 if ( !$user = get_userdatabylogin( $username ) ) 1872 1796 return false; 1873 1797 1874 1798 if ( ( is_multisite() && (int)$user->spam ) || 1 == (int)$user->user_status ) … … 1880 1804 1881 1805 /** 1882 * bp_core_remove_data()1883 *1884 1806 * Deletes usermeta for the user when the user is deleted. 1885 1807 * … … 1889 1811 */ 1890 1812 function bp_core_remove_data( $user_id ) { 1891 / * Remove usermeta */1813 // Remove usermeta 1892 1814 delete_user_meta( $user_id, 'last_activity' ); 1893 1815 1894 / * Flush the cache to remove the user from all cached objects */1816 // Flush the cache to remove the user from all cached objects 1895 1817 wp_cache_flush(); 1896 1818 } 1897 add_action( 'wpmu_delete_user', 'bp_core_remove_data' );1898 add_action( 'delete_user', 'bp_core_remove_data' );1819 add_action( 'wpmu_delete_user', 'bp_core_remove_data' ); 1820 add_action( 'delete_user', 'bp_core_remove_data' ); 1899 1821 add_action( 'bp_make_spam_user', 'bp_core_remove_data' ); 1900 1822 1901 1823 /** 1902 * bp_load_buddypress_textdomain()1903 *1904 1824 * Load the buddypress translation file for current language 1905 1825 * … … 1922 1842 1923 1843 function bp_core_add_ajax_hook() { 1924 / * Theme only, we already have the wp_ajax_ hook firing in wp-admin */1844 // Theme only, we already have the wp_ajax_ hook firing in wp-admin 1925 1845 if ( !defined( 'WP_ADMIN' ) && isset( $_REQUEST['action'] ) ) 1926 1846 do_action( 'wp_ajax_' . $_REQUEST['action'] ); … … 1929 1849 1930 1850 /** 1931 * bp_core_update_message()1932 *1933 1851 * Add an extra update message to the update plugin notification. 1934 1852 * … … 1941 1859 1942 1860 /** 1943 * bp_core_activation_notice()1944 *1945 1861 * When BuddyPress is activated we must make sure that mod_rewrite is enabled. 1946 1862 * We must also make sure a BuddyPress compatible theme is enabled. This function … … 1964 1880 1965 1881 if ( empty( $wp_rewrite->permalink_structure ) ) { ?> 1882 1966 1883 <div id="message" class="updated fade"> 1967 1884 <p><?php printf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) ?></p> 1968 1885 </div><?php 1886 1969 1887 } else { 1970 / * Get current theme info */1888 // Get current theme info 1971 1889 $ct = current_theme_info(); 1972 1890 1973 /* The best way to remove this notice is to add a "buddypress" tag to your active theme's CSS header. */ 1891 // The best way to remove this notice is to add a "buddypress" tag to 1892 // your active theme's CSS header. 1974 1893 if ( !defined( 'BP_SILENCE_THEME_NOTICE' ) && !in_array( 'buddypress', (array)$ct->tags ) ) { ?> 1894 1975 1895 <div id="message" class="updated fade"> 1976 1896 <p style="line-height: 150%"><?php printf( __( "<strong>BuddyPress is ready</strong>. You'll need to <a href='%s'>activate a BuddyPress compatible theme</a> to take advantage of all of the features. We've bundled a default theme, but you can always <a href='%s'>install some other compatible themes</a> or <a href='%s'>update your existing WordPress theme</a>.", 'buddypress' ), admin_url( 'themes.php' ), admin_url( 'theme-install.php?type=tag&s=buddypress&tab=search' ), admin_url( 'plugin-install.php?type=term&tab=search&s=%22bp-template-pack%22' ) ) ?></p> 1977 </div><?php 1897 </div> 1898 1899 <?php 1978 1900 } 1979 1901 } … … 1982 1904 1983 1905 /** 1984 * bp_core_activate_site_options()1985 *1986 1906 * When switching from single to multisite we need to copy blog options to 1987 1907 * site options. … … 2019 1939 2020 1940 /** 2021 * bp_include()2022 *2023 1941 * Allow plugins to include their files ahead of core filters 2024 1942 */ … … 2029 1947 2030 1948 /** 2031 * bp_setup_root_components()2032 *2033 1949 * Allow core components and dependent plugins to set root components 2034 1950 */ … … 2039 1955 2040 1956 /** 2041 * bp_setup_globals()2042 *2043 1957 * Allow core components and dependent plugins to set globals 2044 1958 */ … … 2049 1963 2050 1964 /** 2051 * bp_setup_nav()2052 *2053 1965 * Allow core components and dependent plugins to set their nav 2054 1966 */ … … 2059 1971 2060 1972 /** 2061 * bp_setup_widgets()2062 *2063 1973 * Allow core components and dependent plugins to register widgets 2064 1974 */ … … 2069 1979 2070 1980 /** 2071 * bp_init()2072 *2073 1981 * Allow components to initialize themselves cleanly 2074 1982 */ … … 2087 1995 2088 1996 /** 2089 * bp_core_add_global_group()2090 *2091 1997 * Add's 'bp' to global group of network wide cachable objects 2092 1998 * … … 2102 2008 2103 2009 /** 2104 * bp_core_clear_user_object_cache()2105 *2106 2010 * Clears all cached objects for a user, or a user is part of. 2107 2011 * … … 2113 2017 2114 2018 // List actions to clear super cached pages on, if super cache is installed 2115 add_action( 'wp_login', 'bp_core_clear_cache' );2019 add_action( 'wp_login', 'bp_core_clear_cache' ); 2116 2020 add_action( 'bp_core_render_notice', 'bp_core_clear_cache' ); 2117 2021 2118 2119 /* DEPRECATED FUNCTIONS ****/2120 2121 /**2122 * bp_core_add_root_component()2123 *2124 * This function originally let plugins add support for pages in the root of the install.2125 * These pages are now handled by actual WordPress pages so this function is deprecated.2126 * It now simply facilitates backwards compatibility by adding a WP page if the plugin has not been2127 * updated to do so.2128 *2129 * @deprecated 1.32130 * @deprecated Use wp_insert_post() to create a page2131 * @package BuddyPress Core2132 * @param $slug str The slug of the component2133 * @global $bp BuddyPress global settings2134 */2135 function bp_core_add_root_component( $slug ) {2136 global $bp, $bp_pages;2137 2138 _deprecated_function( __FUNCTION__, '1.3', 'wp_insert_post()' );2139 if ( empty( $bp_pages ) )2140 $bp_pages = bp_core_get_page_names();2141 2142 $match = false;2143 2144 /* Check if the slug is registered in the $bp->pages global */2145 foreach ( (array)$bp_pages as $key => $page ) {2146 if ( $key == $slug || $page->slug == $slug )2147 $match = true;2148 }2149 2150 /* If there was no match, add a page for this root component */2151 if ( empty( $match ) ) {2152 $bp->add_root[] = $slug;2153 add_action( 'init', 'bp_core_create_root_component_page' );2154 }2155 }2156 2157 function bp_core_create_root_component_page() {2158 global $bp;2159 2160 $new_page_ids = array();2161 2162 foreach ( (array)$bp->add_root as $slug )2163 $new_page_ids[$slug] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) );2164 2165 $page_ids = bp_core_get_page_meta();2166 2167 $page_ids = (array) $page_ids;2168 $page_ids = array_merge( (array) $new_page_ids, (array) $page_ids );2169 2170 bp_core_update_page_meta( $page_ids );2171 }2172 2022 ?> -
trunk/bp-core/admin/bp-core-admin.php
r3716 r3728 6 6 <div id="bp-admin-header"> 7 7 <h3><?php _e( 'BuddyPress', 'buddypress' ) ?></h3> 8 <h2><?php _e( 'Dashboard', 'buddypress' ) ?></h2>8 <h2><?php _e( 'Dashboard', 'buddypress' ) ?></h2> 9 9 </div> 10 10 … … 18 18 19 19 </div> 20 20 21 <?php 21 22 } … … 25 26 26 27 $ud = get_userdata( $bp->loggedin_user->id ); 27 ?> 28 29 <?php 28 30 29 if ( isset( $_POST['bp-admin-submit'] ) && isset( $_POST['bp-admin'] ) ) { 31 30 if ( !check_admin_referer('bp-admin') ) … … 52 51 53 52 <?php if ( isset( $_POST['bp-admin'] ) ) : ?> 53 54 54 <div id="message" class="updated fade"> 55 55 <p><?php _e( 'Settings Saved', 'buddypress' ) ?></p> 56 56 </div> 57 57 58 <?php endif; ?> 58 59 … … 60 61 61 62 <table class="form-table"> 62 <tbody> 63 <?php if ( bp_is_active( 'xprofile' ) ) : ?> 64 <tr> 65 <th scope="row"><?php _e( 'Base profile group name', 'buddypress' ) ?>:</th> 66 <td> 67 <input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo esc_attr( stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) ?>" /> 68 </td> 69 </tr> 70 <tr> 71 <th scope="row"><?php _e( 'Full Name field name', 'buddypress' ) ?>:</th> 72 <td> 73 <input name="bp-admin[bp-xprofile-fullname-field-name]" id="bp-xprofile-fullname-field-name" value="<?php echo esc_attr( stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) ?>" /> 74 </td> 75 </tr> 76 <tr> 77 <th scope="row"><?php _e( 'Disable BuddyPress to WordPress profile syncing?', 'buddypress' ) ?>:</th> 78 <td> 79 <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 80 <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 81 </td> 82 </tr> 83 <?php endif; ?> 84 <tr> 85 <th scope="row"><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</th> 86 <td> 87 <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 88 <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 89 </td> 90 </tr> 91 <tr> 92 <th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th> 93 <td> 94 <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 95 <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 96 </td> 97 </tr> 98 <tr> 99 <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th> 100 <td> 101 <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 102 <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 103 </td> 104 </tr> 105 <?php if ( function_exists( 'bp_forums_setup') ) : ?> 106 <tr> 107 <th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th> 108 <td> 109 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 110 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 111 </td> 112 </tr> 113 <?php endif; ?> 114 <?php if ( bp_is_active( 'activity' ) ) : ?> 115 <tr> 116 <th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th> 117 <td> 118 <input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)get_site_option( 'bp-disable-blogforum-comments' ) || false === get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 119 <input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 120 </td> 121 </tr> 122 <?php endif; ?> 123 124 <?php do_action( 'bp_core_admin_screen_fields' ) ?> 125 </tbody> 63 <tbody> 64 65 <?php if ( bp_is_active( 'xprofile' ) ) : ?> 66 67 <tr> 68 <th scope="row"><?php _e( 'Base profile group name', 'buddypress' ) ?>:</th> 69 <td> 70 <input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo esc_attr( stripslashes( get_site_option( 'bp-xprofile-base-group-name' ) ) ) ?>" /> 71 </td> 72 </tr> 73 <tr> 74 <th scope="row"><?php _e( 'Full Name field name', 'buddypress' ) ?>:</th> 75 <td> 76 <input name="bp-admin[bp-xprofile-fullname-field-name]" id="bp-xprofile-fullname-field-name" value="<?php echo esc_attr( stripslashes( get_site_option( 'bp-xprofile-fullname-field-name' ) ) ) ?>" /> 77 </td> 78 </tr> 79 <tr> 80 <th scope="row"><?php _e( 'Disable BuddyPress to WordPress profile syncing?', 'buddypress' ) ?>:</th> 81 <td> 82 <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 83 <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 84 </td> 85 </tr> 86 87 <?php endif; ?> 88 89 <tr> 90 <th scope="row"><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</th> 91 <td> 92 <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 93 <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 94 </td> 95 </tr> 96 <tr> 97 <th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th> 98 <td> 99 <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 100 <input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 101 </td> 102 </tr> 103 <tr> 104 <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th> 105 <td> 106 <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 107 <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 108 </td> 109 </tr> 110 111 <?php if ( function_exists( 'bp_forums_setup') ) : ?> 112 113 <tr> 114 <th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th> 115 <td> 116 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 117 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 118 </td> 119 </tr> 120 121 <?php endif; ?> 122 123 <?php if ( bp_is_active( 'activity' ) ) : ?> 124 125 <tr> 126 <th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th> 127 <td> 128 <input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)get_site_option( 'bp-disable-blogforum-comments' ) || false === get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 129 <input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 130 </td> 131 </tr> 132 133 <?php endif; ?> 134 135 <?php do_action( 'bp_core_admin_screen_fields' ) ?> 136 137 </tbody> 126 138 </table> 127 139 … … 143 155 function bp_core_admin_component_setup() { 144 156 global $wpdb, $bp; 145 ?> 146 147 <?php 157 148 158 if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) { 149 159 if ( !check_admin_referer('bp-admin-component-setup') ) … … 156 166 } 157 167 update_site_option( 'bp-deactivated-components', $disabled ); 158 } 159 ?> 168 } ?> 160 169 161 170 <div class="wrap"> … … 164 173 165 174 <?php if ( isset( $_POST['bp-admin-component-submit'] ) ) : ?> 175 166 176 <div id="message" class="updated fade"> 167 177 <p><?php _e( 'Settings Saved', 'buddypress' ) ?></p> 168 178 </div> 179 169 180 <?php endif; ?> 170 181 … … 176 187 177 188 <table class="form-table" style="width: 80%"> 178 <tbody> 179 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?> 180 <tr> 181 <td><h3><?php _e( 'Activity Streams', 'buddypress' ) ?></h3><p><?php _e( 'Allow users to post activity updates and track all activity across the entire site.', 'buddypress' ) ?></p></td> 182 <td> 183 <input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 184 <input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 185 </td> 186 </tr> 187 <?php endif; ?> 188 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') && is_multisite() ) : ?> 189 <tr> 190 <td><h3><?php _e( 'Blog Tracking', 'buddypress' ) ?></h3><p><?php _e( 'Tracks blogs, blog posts and blogs comments for a user across a WPMU installation.', 'buddypress' ) ?></p></td> 191 <td> 192 <input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 193 <input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 194 </td> 195 </tr> 196 <?php else: ?> 197 <input type="hidden" name="bp_components[bp-blogs.php]" value="0" /> 198 <?php endif; ?> 199 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-forums.php') ) : ?> 200 <tr> 201 <td><h3><?php _e( 'bbPress Forums', 'buddypress' ) ?></h3><p><?php _e( 'Activates bbPress forum support within BuddyPress groups or any other custom component.', 'buddypress' ) ?></p></td> 202 <td> 203 <input type="radio" name="bp_components[bp-forums.php]" value="1"<?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 204 <input type="radio" name="bp_components[bp-forums.php]" value="0"<?php if ( isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 205 </td> 206 </tr> 207 <?php endif; ?> 208 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-friends.php') ) : ?> 209 <tr> 210 <td><h3><?php _e( 'Friends', 'buddypress' ) ?></h3><p><?php _e( 'Allows the creation of friend connections between users.', 'buddypress' ) ?></p></td> 211 <td> 212 <input type="radio" name="bp_components[bp-friends.php]" value="1"<?php if ( !isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 213 <input type="radio" name="bp_components[bp-friends.php]" value="0"<?php if ( isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 214 </td> 215 </tr> 216 <?php endif; ?> 217 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-groups.php') ) : ?> 218 <tr> 219 <td><h3><?php _e( 'Groups', 'buddypress' ) ?></h3><p><?php _e( 'Let users create, join and participate in groups.', 'buddypress' ) ?></p></td> 220 <td> 221 <input type="radio" name="bp_components[bp-groups.php]" value="1"<?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 222 <input type="radio" name="bp_components[bp-groups.php]" value="0"<?php if ( isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 223 </td> 224 </tr> 225 <?php endif; ?> 226 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-messages.php') ) : ?> 227 <tr> 228 <td><h3><?php _e( 'Private Messaging', 'buddypress' ) ?></h3><p><?php _e( 'Let users send private messages to one another. Site admins can also send site-wide notices.', 'buddypress' ) ?></p></td> 229 <td> 230 <input type="radio" name="bp_components[bp-messages.php]" value="1"<?php if ( !isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 231 <input type="radio" name="bp_components[bp-messages.php]" value="0"<?php if ( isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 232 </td> 233 </tr> 234 <?php endif; ?> 235 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?> 236 <tr> 237 <td><h3><?php _e( 'Extended Profiles', 'buddypress' ) ?></h3><p><?php _e( 'Activates customizable profiles and avatars for site users.', 'buddypress' ) ?></p></td> 238 <td width="45%"> 239 <input type="radio" name="bp_components[bp-xprofile.php]" value="1"<?php if ( !isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 240 <input type="radio" name="bp_components[bp-xprofile.php]" value="0"<?php if ( isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 241 </td> 242 </tr> 243 <?php endif; ?> 244 </tbody> 189 <tbody> 190 191 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?> 192 193 <tr> 194 <td><h3><?php _e( 'Activity Streams', 'buddypress' ) ?></h3><p><?php _e( 'Allow users to post activity updates and track all activity across the entire site.', 'buddypress' ) ?></p></td> 195 <td> 196 <input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 197 <input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 198 </td> 199 </tr> 200 201 <?php endif; ?> 202 203 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') && is_multisite() ) : ?> 204 205 <tr> 206 <td><h3><?php _e( 'Blog Tracking', 'buddypress' ) ?></h3><p><?php _e( 'Tracks blogs, blog posts and blogs comments for a user across a WPMU installation.', 'buddypress' ) ?></p></td> 207 <td> 208 <input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 209 <input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 210 </td> 211 </tr> 212 213 <?php else: ?> 214 215 <input type="hidden" name="bp_components[bp-blogs.php]" value="0" /> 216 217 <?php endif; ?> 218 219 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-forums.php') ) : ?> 220 221 <tr> 222 <td><h3><?php _e( 'bbPress Forums', 'buddypress' ) ?></h3><p><?php _e( 'Activates bbPress forum support within BuddyPress groups or any other custom component.', 'buddypress' ) ?></p></td> 223 <td> 224 <input type="radio" name="bp_components[bp-forums.php]" value="1"<?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 225 <input type="radio" name="bp_components[bp-forums.php]" value="0"<?php if ( isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 226 </td> 227 </tr> 228 229 <?php endif; ?> 230 231 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-friends.php') ) : ?> 232 233 <tr> 234 <td><h3><?php _e( 'Friends', 'buddypress' ) ?></h3><p><?php _e( 'Allows the creation of friend connections between users.', 'buddypress' ) ?></p></td> 235 <td> 236 <input type="radio" name="bp_components[bp-friends.php]" value="1"<?php if ( !isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 237 <input type="radio" name="bp_components[bp-friends.php]" value="0"<?php if ( isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 238 </td> 239 </tr> 240 241 <?php endif; ?> 242 243 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-groups.php') ) : ?> 244 245 <tr> 246 <td><h3><?php _e( 'Groups', 'buddypress' ) ?></h3><p><?php _e( 'Let users create, join and participate in groups.', 'buddypress' ) ?></p></td> 247 <td> 248 <input type="radio" name="bp_components[bp-groups.php]" value="1"<?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 249 <input type="radio" name="bp_components[bp-groups.php]" value="0"<?php if ( isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 250 </td> 251 </tr> 252 253 <?php endif; ?> 254 255 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-messages.php') ) : ?> 256 257 <tr> 258 <td><h3><?php _e( 'Private Messaging', 'buddypress' ) ?></h3><p><?php _e( 'Let users send private messages to one another. Site admins can also send site-wide notices.', 'buddypress' ) ?></p></td> 259 <td> 260 <input type="radio" name="bp_components[bp-messages.php]" value="1"<?php if ( !isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 261 <input type="radio" name="bp_components[bp-messages.php]" value="0"<?php if ( isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 262 </td> 263 </tr> 264 265 <?php endif; ?> 266 267 <?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?> 268 269 <tr> 270 <td><h3><?php _e( 'Extended Profiles', 'buddypress' ) ?></h3><p><?php _e( 'Activates customizable profiles and avatars for site users.', 'buddypress' ) ?></p></td> 271 <td width="45%"> 272 <input type="radio" name="bp_components[bp-xprofile.php]" value="1"<?php if ( !isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 273 <input type="radio" name="bp_components[bp-xprofile.php]" value="0"<?php if ( isset( $disabled_components['bp-xprofile.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 274 </td> 275 </tr> 276 277 <?php endif; ?> 278 279 </tbody> 245 280 </table> 246 281 … … 252 287 253 288 </form> 254 255 289 </div> 256 290 -
trunk/bp-core/admin/bp-core-update.php
r3721 r3728 12 12 13 13 /** 14 * bp_core_activate_site_options()15 *16 14 * When switching from single to multisite we need to copy blog options to 17 15 * site options. … … 91 89 global $wp_rewrite; 92 90 91 // Setup wizard steps 93 92 if ( 'new' == $this->setup_type ) { 94 // Setup wizard steps95 93 $steps = array( 96 94 __( 'Components', 'buddypress' ), 97 __( 'Pages', 'buddypress' ),95 __( 'Pages', 'buddypress' ), 98 96 __( 'Permalinks', 'buddypress' ), 99 __( 'Theme', 'buddypress' ),100 __( 'Finish', 'buddypress' )97 __( 'Theme', 'buddypress' ), 98 __( 'Finish', 'buddypress' ) 101 99 ); 102 100 … … 108 106 $steps = array_merge( array(), $steps ); 109 107 } 108 109 // Update wizard steps 110 110 } else { 111 // Update wizard steps112 113 111 if ( $this->is_network_activate ) 114 112 $steps[] = __( 'Multisite Update', 'buddypress' ); … … 167 165 <div id="bp-admin-header"> 168 166 <h3><?php _e( 'BuddyPress', 'buddypress' ) ?></h3> 169 <h2> 170 <?php if ( 'update' == $this->setup_type ) : ?> 171 172 <?php _e( 'Update', 'buddypress' ) ?> 173 174 <?php else : ?> 175 176 <?php _e( 'Setup', 'buddypress' ) ?> 177 178 <?php endif; ?> 179 </h2> 167 <h2><?php ( 'update' == $this->setup_type ) ? _e( 'Update', 'buddypress' ) : _e( 'Setup', 'buddypress' ); ?></h2> 180 168 </div> 181 169 182 170 <?php 183 171 do_action( 'bp_admin_notices' ); 172 184 173 $step_count = count( $this->steps ) - 1; 185 174 $wiz_or_set = $this->current_step >= $step_count ? 'bp-general-settings' : 'bp-wizard'; … … 190 179 <div id="bp-admin-nav"> 191 180 <ol> 181 192 182 <?php foreach( (array)$this->steps as $i => $name ) : ?> 183 193 184 <li<?php if ( $this->current_step == $i ) : ?> class="current"<?php endif; ?>> 194 185 <?php if ( $this->current_step > $i ) : ?> 186 195 187 <span class="complete"> </span> 196 <?php else : ?> 197 <?php echo $i + 1 . '. ' ?> 198 <?php endif; ?> 199 <?php echo esc_attr( $name ) ?> 188 189 <?php else : 190 191 echo $i + 1 . '. '; 192 193 endif; 194 echo esc_attr( $name ) ?> 195 200 196 </li> 197 201 198 <?php endforeach; ?> 199 202 200 </ol> 203 201 <div class="prev-next submit clear"> … … 207 205 208 206 <div id="bp-admin-content"> 207 209 208 <?php switch ( $this->steps[$this->current_step] ) { 210 209 case __( 'Database Update', 'buddypress'): … … 233 232 break; 234 233 } ?> 234 235 235 </div> 236 236 </form> 237 238 </div> 237 </div> 238 239 239 <?php 240 240 } 241 241 242 / * Setup Step HTML */242 // Setup Step HTML 243 243 244 244 function step_db_update() { 245 245 if ( !current_user_can( 'activate_plugins' ) ) 246 return false; 247 ?> 246 return false; ?> 247 248 248 <div class="prev-next submit clear"> 249 249 <p><input type="submit" value="<?php _e( 'Update & Next →', 'buddypress' ) ?>" name="submit" /></p> … … 257 257 <input type="hidden" name="save" value="db_update" /> 258 258 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" /> 259 259 260 <?php wp_nonce_field( 'bpwizard_db_update' ) ?> 260 </div> 261 262 </div> 263 261 264 <?php 262 265 } … … 319 322 <input type="hidden" name="save" value="ms_update" /> 320 323 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" /> 324 321 325 <?php wp_nonce_field( 'bpwizard_ms_update' ) ?> 326 322 327 </div> 323 328 … … 327 332 }); 328 333 </script> 334 329 335 <?php 330 336 } 331 332 337 333 338 function step_components() { … … 455 460 $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) ); 456 461 457 / * Check for defined slugs */462 // Check for defined slugs 458 463 if ( defined( 'BP_MEMBERS_SLUG' ) ) 459 464 $members_slug = constant( 'BP_MEMBERS_SLUG' ); … … 628 633 629 634 if ( !got_mod_rewrite() && !iis7_supports_permalinks() ) 630 $prefix = '/index.php'; 631 ?> 635 $prefix = '/index.php'; ?> 632 636 633 637 <p><?php _e( "To make sure the pages we created in the previous step work correctly, you will need to enable permalink support on your site.", 'buddypress' ) ?></p> … … 654 658 <input type="hidden" name="save" value="permalinks" /> 655 659 <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" /> 660 656 661 <?php wp_nonce_field( 'bpwizard_permalinks' ) ?> 662 657 663 </div> 658 664 <?php … … 665 671 require_once( ABSPATH . WPINC . '/plugin.php' ); 666 672 $installed_plugins = get_plugins(); 667 $installed_themes = get_themes();673 $installed_themes = get_themes(); 668 674 669 675 $template_pack_installed = false; 670 $bp_autotheme_installed = false;671 $bp_theme_installed = false;676 $bp_autotheme_installed = false; 677 $bp_theme_installed = false; 672 678 673 679 foreach ( (array)$installed_plugins as $plugin ) { … … 700 706 </td> 701 707 </tr> 708 702 709 <?php /* 703 710 <tr> … … 714 721 </tr> 715 722 */ ?> 723 716 724 <tr> 717 725 <th> … … 732 740 </td> 733 741 </tr> 742 734 743 <tr> 735 744 <th> … … 774 783 }); 775 784 </script> 785 776 786 <?php 777 787 } … … 811 821 } 812 822 813 / * Save Step Methods */823 // Save Step Methods 814 824 815 825 function step_db_update_save() { … … 837 847 // Transfer important settings from blog options to site options 838 848 $options = array( 839 'bp-db-version' => $this->current_version,849 'bp-db-version' => $this->current_version, 840 850 'bp-deactivated-components' => $disabled, 841 'avatar-default' => get_option( 'avatar-default' )851 'avatar-default' => get_option( 'avatar-default' ) 842 852 ); 843 853 bp_core_activate_site_options( $options ); … … 853 863 854 864 $existing_pages = get_option( 'bp-pages' ); 855 856 $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); 857 858 $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages ); 865 $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); 866 $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages ); 859 867 860 868 update_option( 'bp-pages', $bp_pages ); … … 942 950 if ( !empty($permalink_structure) ) 943 951 $permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] ); 952 944 953 if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) 945 954 $permalink_structure = '/blog' . $permalink_structure; … … 965 974 if ( $iis7_permalinks || ( !$usingpi && !$writable ) ) { 966 975 function _bp_core_wizard_step_permalinks_message() { 967 global $wp_rewrite; 968 969 ?><div id="message" class="updated fade"><p> 976 global $wp_rewrite; ?> 977 978 <div id="message" class="updated fade"><p> 979 970 980 <?php 971 981 _e( 'Oops, there was a problem creating a configuration file. ', 'buddypress' ); … … 982 992 } 983 993 ?> 994 984 995 <br /><br /> 996 985 997 <?php 986 998 if ( empty( $iis7_permalinks ) ) 987 999 _e( 'Paste all these rules into a new <code>.htaccess</code> file in the root of your WordPress installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress' ); 988 1000 ?> 989 </p></div><?php 1001 1002 </p></div> 1003 1004 <?php 990 1005 } 991 1006 add_action( 'bp_admin_notices', '_bp_core_wizard_step_permalinks_message' ); … … 1078 1093 } 1079 1094 1080 / * Database update methods based on version numbers */1095 // Database update methods based on version numbers 1081 1096 function update_1_3() { 1082 1097 // Run the schema install to update tables … … 1085 1100 // Delete old database version options 1086 1101 delete_site_option( 'bp-activity-db-version' ); 1087 delete_site_option( 'bp-blogs-db-version' );1088 delete_site_option( 'bp-friends-db-version' );1089 delete_site_option( 'bp-groups-db-version' );1102 delete_site_option( 'bp-blogs-db-version' ); 1103 delete_site_option( 'bp-friends-db-version' ); 1104 delete_site_option( 'bp-groups-db-version' ); 1090 1105 delete_site_option( 'bp-messages-db-version' ); 1091 1106 delete_site_option( 'bp-xprofile-db-version' ); … … 1216 1231 $message = __( 'Installation was successful. The available options have now been updated, please continue with your selection.', 'buddypress' ); 1217 1232 else 1218 return false; 1219 ?> 1233 return false; ?> 1234 1220 1235 <div id="message" class="updated"> 1221 1236 <p><?php echo esc_attr( $message ) ?></p> 1222 1237 </div> 1238 1223 1239 <?php 1224 1240 } 1225 1241 add_action( 'bp_admin_notices', 'bp_core_wizard_message' ); 1226 1242 1227 /* Alter thickbox screens so the entire plugin download and install interface is contained within. */ 1243 // Alter thickbox screens so the entire plugin download and install 1244 // interface is contained within. 1228 1245 function bp_core_wizard_thickbox() { 1229 1246 $form_action = is_multisite() ? network_admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ) : admin_url( add_query_arg( array( 'page' => 'bp-wizard', 'updated' => '1' ), 'admin.php' ) ); ?> … … 1242 1259 } 1243 1260 </script> 1261 1244 1262 <?php 1245 1263 } … … 1247 1265 1248 1266 /** 1249 * bp_core_add_admin_menu()1250 *1251 1267 * Adds the "BuddyPress" admin submenu item to the Site Admin tab. 1252 1268 * … … 1291 1307 1292 1308 wp_enqueue_script( 'thickbox' ); 1293 wp_enqueue_style( 'thickbox' ); 1294 ?> 1309 wp_enqueue_style( 'thickbox' ); ?> 1310 1295 1311 <style type="text/css"> 1296 1312 /* Wizard Icon */ … … 1310 1326 } 1311 1327 </style> 1328 1312 1329 <?php 1313 1330 } 1314 1331 add_action( 'admin_head', 'bp_core_add_admin_menu_styles' ); 1332 1315 1333 ?> -
trunk/bp-core/bp-core-templatetags.php
r3701 r3728 163 163 164 164 // Make sure we return no members if we looking at friendship requests and there are none. 165 if ( empty( $include ) && $bp->friends->slug == $bp->current_component&& 'requests' == $bp->current_action )165 if ( empty( $include ) && bp_is_current_component( $bp->friends->slug ) && 'requests' == $bp->current_action ) 166 166 return false; 167 167 … … 583 583 function bp_get_options_nav() { 584 584 global $bp; 585 586 if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 ) 585 586 // If we are looking at a member profile, then the we can use the current component as an 587 // index. Otherwise we need to use the component's root_slug 588 $component_index = !empty( $bp->displayed_user ) ? $bp->current_component : bp_get_root_slug( $bp->current_component ); 589 590 if ( count( $bp->bp_options_nav[$component_index] ) < 1 ) 587 591 return false; 588 592 589 593 /* Loop through each navigation item */ 590 foreach ( (array)$bp->bp_options_nav[$ bp->current_component] as $subnav_item ) {594 foreach ( (array)$bp->bp_options_nav[$component_index] as $subnav_item ) { 591 595 if ( !$subnav_item['user_has_access'] ) 592 596 continue; … … 1557 1561 } 1558 1562 1563 /** 1564 * Echoes the output of bp_get_root_slug() 1565 * 1566 * @package BuddyPress Core 1567 * @since 1.3 1568 */ 1569 function bp_root_slug( $component = '' ) { 1570 echo bp_get_root_slug( $component ); 1571 } 1572 /** 1573 * Gets the root slug for a component slug 1574 * 1575 * In order to maintain backward compatibility, the following procedure is used: 1576 * 1) Use the short slug to get the canonical component name from the 1577 * active component array 1578 * 2) Use the component name to get the root slug out of the appropriate part of the $bp 1579 * global 1580 * 3) If nothing turns up, it probably means that $component is itself a root slug 1581 * 1582 * Example: If your groups directory is at /community/companies, this function first uses 1583 * the short slug 'companies' (ie the current component) to look up the canonical name 1584 * 'groups' in $bp->active_components. Then it uses 'groups' to get the root slug, from 1585 * $bp->groups->root_slug. 1586 * 1587 * @package BuddyPress Core 1588 * @since 1.3 1589 * 1590 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 1591 * @param string $component Optional. Defaults to the current component 1592 * @return string $root_slug The root slug 1593 */ 1594 function bp_get_root_slug( $component = '' ) { 1595 global $bp; 1596 1597 $root_slug = ''; 1598 1599 // Use current global component if none passed 1600 if ( empty( $component ) ) 1601 $component = $bp->current_component; 1602 1603 // Component is active 1604 if ( !empty( $bp->active_components[$component] ) ) { 1605 $component_name = $bp->active_components[$component]; 1606 1607 // Component has specific root slug 1608 if ( !empty( $bp->{$component_name}->root_slug ) ) 1609 $root_slug = $bp->{$component_name}->root_slug; 1610 } 1611 1612 // No specific root slug, so fall back to component slug 1613 if ( empty( $root_slug ) ) 1614 $root_slug = $component; 1615 1616 return apply_filters( 'bp_get_root_slug', $root_slug, $component ); 1617 } 1618 1559 1619 /* Template is_() functions to determine the current page */ 1620 1621 /** 1622 * Checks to see whether the current page belongs to the specified component 1623 * 1624 * This function is designed to be generous, accepting several different kinds 1625 * of value for the $component parameter. It checks $component_name against: 1626 * - the component's root_slug, which matches the page slug in $bp->pages 1627 * - the component's regular slug 1628 * - the component's id, or 'canonical' name 1629 * 1630 * @package BuddyPress Core 1631 * @since 1.3 1632 * @return bool Returns true if the component matches, or else false. 1633 */ 1634 function bp_is_current_component( $component ) { 1635 global $bp; 1636 1637 $is_current_component = false; 1638 1639 if ( !empty( $bp->current_component ) ) { 1640 1641 // First, check to see whether $component_name and the current 1642 // component are a simple match 1643 if ( $bp->current_component == $component ) { 1644 $is_current_component = true; 1645 1646 // Next, check to see whether $component is a canonical, 1647 // non-translatable component name. If so, we can return its 1648 // corresponding slug from $bp->active_components. 1649 } else if ( $key = array_search( $component, $bp->active_components ) ) { 1650 if ( $key === $bp->current_component ) 1651 $is_current_component = true; 1652 1653 // If we haven't found a match yet, check against the root_slugs 1654 // created by $bp->pages 1655 } else { 1656 foreach ( $bp->active_components as $key => $id ) { 1657 // If the $component parameter does not match the current_component, 1658 // then move along, these are not the droids you are looking for 1659 if ( $bp->{$id}->root_slug != $bp->current_component ) 1660 continue; 1661 1662 if ( $key == $component ) { 1663 $is_current_component = true; 1664 break; 1665 } 1666 } 1667 } 1668 } 1669 1670 return apply_filters( 'bp_is_current_component', $is_current_component, $component_name ); 1671 } 1672 1673 /** 1674 * Checks to see if a component's URL should be in the root, not under a member page: 1675 * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group 1676 * 1677 * @package BuddyPress Core 1678 * @return true if root component, else false. 1679 */ 1680 function bp_is_root_component( $component_name ) { 1681 global $bp; 1682 1683 foreach ( (array) $bp->active_components as $key => $slug ) { 1684 if ( $key == $component_name || $slug == $component_name ) 1685 return true; 1686 } 1687 1688 return false; 1689 } 1560 1690 1561 1691 /** … … 1591 1721 return true; 1592 1722 1593 if ( !$bp->displayed_user->id && !$bp->is_single_item && ( !isset( $bp->is_directory ) || !$bp->is_directory ) && !bp_ core_is_root_component( $bp->current_component ) )1723 if ( !$bp->displayed_user->id && !$bp->is_single_item && ( !isset( $bp->is_directory ) || !$bp->is_directory ) && !bp_is_root_component( $bp->current_component ) ) 1594 1724 return true; 1595 1725 … … 1661 1791 1662 1792 function bp_is_profile_component() { 1663 global $bp; 1664 1665 if ( BP_XPROFILE_SLUG == $bp->current_component ) 1793 if ( bp_is_current_component( BP_XPROFILE_SLUG ) ) 1666 1794 return true; 1667 1795 … … 1670 1798 1671 1799 function bp_is_activity_component() { 1672 global $bp; 1673 1674 if ( BP_ACTIVITY_SLUG == $bp->current_component ) 1800 if ( bp_is_current_component( BP_ACTIVITY_SLUG ) ) 1675 1801 return true; 1676 1802 … … 1679 1805 1680 1806 function bp_is_blogs_component() { 1681 global $bp; 1682 1683 if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component ) 1807 if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) ) 1684 1808 return true; 1685 1809 … … 1688 1812 1689 1813 function bp_is_messages_component() { 1690 global $bp; 1691 1692 if ( BP_MESSAGES_SLUG == $bp->current_component ) 1814 if ( bp_is_current_component( BP_MESSAGES_SLUG ) ) 1693 1815 return true; 1694 1816 … … 1697 1819 1698 1820 function bp_is_friends_component() { 1699 global $bp; 1700 1701 if ( BP_FRIENDS_SLUG == $bp->current_component ) 1821 if ( bp_is_current_component( BP_FRIENDS_SLUG ) ) 1702 1822 return true; 1703 1823 … … 1706 1826 1707 1827 function bp_is_groups_component() { 1708 global $bp; 1709 1710 if ( BP_GROUPS_SLUG == $bp->current_component ) 1828 if ( bp_is_current_component( BP_GROUPS_SLUG ) ) 1711 1829 return true; 1712 1830 … … 1715 1833 1716 1834 function bp_is_settings_component() { 1717 global $bp; 1718 1719 if ( BP_SETTINGS_SLUG == $bp->current_component ) 1835 if ( bp_is_current_component( BP_SETTINGS_SLUG ) ) 1720 1836 return true; 1721 1837 … … 1735 1851 global $bp; 1736 1852 1737 if ( $bp->activity->slug == $bp->current_component)1853 if ( bp_is_current_component( $bp->activity->slug ) ) 1738 1854 return true; 1739 1855 … … 1744 1860 global $bp; 1745 1861 1746 if ( $bp->activity->slug == $bp->current_component&& 'my-friends' == $bp->current_action )1862 if ( bp_is_current_component( $bp->activity->slug ) && 'my-friends' == $bp->current_action ) 1747 1863 return true; 1748 1864 … … 1753 1869 global $bp; 1754 1870 1755 if ( BP_ACTIVITY_SLUG == $bp->current_component&& is_numeric( $bp->current_action ) )1871 if ( bp_is_current_component( BP_ACTIVITY_SLUG ) && is_numeric( $bp->current_action ) ) 1756 1872 return true; 1757 1873 … … 1762 1878 global $bp; 1763 1879 1764 if ( defined( 'BP_XPROFILE_SLUG' ) && BP_XPROFILE_SLUG == $bp->current_component || isset( $bp->core->profile->slug ) && $bp->core->profile->slug == $bp->current_component)1880 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 ) ) 1765 1881 return true; 1766 1882 … … 1771 1887 global $bp; 1772 1888 1773 if ( BP_XPROFILE_SLUG == $bp->current_component&& 'edit' == $bp->current_action )1889 if ( bp_is_current_component( BP_XPROFILE_SLUG ) && 'edit' == $bp->current_action ) 1774 1890 return true; 1775 1891 … … 1780 1896 global $bp; 1781 1897 1782 if ( BP_XPROFILE_SLUG == $bp->current_component&& 'change-avatar' == $bp->current_action )1898 if ( bp_is_current_component( BP_XPROFILE_SLUG ) && 'change-avatar' == $bp->current_action ) 1783 1899 return true; 1784 1900 … … 1788 1904 function bp_is_user_groups() { 1789 1905 global $bp; 1790 1791 if ( $bp->groups->slug == $bp->current_component)1906 1907 if ( bp_is_current_component( BP_GROUPS_SLUG ) ) 1792 1908 return true; 1793 1909 … … 1797 1913 function bp_is_group() { 1798 1914 global $bp; 1799 1800 if ( BP_GROUPS_SLUG == $bp->current_component&& isset( $bp->groups->current_group ) && $bp->groups->current_group )1915 1916 if ( bp_is_current_component( BP_GROUPS_SLUG ) && isset( $bp->groups->current_group ) && $bp->groups->current_group ) 1801 1917 return true; 1802 1918 … … 1807 1923 global $bp; 1808 1924 1809 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )1925 if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) ) 1810 1926 return true; 1811 1927 … … 1816 1932 global $bp; 1817 1933 1818 if ( BP_GROUPS_SLUG == $bp->current_component&& 'create' == $bp->current_action )1934 if ( bp_is_current_component( BP_GROUPS_SLUG ) && 'create' == $bp->current_action ) 1819 1935 return true; 1820 1936 … … 1826 1942 global $bp; 1827 1943 1828 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'admin' == $bp->current_action )1944 if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'admin' == $bp->current_action ) 1829 1945 return true; 1830 1946 … … 1835 1951 global $bp; 1836 1952 1837 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'forum' == $bp->current_action )1953 if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'forum' == $bp->current_action ) 1838 1954 return true; 1839 1955 … … 1844 1960 global $bp; 1845 1961 1846 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'activity' == $bp->current_action )1962 if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'activity' == $bp->current_action ) 1847 1963 return true; 1848 1964 … … 1853 1969 global $bp; 1854 1970 1855 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )1971 if ( 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] ) 1856 1972 return true; 1857 1973 … … 1862 1978 global $bp; 1863 1979 1864 if ( BP_GROUPS_SLUG == $bp->current_component&& $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] )1980 if ( 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] ) 1865 1981 return true; 1866 1982 … … 1871 1987 global $bp; 1872 1988 1873 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'members' == $bp->current_action )1989 if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'members' == $bp->current_action ) 1874 1990 return true; 1875 1991 … … 1880 1996 global $bp; 1881 1997 1882 if ( BP_GROUPS_SLUG == $bp->current_component&& 'send-invites' == $bp->current_action )1998 if ( bp_is_current_component( BP_GROUPS_SLUG ) && 'send-invites' == $bp->current_action ) 1883 1999 return true; 1884 2000 … … 1889 2005 global $bp; 1890 2006 1891 if ( BP_GROUPS_SLUG == $bp->current_component&& 'request-membership' == $bp->current_action )2007 if ( bp_is_current_component( BP_GROUPS_SLUG ) && 'request-membership' == $bp->current_action ) 1892 2008 return true; 1893 2009 … … 1898 2014 global $bp; 1899 2015 1900 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'leave-group' == $bp->current_action )2016 if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'leave-group' == $bp->current_action ) 1901 2017 return true; 1902 2018 … … 1907 2023 global $bp; 1908 2024 1909 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item )2025 if ( bp_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item ) 1910 2026 return true; 1911 2027 … … 1916 2032 global $bp; 1917 2033 1918 if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component)2034 if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) ) 1919 2035 return true; 1920 2036 … … 1925 2041 global $bp; 1926 2042 1927 if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component&& 'recent-posts' == $bp->current_action )2043 if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) && 'recent-posts' == $bp->current_action ) 1928 2044 return true; 1929 2045 … … 1934 2050 global $bp; 1935 2051 1936 if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component&& 'recent-comments' == $bp->current_action )2052 if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) && 'recent-comments' == $bp->current_action ) 1937 2053 return true; 1938 2054 … … 1943 2059 global $bp; 1944 2060 1945 if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component&& 'create' == $bp->current_action )2061 if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) && 'create' == $bp->current_action ) 1946 2062 return true; 1947 2063 … … 1950 2066 1951 2067 function bp_is_user_friends() { 1952 global $bp; 1953 1954 if ( BP_FRIENDS_SLUG == $bp->current_component ) 2068 if ( bp_is_current_component( BP_FRIENDS_SLUG ) ) 1955 2069 return true; 1956 2070 … … 1961 2075 global $bp; 1962 2076 1963 if ( BP_FRIENDS_SLUG == $bp->current_component&& 'requests' == $bp->current_action )2077 if ( bp_is_current_component( BP_FRIENDS_SLUG ) && 'requests' == $bp->current_action ) 1964 2078 return true; 1965 2079 … … 1968 2082 1969 2083 function bp_is_user_messages() { 1970 global $bp; 1971 1972 if ( BP_MESSAGES_SLUG == $bp->current_component ) 2084 if ( bp_is_current_component( BP_MESSAGES_SLUG ) ) 1973 2085 return true; 1974 2086 … … 1979 2091 global $bp; 1980 2092 1981 if ( BP_MESSAGES_SLUG == $bp->current_component&& ( !$bp->current_action || 'inbox' == $bp->current_action ) )2093 if ( bp_is_current_component( BP_MESSAGES_SLUG ) && ( !$bp->current_action || 'inbox' == $bp->current_action ) ) 1982 2094 return true; 1983 2095 … … 1988 2100 global $bp; 1989 2101 1990 if ( BP_MESSAGES_SLUG == $bp->current_component&& 'sentbox' == $bp->current_action )2102 if ( bp_is_current_component( BP_MESSAGES_SLUG ) && 'sentbox' == $bp->current_action ) 1991 2103 return true; 1992 2104 … … 1998 2110 global $bp; 1999 2111 2000 if ( BP_MESSAGES_SLUG == $bp->current_component&& 'notices' == $bp->current_action )2112 if ( bp_is_current_component( BP_MESSAGES_SLUG ) && 'notices' == $bp->current_action ) 2001 2113 return true; 2002 2114 … … 2008 2120 global $bp; 2009 2121 2010 if ( BP_MESSAGES_SLUG == $bp->current_component&& 'compose' == $bp->current_action )2122 if ( bp_is_current_component( BP_MESSAGES_SLUG ) && 'compose' == $bp->current_action ) 2011 2123 return true; 2012 2124 … … 2024 2136 2025 2137 function bp_is_activation_page() { 2026 global $bp; 2027 2028 if ( BP_ACTIVATION_SLUG == $bp->current_component ) 2138 if ( bp_is_current_component( BP_ACTIVATION_SLUG ) ) 2029 2139 return true; 2030 2140 … … 2033 2143 2034 2144 function bp_is_register_page() { 2035 global $bp; 2036 2037 if ( BP_REGISTER_SLUG == $bp->current_component ) 2145 if ( bp_is_current_component( BP_REGISTER_SLUG ) ) 2038 2146 return true; 2039 2147 -
trunk/bp-core/css/admin.dev.css
r3727 r3728 1 html { 2 padding-top: 28px !important; 3 } 4 1 5 div#bp-admin { 2 6 margin: 25px 15px 25px 0; … … 9 13 10 14 div#bp-admin div#bp-admin-header { 11 height: 45px;15 12 16 } 13 17 -
trunk/bp-forums.php
r3713 r3728 1 1 <?php 2 2 3 / * Define the parent forum ID */3 // Define the parent forum ID 4 4 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) 5 5 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); … … 19 19 function bp_forums_setup() { 20 20 global $bp; 21 22 23 define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug);21 22 if ( !defined( 'BP_FORUMS_SLUG' ) ) 23 define ( 'BP_FORUMS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->forums->slug ) ); 24 24 25 25 // For internal identification 26 26 $bp->forums->id = 'forums'; 27 27 28 // Slugs 29 $bp->forums->slug = BP_FORUMS_SLUG; 30 $bp->forums->root_slug = $bp->pages->forums->slug; 31 32 // Images 28 33 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 29 $bp->forums->slug = BP_FORUMS_SLUG;30 34 31 35 if ( isset( $bp->site_options['bb-config-location'] ) ) … … 81 85 do_action( 'bbpress_init' ); 82 86 83 / * Check to see if the user has posted a new topic from the forums page. */87 // Check to see if the user has posted a new topic from the forums page. 84 88 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) { 85 /* Check the nonce */86 89 check_admin_referer( 'bp_forums_new_topic' ); 87 90 88 91 if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) { 89 / * Auto join this user if they are not yet a member of this group */92 // Auto join this user if they are not yet a member of this group 90 93 if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 91 94 groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id ); … … 134 137 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ); 135 138 136 / * Add the administration tab under the "Site Admin" tab for site administrators */139 // Add the administration tab under the "Site Admin" tab for site administrators 137 140 add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" ); 138 141 } 139 142 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_forums_add_admin_menu' ); 140 143 141 /* Forum Functions*/144 /** Forum Functions ***********************************************************/ 142 145 143 146 function bp_forums_get_forum( $forum_id ) { … … 150 153 151 154 $defaults = array( 152 'forum_name' => '',153 'forum_desc' => '',154 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID,155 'forum_order' => false,155 'forum_name' => '', 156 'forum_desc' => '', 157 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 158 'forum_order' => false, 156 159 'forum_is_category' => 0 157 160 ); … … 182 185 } 183 186 184 /* Topic Functions*/187 /** Topic Functions ***********************************************************/ 185 188 186 189 function bp_forums_get_forum_topics( $args = '' ) { … … 207 210 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' ); 208 211 $topics =& $query->results; 209 break;212 break; 210 213 211 214 case 'popular': 212 215 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 213 216 $topics =& $query->results; 214 break;217 break; 215 218 216 219 case 'unreplied': 217 220 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 218 221 $topics =& $query->results; 219 break;222 break; 220 223 221 224 case 'tags': 222 225 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) ); 223 226 $topics =& $query->results; 224 break;227 break; 225 228 } 226 229 … … 247 250 248 251 $defaults = array( 249 'topic_title' => '',250 'topic_slug' => '',251 'topic_text' => '',252 'topic_poster' => $bp->loggedin_user->id, // accepts ids253 'topic_poster_name' => $bp->loggedin_user->fullname, // accept names254 'topic_last_poster' => $bp->loggedin_user->id, // accepts ids252 'topic_title' => '', 253 'topic_slug' => '', 254 'topic_text' => '', 255 'topic_poster' => $bp->loggedin_user->id, // accepts ids 256 'topic_poster_name' => $bp->loggedin_user->fullname, // accept names 257 'topic_last_poster' => $bp->loggedin_user->id, // accepts ids 255 258 'topic_last_poster_name' => $bp->loggedin_user->fullname, // accept names 256 'topic_start_time' => bp_core_current_time(),257 'topic_time' => bp_core_current_time(),258 'topic_open' => 1,259 'topic_tags' => false, // accepts array or comma delim260 'forum_id' => 0 // accepts ids or slugs259 'topic_start_time' => bp_core_current_time(), 260 'topic_time' => bp_core_current_time(), 261 'topic_open' => 1, 262 'topic_tags' => false, // accepts array or comma delim 263 'forum_id' => 0 // accepts ids or slugs 261 264 ); 262 265 … … 275 278 return false; 276 279 277 / * Now insert the first post. */280 // Now insert the first post. 278 281 if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) ) 279 282 return false; … … 290 293 291 294 $defaults = array( 295 'topic_id' => false, 296 'topic_title' => '', 297 'topic_text' => '' 298 ); 299 300 $r = wp_parse_args( $args, $defaults ); 301 extract( $r, EXTR_SKIP ); 302 303 if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) ) 304 return false; 305 306 if ( !$post = bb_get_first_post( $topic_id ) ) 307 return false; 308 309 // Update the first post 310 if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) ) 311 return false; 312 313 return bp_forums_get_topic_details( $topic_id ); 314 } 315 316 function bp_forums_sticky_topic( $args = '' ) { 317 global $bp; 318 319 do_action( 'bbpress_init' ); 320 321 $defaults = array( 292 322 'topic_id' => false, 293 'topic_title' => '', 294 'topic_text' => '' 295 ); 296 297 $r = wp_parse_args( $args, $defaults ); 298 extract( $r, EXTR_SKIP ); 299 300 if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) ) 301 return false; 302 303 if ( !$post = bb_get_first_post( $topic_id ) ) 304 return false; 305 306 /* Update the first post */ 307 if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) ) 308 return false; 309 310 return bp_forums_get_topic_details( $topic_id ); 311 } 312 313 function bp_forums_sticky_topic( $args = '' ) { 314 global $bp; 315 316 do_action( 'bbpress_init' ); 317 318 $defaults = array( 319 'topic_id' => false, 320 'mode' => 'stick' // stick/unstick 323 'mode' => 'stick' // stick/unstick 321 324 ); 322 325 … … 339 342 $defaults = array( 340 343 'topic_id' => false, 341 'mode' => 'close' // stick/unstick344 'mode' => 'close' // stick/unstick 342 345 ); 343 346 … … 398 401 return $topics; 399 402 400 / * Get the topic ids */403 // Get the topic ids 401 404 foreach ( (array)$topics as $topic ) $topic_ids[] = $topic->topic_id; 402 405 $topic_ids = $wpdb->escape( join( ',', (array)$topic_ids ) ); 403 406 404 / * Fetch the topic's last poster details */407 // Fetch the topic's last poster details 405 408 $poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, t.topic_last_poster, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u, {$bbdb->topics} t WHERE u.ID = t.topic_last_poster AND t.topic_id IN ( {$topic_ids} )" ) ); 406 409 for ( $i = 0; $i < count( $topics ); $i++ ) { 407 410 foreach ( (array)$poster_details as $poster ) { 408 411 if ( $poster->topic_id == $topics[$i]->topic_id ) { 409 $topics[$i]->topic_last_poster_email = $poster->user_email;410 $topics[$i]->topic_last_poster_nicename = $poster->user_nicename;411 $topics[$i]->topic_last_poster_login = $poster->user_login;412 $topics[$i]->topic_last_poster_email = $poster->user_email; 413 $topics[$i]->topic_last_poster_nicename = $poster->user_nicename; 414 $topics[$i]->topic_last_poster_login = $poster->user_login; 412 415 $topics[$i]->topic_last_poster_displayname = $poster->display_name; 413 416 } … … 415 418 } 416 419 417 / * Fetch fullname for the topic's last poster */420 // Fetch fullname for the topic's last poster 418 421 if ( bp_is_active( 'xprofile' ) ) { 419 422 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) ); … … 429 432 } 430 433 431 /* Post Functions*/434 /** Post Functions ************************************************************/ 432 435 433 436 function bp_forums_get_topic_posts( $args = '' ) { … … 436 439 $defaults = array( 437 440 'topic_id' => false, 438 'page' => 1,441 'page' => 1, 439 442 'per_page' => 15, 440 'order' => 'ASC' 441 ); 442 443 $args = wp_parse_args( $args, $defaults ); 444 443 'order' => 'ASC' 444 ); 445 446 $args = wp_parse_args( $args, $defaults ); 445 447 $query = new BB_Query( 'post', $args, 'get_thread' ); 448 446 449 return bp_forums_get_post_extras( $query->results ); 447 450 } … … 473 476 474 477 $defaults = array( 475 'post_id' => false,476 'topic_id' => false,477 'post_text' => '',478 'post_time' => bp_core_current_time(),479 'poster_id' => $bp->loggedin_user->id, // accepts ids or names480 'poster_ip' => $_SERVER['REMOTE_ADDR'],481 'post_status' => 0, // use bb_delete_post() instead478 'post_id' => false, 479 'topic_id' => false, 480 'post_text' => '', 481 'post_time' => bp_core_current_time(), 482 'poster_id' => $bp->loggedin_user->id, // accepts ids or names 483 'poster_ip' => $_SERVER['REMOTE_ADDR'], 484 'post_status' => 0, // use bb_delete_post() instead 482 485 'post_position' => false 483 486 ); … … 503 506 $post_id = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) ); 504 507 505 if ( $post_id)508 if ( !empty( $post_id ) ) 506 509 do_action( 'bp_forums_new_post', $post_id ); 507 510 … … 515 518 return $posts; 516 519 517 / * Get the user ids */520 // Get the user ids 518 521 foreach ( (array)$posts as $post ) $user_ids[] = $post->poster_id; 519 522 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) ); 520 523 521 / * Fetch the poster's user_email, user_nicename and user_login */524 // Fetch the poster's user_email, user_nicename and user_login 522 525 $poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u WHERE u.ID IN ( {$user_ids} )" ) ); 523 526 … … 525 528 foreach ( (array)$poster_details as $poster ) { 526 529 if ( $poster->user_id == $posts[$i]->poster_id ) { 527 $posts[$i]->poster_email = $poster->user_email;528 $posts[$i]->poster_login = $poster->user_nicename;530 $posts[$i]->poster_email = $poster->user_email; 531 $posts[$i]->poster_login = $poster->user_nicename; 529 532 $posts[$i]->poster_nicename = $poster->user_login; 530 $posts[$i]->poster_name = $poster->display_name;533 $posts[$i]->poster_name = $poster->display_name; 531 534 } 532 535 } 533 536 } 534 537 535 / * Fetch fullname for each poster. */538 // Fetch fullname for each poster. 536 539 if ( bp_is_active( 'xprofile' ) ) { 537 540 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) ); … … 552 555 do_action( 'bbpress_init' ); 553 556 554 / * Need to find a bbPress function that does this */557 // Need to find a bbPress function that does this 555 558 return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) ); 556 559 } … … 586 589 add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' ); 587 590 add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' ); 588 add_action( 'bp_forums_new_post', 'bp_core_clear_cache' ); 591 add_action( 'bp_forums_new_post', 'bp_core_clear_cache' ); 592 589 593 ?> -
trunk/bp-friends.php
r3633 r3728 1 1 <?php 2 2 3 // Required Files 4 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' ); 5 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' ); 6 3 7 define ( 'BP_FRIENDS_DB_VERSION', '1800' ); 4 8 5 / * Define the slug for the component */9 // Define the slug for the component 6 10 if ( !defined( 'BP_FRIENDS_SLUG' ) ) 7 11 define ( 'BP_FRIENDS_SLUG', 'friends' ); 8 12 9 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );10 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );11 12 13 function friends_setup_globals() { 13 14 global $bp; 14 15 15 / * For internal identification */16 // For internal identification 16 17 $bp->friends->id = 'friends'; 17 18 19 // Slug 18 20 $bp->friends->slug = BP_FRIENDS_SLUG; 19 21 22 // Table 20 23 $bp->friends->table_name = $bp->table_prefix . 'bp_friends'; 21 24 25 // Notifications 22 26 $bp->friends->format_notification_function = 'friends_format_notifications'; 23 27 24 / * Register this in the active components array */28 // Register this in the active components array 25 29 $bp->active_components[$bp->friends->slug] = $bp->friends->id; 26 30 … … 32 36 global $bp; 33 37 34 / * Add 'Friends' to the main navigation */38 // Add 'Friends' to the main navigation 35 39 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Friends <span>(%d)</span>', 'buddypress' ), friends_get_total_friend_count() ), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) ); 36 40 37 41 $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/'; 38 42 39 / * Add the subnav items to the friends nav item */40 bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) );41 bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_my_profile()) );43 // Add the subnav items to the friends nav item 44 bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) ); 45 bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) ); 42 46 43 47 if ( $bp->current_component == $bp->friends->slug ) { … … 77 81 78 82 if ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'accept' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) { 79 / * Check the nonce */83 // Check the nonce 80 84 check_admin_referer( 'friends_accept_friendship' ); 81 85 … … 88 92 89 93 } elseif ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'reject' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) { 90 / * Check the nonce */94 // Check the nonce 91 95 check_admin_referer( 'friends_reject_friendship' ); 92 96 … … 110 114 global $bp; 111 115 112 $send_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ); 113 if ( !$send_requests ) 114 $send_requests = 'yes'; 115 116 $accept_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ); 117 if ( !$accept_requests ) 116 117 if ( !$send_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ) ) 118 $send_requests = 'yes'; 119 120 if ( !$accept_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) ) 118 121 $accept_requests = 'yes'; 119 122 ?> 123 120 124 <table class="notification-settings zebra" id="friends-notification-settings"> 121 125 <thead> … … 143 147 144 148 <?php do_action( 'friends_screen_notification_settings' ); ?> 149 145 150 </tbody> 146 151 </table> 152 147 153 <?php 148 154 } … … 184 190 bp_core_add_message( __( 'Friendship requested', 'buddypress' ) ); 185 191 } 192 186 193 } else if ( 'is_friend' == $friendship_status ) { 187 194 bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' ); … … 222 229 bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) ); 223 230 } 231 224 232 } else if ( 'is_friends' == $friendship_status ) { 225 233 bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' ); … … 248 256 return false; 249 257 250 $defaults = array (251 'user_id' => $bp->loggedin_user->id,252 'action' => '',253 'content' => '',254 'primary_link' => '',255 'component' => $bp->friends->id,256 'type' => false,257 'item_id' => false,258 $defaults = array ( 259 'user_id' => $bp->loggedin_user->id, 260 'action' => '', 261 'content' => '', 262 'primary_link' => '', 263 'component' => $bp->friends->id, 264 'type' => false, 265 'item_id' => false, 258 266 'secondary_item_id' => false, 259 'recorded_time' => bp_core_current_time(),260 'hide_sitewide' => false267 'recorded_time' => bp_core_current_time(), 268 'hide_sitewide' => false 261 269 ); 262 270 … … 300 308 return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname ); 301 309 } 302 break;310 break; 303 311 304 312 case 'friendship_request': … … 310 318 return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname ); 311 319 } 312 break;320 break; 313 321 } 314 322 … … 337 345 338 346 $friendship->initiator_user_id = $initiator_userid; 339 $friendship->friend_user_id = $friend_userid;340 $friendship->is_confirmed = 0;341 $friendship->is_limited = 0;342 $friendship->date_created = bp_core_current_time();347 $friendship->friend_user_id = $friend_userid; 348 $friendship->is_confirmed = 0; 349 $friendship->is_limited = 0; 350 $friendship->date_created = bp_core_current_time(); 343 351 344 352 if ( $force_accept ) … … 370 378 371 379 $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid ); 372 $friendship = new BP_Friends_Friendship( $friendship_id );380 $friendship = new BP_Friends_Friendship( $friendship_id ); 373 381 374 382 // Remove the activity stream item for the user who canceled the friendship … … 427 435 428 436 do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 437 429 438 return true; 430 439 } … … 456 465 } 457 466 467 // Returns - 'is_friend', 'not_friends', 'pending' 458 468 function friends_check_friendship_status( $user_id, $possible_friend_id ) { 459 /* Returns - 'is_friend', 'not_friends', 'pending' */460 469 return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ); 461 470 } 462 471 463 function friends_get_total_friend_count( $user_id = false) {472 function friends_get_total_friend_count( $user_id = 0 ) { 464 473 global $bp; 465 474 … … 504 513 } 505 514 506 function friends_get_recently_active( $user_id, $per_page = false, $page = false, $filter = false) {515 function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) { 507 516 return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) ); 508 517 } 509 518 510 function friends_get_alphabetically( $user_id, $per_page = false, $page = false, $filter = false) {519 function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) { 511 520 return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) ); 512 521 } 513 522 514 function friends_get_newest( $user_id, $per_page = false, $page = false, $filter = false) {523 function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) { 515 524 return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) ); 516 525 } … … 520 529 } 521 530 522 function friends_get_friends_invite_list( $user_id = false) {531 function friends_get_friends_invite_list( $user_id = 0 ) { 523 532 global $bp; 524 533 … … 549 558 } 550 559 551 function friends_search_users( $search_terms, $user_id, $pag_num = false, $pag_page = false) {560 function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) { 552 561 global $bp; 553 562 … … 557 566 return false; 558 567 559 for ( $i = 0; $i < count( $user_ids); $i++ ) {568 for ( $i = 0; $i < count( $user_ids ); $i++ ) 560 569 $users[] = new BP_Core_User($user_ids[$i]); 561 } 562 563 return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) ); 570 571 return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count( $search_terms ) ); 564 572 } 565 573 … … 584 592 BP_Friends_Friendship::delete_all_for_user($user_id); 585 593 586 / * Remove usermeta */594 // Remove usermeta 587 595 delete_user_meta( $user_id, 'total_friend_count' ); 588 596 589 / * Remove friendship requests FROM user */597 // Remove friendship requests FROM user 590 598 bp_core_delete_notifications_from_user( $user_id, $bp->friends->id, 'friendship_request' ); 591 599 592 600 do_action( 'friends_remove_data', $user_id ); 593 601 } 594 add_action( 'wpmu_delete_user', 'friends_remove_data' );595 add_action( 'delete_user', 'friends_remove_data' );602 add_action( 'wpmu_delete_user', 'friends_remove_data' ); 603 add_action( 'delete_user', 'friends_remove_data' ); 596 604 add_action( 'bp_make_spam_user', 'friends_remove_data' ); 597 605 … … 608 616 return false; 609 617 610 wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' );611 wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id,'bp' );618 wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' ); 619 wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' ); 612 620 wp_cache_delete( 'bp_total_friend_count_' . $friendship->initiator_user_id, 'bp' ); 613 wp_cache_delete( 'bp_total_friend_count_' . $friendship->friend_user_id, 'bp' );621 wp_cache_delete( 'bp_total_friend_count_' . $friendship->friend_user_id, 'bp' ); 614 622 } 615 623 … … 624 632 // List actions to clear object caches on 625 633 add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' ); 626 add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );634 add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' ); 627 635 628 636 // List actions to clear super cached pages on, if super cache is installed 629 add_action( 'friends_friendship_rejected', 'bp_core_clear_cache' );630 add_action( 'friends_friendship_accepted', 'bp_core_clear_cache' );631 add_action( 'friends_friendship_deleted', 'bp_core_clear_cache' );637 add_action( 'friends_friendship_rejected', 'bp_core_clear_cache' ); 638 add_action( 'friends_friendship_accepted', 'bp_core_clear_cache' ); 639 add_action( 'friends_friendship_deleted', 'bp_core_clear_cache' ); 632 640 add_action( 'friends_friendship_requested', 'bp_core_clear_cache' ); 633 641 -
trunk/bp-groups.php
r3648 r3728 1 1 <?php 2 3 // Required Files 2 4 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php' ); 3 5 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-templatetags.php' ); … … 14 16 global $bp; 15 17 18 // Define a slug, if necessary 16 19 if ( !defined( 'BP_GROUPS_SLUG' ) ) 17 define ( 'BP_GROUPS_SLUG', $bp->pages->groups->slug ); 18 19 /* For internal identification */ 20 $bp->groups->id = 'groups'; 21 $bp->groups->name = $bp->pages->groups->name; 22 $bp->groups->slug = BP_GROUPS_SLUG; 23 20 define ( 'BP_GROUPS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->groups->slug ) ); 21 22 // For internal identification 23 $bp->groups->id = 'groups'; 24 $bp->groups->name = $bp->pages->groups->name; 25 26 // Slugs 27 $bp->groups->slug = BP_GROUPS_SLUG; 28 $bp->groups->root_slug = $bp->pages->groups->slug; 29 30 // Tables 24 31 $bp->groups->table_name = $bp->table_prefix . 'bp_groups'; 25 32 $bp->groups->table_name_members = $bp->table_prefix . 'bp_groups_members'; 26 33 $bp->groups->table_name_groupmeta = $bp->table_prefix . 'bp_groups_groupmeta'; 27 34 35 // Notifications 28 36 $bp->groups->format_notification_function = 'groups_format_notifications'; 29 37 30 / * Register this in the active components array */38 // Register this in the active components array 31 39 $bp->active_components[$bp->groups->slug] = $bp->groups->id; 32 40 … … 34 42 35 43 $bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array( 36 'group-details' => array( 'name' => __( 'Details', 'buddypress' ), 'position' => 0 ),44 'group-details' => array( 'name' => __( 'Details', 'buddypress' ), 'position' => 0 ), 37 45 'group-settings' => array( 'name' => __( 'Settings', 'buddypress' ), 'position' => 10 ), 38 'group-avatar' => array( 'name' => __( 'Avatar', 'buddypress' ), 'position' => 20 ),46 'group-avatar' => array( 'name' => __( 'Avatar', 'buddypress' ), 'position' => 20 ), 39 47 ) ); 40 48 … … 48 56 49 57 // The default text for the groups directory search box 50 58 $bp->default_search_strings[$bp->groups->slug] = __( 'Search Groups...', 'buddypress' ); 51 59 52 60 do_action( 'groups_setup_globals' ); … … 57 65 global $bp; 58 66 59 if ( $bp->current_component == $bp->groups->slug&& $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {60 61 / * This is a single group page. */67 if ( bp_is_current_component( $bp->groups->slug ) && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) { 68 69 // This is a single group page. 62 70 $bp->is_single_item = true; 63 71 $bp->groups->current_group = new BP_Groups_Group( $group_id ); 64 72 65 / * Using "item" not "group" for generic support in other components. */73 // Using "item" not "group" for generic support in other components. 66 74 if ( is_super_admin() ) 67 75 $bp->is_item_admin = 1; … … 69 77 $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ); 70 78 71 / * If the user is not an admin, check if they are a moderator */79 // If the user is not an admin, check if they are a moderator 72 80 if ( !$bp->is_item_admin ) 73 81 $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id ); 74 82 75 / * Is the logged in user a member of the group? */83 // Is the logged in user a member of the group? 76 84 $bp->groups->current_group->is_user_member = ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ? true : false; 77 85 78 / * Should this group be visible to the logged in user? */86 // Should this group be visible to the logged in user? 79 87 $bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $bp->groups->current_group->is_user_member ) ? true : false; 80 88 } 81 89 82 / * Add 'Groups' to the main navigation */83 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups-> name, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );84 85 $groups_link = $bp->loggedin_user->domain . $bp->groups-> name. '/';86 87 / * Add the subnav items to the groups nav item */88 bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups-> name, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id'=> 'groups-my-groups' ) );89 bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );90 91 if ( $bp->current_component == $bp->groups->slug) {90 // Add 'Groups' to the main navigation 91 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) ); 92 93 $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/'; 94 95 // Add the subnav items to the groups nav item 96 bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) ); 97 bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) ); 98 99 if ( bp_is_current_component( $bp->groups->slug ) ) { 92 100 93 101 if ( bp_is_my_profile() && !$bp->is_single_item ) { … … 104 112 // group navigation menu using the $bp->groups->current_group global. 105 113 106 / *When in a single group, the first action is bumped down one because of the107 group name, so we need to adjust this and set the group name to current_item. */108 $bp->current_item = isset( $bp->current_action ) ? $bp->current_action: false;114 // When in a single group, the first action is bumped down one because of the 115 // group name, so we need to adjust this and set the group name to current_item. 116 $bp->current_item = isset( $bp->current_action ) ? $bp->current_action : false; 109 117 $bp->current_action = isset( $bp->action_variables[0] ) ? $bp->action_variables[0] : false; 110 array_shift( $bp->action_variables);118 array_shift( $bp->action_variables ); 111 119 112 120 $bp->bp_options_title = $bp->groups->current_group->name; … … 115 123 $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />'; 116 124 117 $group_link = $bp->root_domain . '/' . $bp->groups-> slug . '/' . $bp->groups->current_group->slug . '/';125 $group_link = $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $bp->groups->current_group->slug . '/'; 118 126 119 127 // If this is a private or hidden group, does the user have access? … … 127 135 } 128 136 129 / * Reset the existing subnav items */130 bp_core_reset_subnav_items( $bp->groups->slug);131 132 / * Add a new default subnav item for when the groups nav is selected. */133 bp_core_new_nav_default( array( 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );134 135 / * Add the "Home" subnav item, as this will always be present */136 bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) );137 138 / * If the user is a group mod or more, then show the group admin nav item */137 // Reset the existing subnav items 138 bp_core_reset_subnav_items( $bp->groups->root_slug ); 139 140 // Add a new default subnav item for when the groups nav is selected. 141 bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) ); 142 143 // Add the "Home" subnav item, as this will always be present 144 bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) ); 145 146 // If the user is a group mod or more, then show the group admin nav item 139 147 if ( $bp->is_item_mod || $bp->is_item_admin ) 140 bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) );148 bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) ); 141 149 142 150 // If this is a private group, and the user is not a member, show a "Request Membership" nav item. 143 151 if ( !is_super_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' ) 144 bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) ); 145 146 if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') ) 147 bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) ); 148 149 bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members' ) ); 152 bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) ); 153 154 // Forums are enabled and turned on 155 if ( $bp->groups->current_group->enable_forum && function_exists( 'bp_forums_setup' ) ) 156 bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) ); 157 158 bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members' ) ); 150 159 151 160 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 152 161 if ( bp_is_active('friends') ) 153 bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );162 bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) ); 154 163 } 155 164 } … … 165 174 function groups_directory_groups_setup() { 166 175 global $bp; 167 168 if ( $bp->current_component == $bp->groups->slug&& empty( $bp->current_action ) && empty( $bp->current_item ) ) {176 177 if ( bp_is_current_component( $bp->groups->slug ) && empty( $bp->current_action ) && empty( $bp->current_item ) ) { 169 178 $bp->is_directory = true; 170 179 … … 181 190 return false; 182 191 183 / * Don't show this menu to non site admins or if you're viewing your own profile */192 // Don't show this menu to non site admins or if you're viewing your own profile 184 193 if ( !is_super_admin() ) 185 return false; 186 ?> 194 return false; ?> 195 187 196 <li id="bp-adminbar-adminoptions-menu"> 188 197 <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a> … … 192 201 193 202 <?php do_action( 'groups_adminbar_menu_items' ) ?> 203 194 204 </ul> 195 205 </li> 206 196 207 <?php 197 208 } 198 209 add_action( 'bp_adminbar_menus', 'groups_setup_adminbar_menu', 20 ); 199 200 210 201 211 /******************************************************************************** … … 210 220 global $bp; 211 221 212 if ( isset($_GET['n']) ) {213 // Delete group request notifications for the user222 // Delete group request notifications for the user 223 if ( isset( $_GET['n'] ) ) { 214 224 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' ); 215 225 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' ); 216 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' );217 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' );226 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' ); 227 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' ); 218 228 } 219 229 … … 231 241 232 242 if ( isset( $bp->action_variables ) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric( $group_id ) ) { 233 / * Check the nonce */243 // Check the nonce 234 244 if ( !check_admin_referer( 'groups_accept_invite' ) ) 235 245 return false; … … 240 250 bp_core_add_message( __('Group invite accepted', 'buddypress') ); 241 251 242 / * Record this in activity streams */252 // Record this in activity streams 243 253 $group = new BP_Groups_Group( $group_id ); 244 254 245 255 groups_record_activity( array( 246 'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),247 'type' => 'joined_group',256 'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ), 257 'type' => 'joined_group', 248 258 'item_id' => $group->id 249 259 ) ); … … 253 263 254 264 } elseif ( isset( $bp->action_variables ) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric( $group_id ) ) { 255 / * Check the nonce */265 // Check the nonce 256 266 if ( !check_admin_referer( 'groups_reject_invite' ) ) 257 267 return false; … … 277 287 278 288 if ( $bp->is_single_item ) { 279 if ( isset($_GET['n']) ) { 280 // Delete group request notifications for the user 289 if ( isset( $_GET['n'] ) ) { 281 290 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' ); 282 291 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' ); 283 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' );284 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' );292 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' ); 293 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' ); 285 294 } 286 295 … … 296 305 if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) { 297 306 298 /* Fetch the details we need */ 299 $topic_slug = isset( $bp->action_variables[1] ) ? $bp->action_variables[1] : false; 300 $topic_id = bp_forums_get_topic_id_from_slug( $topic_slug ); 301 $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ); 302 307 // Fetch the details we need 308 $topic_slug = isset( $bp->action_variables[1] ) ? $bp->action_variables[1] : false; 309 $topic_id = bp_forums_get_topic_id_from_slug( $topic_slug ); 310 $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ); 303 311 $user_is_banned = false; 312 304 313 if ( !is_super_admin() && groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 305 314 $user_is_banned = true; … … 307 316 if ( $topic_slug && $topic_id ) { 308 317 309 / * Posting a reply */318 // Posting a reply 310 319 if ( !$user_is_banned && !isset( $bp->action_variables[2] ) && isset( $_POST['submit_reply'] ) ) { 311 / * Check the nonce */320 // Check the nonce 312 321 check_admin_referer( 'bp_forums_new_reply' ); 313 322 314 / * Auto join this user if they are not yet a member of this group */323 // Auto join this user if they are not yet a member of this group 315 324 if ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 316 325 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 317 326 318 327 $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false; 319 328 320 329 if ( !$post_id = groups_new_group_forum_post( $_POST['reply_text'], $topic_id, $topic_page ) ) … … 329 338 } 330 339 331 / * Sticky a topic */340 // Sticky a topic 332 341 else if ( isset( $bp->action_variables[2] ) && 'stick' == $bp->action_variables[2] && ( isset( $bp->is_item_admin ) || isset( $bp->is_item_mod ) ) ) { 333 / * Check the nonce */342 // Check the nonce 334 343 check_admin_referer( 'bp_forums_stick_topic' ); 335 344 … … 343 352 } 344 353 345 / * Un-Sticky a topic */354 // Un-Sticky a topic 346 355 else if ( isset( $bp->action_variables[2] ) && 'unstick' == $bp->action_variables[2] && ( isset( $bp->is_item_admin ) || isset( $bp->is_item_mod ) ) ) { 347 / * Check the nonce */356 // Check the nonce 348 357 check_admin_referer( 'bp_forums_unstick_topic' ); 349 358 … … 357 366 } 358 367 359 / * Close a topic */368 // Close a topic 360 369 else if ( isset( $bp->action_variables[2] ) && 'close' == $bp->action_variables[2] && ( isset( $bp->is_item_admin ) || isset( $bp->is_item_mod ) ) ) { 361 / * Check the nonce */370 // Check the nonce 362 371 check_admin_referer( 'bp_forums_close_topic' ); 363 372 … … 371 380 } 372 381 373 / * Open a topic */382 // Open a topic 374 383 else if ( isset( $bp->action_variables[2] ) && 'open' == $bp->action_variables[2] && ( isset( $bp->is_item_admin ) || isset( $bp->is_item_mod ) ) ) { 375 / * Check the nonce */384 // Check the nonce 376 385 check_admin_referer( 'bp_forums_open_topic' ); 377 386 … … 385 394 } 386 395 387 / * Delete a topic */396 // Delete a topic 388 397 else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'delete' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) { 389 / * Fetch the topic */398 // Fetch the topic 390 399 $topic = bp_forums_get_topic_details( $topic_id ); 391 400 … … 394 403 bp_core_redirect( wp_get_referer() ); 395 404 396 / * Check the nonce */405 // Check the nonce 397 406 check_admin_referer( 'bp_forums_delete_topic' ); 398 407 … … 407 416 } 408 417 409 / * Editing a topic */418 // Editing a topic 410 419 else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) { 411 / * Fetch the topic */420 // Fetch the topic 412 421 $topic = bp_forums_get_topic_details( $topic_id ); 413 422 414 / * Check the logged in user can edit this topic */423 // Check the logged in user can edit this topic 415 424 if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster ) 416 425 bp_core_redirect( wp_get_referer() ); 417 426 418 427 if ( isset( $_POST['save_changes'] ) ) { 419 / * Check the nonce */428 // Check the nonce 420 429 check_admin_referer( 'bp_forums_edit_topic' ); 421 430 … … 432 441 } 433 442 434 / * Delete a post */443 // Delete a post 435 444 else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'delete' == $bp->action_variables[2] && isset( $bp->action_variables[4] ) && $post_id = $bp->action_variables[4] ) { 436 / * Fetch the post */445 // Fetch the post 437 446 $post = bp_forums_get_post( $post_id ); 438 447 439 / * Check the logged in user can edit this topic */448 // Check the logged in user can edit this topic 440 449 if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id ) 441 450 bp_core_redirect( wp_get_referer() ); 442 451 443 / * Check the nonce */452 // Check the nonce 444 453 check_admin_referer( 'bp_forums_delete_post' ); 445 454 … … 455 464 } 456 465 457 / * Editing a post */466 // Editing a post 458 467 else if ( !$user_is_banned && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] && isset( $bp->action_variables[4] ) && $post_id = $bp->action_variables[4] ) { 459 / * Fetch the post */468 // Fetch the post 460 469 $post = bp_forums_get_post( $bp->action_variables[4] ); 461 470 462 / * Check the logged in user can edit this topic */471 // Check the logged in user can edit this topic 463 472 if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id ) 464 473 bp_core_redirect( wp_get_referer() ); 465 474 466 475 if ( isset( $_POST['save_changes'] ) ) { 467 / * Check the nonce */476 // Check the nonce 468 477 check_admin_referer( 'bp_forums_edit_post' ); 469 478 … … 483 492 } 484 493 485 / * Standard topic display */494 // Standard topic display 486 495 else { 487 496 if ( $user_is_banned ) … … 492 501 493 502 } else { 494 / * Posting a topic */503 // Posting a topic 495 504 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) { 496 / * Check the nonce */505 // Check the nonce 497 506 check_admin_referer( 'bp_forums_new_topic' ); 498 507 … … 578 587 // If the user has submitted a request, send it. 579 588 if ( isset( $_POST['group-request-send']) ) { 580 / * Check the nonce first. */589 // Check the nonce 581 590 if ( !check_admin_referer( 'groups_request_membership' ) ) 582 591 return false; … … 599 608 global $bp; 600 609 601 if ( $bp->current_component != $bp->groups->slug|| $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )610 if ( !bp_is_current_component( $bp->groups->slug ) || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) ) 602 611 return false; 603 612 … … 611 620 global $bp; 612 621 613 if ( $bp->current_component != BP_GROUPS_SLUG|| 'admin' != $bp->current_action )622 if ( !bp_is_current_component( BP_GROUPS_SLUG ) || 'admin' != $bp->current_action ) 614 623 return false; 615 624 … … 623 632 global $bp; 624 633 625 if ( $bp->current_component == $bp->groups->slug&& 'edit-details' == $bp->action_variables[0] ) {634 if ( bp_is_current_component( $bp->groups->slug ) && 'edit-details' == $bp->action_variables[0] ) { 626 635 627 636 if ( $bp->is_item_admin || $bp->is_item_mod ) { … … 629 638 // If the edit form has been submitted, save the edited details 630 639 if ( isset( $_POST['save'] ) ) { 631 / * Check the nonce first. */640 // Check the nonce 632 641 if ( !check_admin_referer( 'groups_edit_group_details' ) ) 633 642 return false; … … 655 664 global $bp; 656 665 657 if ( $bp->current_component == $bp->groups->slug&& 'group-settings' == $bp->action_variables[0] ) {666 if ( bp_is_current_component( $bp->groups->slug ) && 'group-settings' == $bp->action_variables[0] ) { 658 667 659 668 if ( !$bp->is_item_admin ) … … 667 676 $status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public'; 668 677 669 / * Check the nonce first. */678 // Check the nonce 670 679 if ( !check_admin_referer( 'groups_edit_group_settings' ) ) 671 680 return false; … … 692 701 global $bp; 693 702 694 if ( $bp->current_component == $bp->groups->slug&& 'group-avatar' == $bp->action_variables[0] ) {703 if ( bp_is_current_component( $bp->groups->slug ) && 'group-avatar' == $bp->action_variables[0] ) { 695 704 696 705 if ( !$bp->is_item_admin ) 697 706 return false; 698 707 699 / * If the group admin has deleted the admin avatar */708 // If the group admin has deleted the admin avatar 700 709 if ( 'delete' == $bp->action_variables[1] ) { 701 710 702 / * Check the nonce */711 // Check the nonce 703 712 check_admin_referer( 'bp_group_avatar_delete' ); 704 713 … … 714 723 if ( !empty( $_FILES ) ) { 715 724 716 / * Check the nonce */725 // Check the nonce 717 726 check_admin_referer( 'bp_avatar_upload' ); 718 727 719 / * Pass the file to the avatar upload handler */728 // Pass the file to the avatar upload handler 720 729 if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) { 721 730 $bp->avatar_admin->step = 'crop-image'; 722 731 723 / * Make sure we include the jQuery jCrop file for image cropping */732 // Make sure we include the jQuery jCrop file for image cropping 724 733 add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' ); 725 734 } … … 727 736 } 728 737 729 / * If the image cropping is done, crop the image and save a full/thumb version */738 // If the image cropping is done, crop the image and save a full/thumb version 730 739 if ( isset( $_POST['avatar-crop-submit'] ) ) { 731 740 732 / * Check the nonce */741 // Check the nonce 733 742 check_admin_referer( 'bp_avatar_cropstore' ); 734 743 … … 750 759 global $bp; 751 760 752 if ( $bp->current_component == $bp->groups->slug&& 'manage-members' == $bp->action_variables[0] ) {761 if ( bp_is_current_component( $bp->groups->slug ) && 'manage-members' == $bp->action_variables[0] ) { 753 762 754 763 if ( !$bp->is_item_admin ) … … 856 865 global $bp; 857 866 858 if ( $bp->current_component == $bp->groups->slug&& 'membership-requests' == $bp->action_variables[0] ) {859 860 / * Ask for a login if the user is coming here via an email notification */867 if ( bp_is_current_component( $bp->groups->slug ) && 'membership-requests' == $bp->action_variables[0] ) { 868 869 // Ask for a login if the user is coming here via an email notification 861 870 if ( !is_user_logged_in() ) 862 871 bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests/' ) ); … … 874 883 if ( 'accept' == $request_action && is_numeric($membership_id) ) { 875 884 876 / * Check the nonce first. */885 // Check the nonce first. 877 886 if ( !check_admin_referer( 'groups_accept_membership_request' ) ) 878 887 return false; … … 914 923 global $bp; 915 924 916 if ( $bp->current_component == $bp->groups->slug&& 'delete-group' == $bp->action_variables[0] ) {925 if ( bp_is_current_component( $bp->groups->slug ) && 'delete-group' == $bp->action_variables[0] ) { 917 926 918 927 if ( !$bp->is_item_admin && !is_super_admin() ) … … 920 929 921 930 if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) { 922 / * Check the nonce first. */931 // Check the nonce first. 923 932 if ( !check_admin_referer( 'groups_delete_group' ) ) 924 933 return false; … … 950 959 global $bp; 951 960 952 $group_invite = get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true ); 953 if ( !$group_invite ) 954 $group_invite = 'yes'; 955 956 $group_update = get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true ); 957 if ( !$group_update ) 958 $group_update = 'yes'; 959 960 $group_promo = get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true ); 961 if ( !$group_promo ) 962 $group_promo = 'yes'; 963 964 $group_request = get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true ); 965 if ( !$group_request ) 961 if ( !$group_invite = get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true ) ) 962 $group_invite = 'yes'; 963 964 if ( !$group_update = get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true ) ) 965 $group_update = 'yes'; 966 967 if ( !$group_promo = get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true ) ) 968 $group_promo = 'yes'; 969 970 if ( !$group_request = get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true ) ) 966 971 $group_request = 'yes'; 967 972 ?> 973 968 974 <table class="notification-settings zebra" id="groups-notification-settings"> 969 975 <thead> … … 1003 1009 1004 1010 <?php do_action( 'groups_screen_notification_settings' ); ?> 1011 1005 1012 </tbody> 1006 1013 </table> 1014 1007 1015 <?php 1008 1016 } … … 1021 1029 global $bp; 1022 1030 1023 / * If we're not at domain.org/groups/create/ then return false */1024 if ( $bp->current_component != $bp->groups->slug|| 'create' != $bp->current_action )1031 // If we're not at domain.org/groups/create/ then return false 1032 if ( !bp_is_current_component( $bp->groups->slug ) || 'create' != $bp->current_action ) 1025 1033 return false; 1026 1034 … … 1028 1036 return false; 1029 1037 1030 / * Make sure creation steps are in the right order */1038 // Make sure creation steps are in the right order 1031 1039 groups_action_sort_creation_steps(); 1032 1040 1033 / * If no current step is set, reset everything so we can start a fresh group creation */1041 // If no current step is set, reset everything so we can start a fresh group creation 1034 1042 if ( !isset( $bp->action_variables[1] ) || !$bp->groups->current_create_step = $bp->action_variables[1] ) { 1035 1043 … … 1041 1049 1042 1050 $reset_steps = true; 1043 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );1044 } 1045 1046 / * If this is a creation step that is not recognized, just redirect them back to the first screen */1051 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' ); 1052 } 1053 1054 // If this is a creation step that is not recognized, just redirect them back to the first screen 1047 1055 if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) { 1048 1056 bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' ); 1049 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/' );1050 } 1051 1052 / * Fetch the currently completed steps variable */1057 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/' ); 1058 } 1059 1060 // Fetch the currently completed steps variable 1053 1061 if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !isset( $reset_steps ) ) 1054 1062 $bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE['bp_completed_create_steps'] ) ); 1055 1063 1056 / * Set the ID of the new group, if it has already been created in a previous step */1064 // Set the ID of the new group, if it has already been created in a previous step 1057 1065 if ( isset( $_COOKIE['bp_new_group_id'] ) ) { 1058 1066 $bp->groups->new_group_id = $_COOKIE['bp_new_group_id']; … … 1060 1068 } 1061 1069 1062 / * If the save, upload or skip button is hit, lets calculate what we need to save */1070 // If the save, upload or skip button is hit, lets calculate what we need to save 1063 1071 if ( isset( $_POST['save'] ) ) { 1064 1072 1065 / * Check the nonce */1073 // Check the nonce 1066 1074 check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step ); 1067 1075 … … 1069 1077 if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) { 1070 1078 bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' ); 1071 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . $bp->groups->current_create_step . '/' );1079 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' ); 1072 1080 } 1073 1081 … … 1076 1084 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => bp_core_current_time(), 'status' => 'public' ) ) ) { 1077 1085 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 1078 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . $bp->groups->current_create_step . '/' );1086 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' ); 1079 1087 } 1080 1088 … … 1090 1098 $group_enable_forum = 0; 1091 1099 } else { 1092 / * Create the forum if enable_forum = 1 */1100 // Create the forum if enable_forum = 1 1093 1101 if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) { 1094 1102 groups_new_group_forum(); … … 1103 1111 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) { 1104 1112 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 1105 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . $bp->groups->current_create_step . '/' );1113 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' ); 1106 1114 } 1107 1115 } 1108 1116 1109 if ( 'group-invites' == $bp->groups->current_create_step ) {1117 if ( 'group-invites' == $bp->groups->current_create_step ) 1110 1118 groups_send_invites( $bp->loggedin_user->id, $bp->groups->new_group_id ); 1111 }1112 1119 1113 1120 do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step ); … … 1123 1130 $bp->groups->completed_create_steps[] = $bp->groups->current_create_step; 1124 1131 1125 / * Reset cookie info */1132 // Reset cookie info 1126 1133 setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH ); 1127 1134 setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH ); 1128 1135 1129 /* If we have completed all steps and hit done on the final step we can redirect to the completed group */ 1136 // If we have completed all steps and hit done on the final step we 1137 // can redirect to the completed group 1130 1138 if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && $bp->groups->current_create_step == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) { 1131 1139 unset( $bp->groups->current_create_step ); 1132 1140 unset( $bp->groups->completed_create_steps ); 1133 1141 1134 / * Once we compelete all steps, record the group creation in the activity stream. */1142 // Once we compelete all steps, record the group creation in the activity stream. 1135 1143 groups_record_activity( array( 1136 1144 'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%1$s created the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ) ), … … 1159 1167 } 1160 1168 1161 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . $next_step . '/' );1162 } 1163 } 1164 1165 / * Group avatar is handled separately */1169 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $next_step . '/' ); 1170 } 1171 } 1172 1173 // Group avatar is handled separately 1166 1174 if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) { 1167 1175 if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) { 1168 / * Normally we would check a nonce here, but the group save nonce is used instead */1169 1170 / * Pass the file to the avatar upload handler */1176 // Normally we would check a nonce here, but the group save nonce is used instead 1177 1178 // Pass the file to the avatar upload handler 1171 1179 if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) { 1172 1180 $bp->avatar_admin->step = 'crop-image'; 1173 1181 1174 / * Make sure we include the jQuery jCrop file for image cropping */1182 // Make sure we include the jQuery jCrop file for image cropping 1175 1183 add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' ); 1176 1184 } 1177 1185 } 1178 1186 1179 / * If the image cropping is done, crop the image and save a full/thumb version */1187 // If the image cropping is done, crop the image and save a full/thumb version 1180 1188 if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) { 1181 / * Normally we would check a nonce here, but the group save nonce is used instead */1189 // Normally we would check a nonce here, but the group save nonce is used instead 1182 1190 1183 1191 if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) ) … … 1195 1203 global $bp; 1196 1204 1197 if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug|| $bp->current_action != 'join' )1205 if ( !$bp->is_single_item || !bp_is_current_component( $bp->groups->slug ) || $bp->current_action != 'join' ) 1198 1206 return false; 1199 1207 … … 1230 1238 global $bp; 1231 1239 1232 if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug|| $bp->current_action != 'leave-group' )1240 if ( !$bp->is_single_item || !bp_is_current_component( $bp->groups->slug ) || $bp->current_action != 'leave-group' ) 1233 1241 return false; 1234 1242 … … 1255 1263 global $bp; 1256 1264 1257 if ( $bp->current_component != BP_GROUPS_SLUG&& $bp->current_action != 'create' )1265 if ( !bp_is_current_component( BP_GROUPS_SLUG ) && $bp->current_action != 'create' ) 1258 1266 return false; 1259 1267 … … 1268 1276 } 1269 1277 1270 / * Sort the steps by their position key */1278 // Sort the steps by their position key 1271 1279 ksort($temp); 1272 1280 unset($bp->groups->group_creation_steps); … … 1279 1287 global $bp, $wpdb; 1280 1288 1281 if ( $bp->current_component == $bp->groups->slug&& isset( $_GET['random-group'] ) ) {1289 if ( bp_is_current_component( $bp->groups->slug ) && isset( $_GET['random-group'] ) ) { 1282 1290 $group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) ); 1283 1291 … … 1290 1298 global $bp, $wp_query; 1291 1299 1292 if ( !bp_is_active( 'activity' ) || $bp->current_component != $bp->groups->slug|| !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' )1300 if ( !bp_is_active( 'activity' ) || !bp_is_current_component( $bp->groups->slug ) || !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' ) 1293 1301 return false; 1294 1302 … … 1320 1328 return false; 1321 1329 1322 bp_activity_set_action( $bp->groups->id, 'created_group', __( 'Created a group','buddypress' ) );1323 bp_activity_set_action( $bp->groups->id, 'joined_group', __( 'Joined a group','buddypress' ) );1330 bp_activity_set_action( $bp->groups->id, 'created_group', __( 'Created a group', 'buddypress' ) ); 1331 bp_activity_set_action( $bp->groups->id, 'joined_group', __( 'Joined a group', 'buddypress' ) ); 1324 1332 bp_activity_set_action( $bp->groups->id, 'new_forum_topic', __( 'New group forum topic', 'buddypress' ) ); 1325 bp_activity_set_action( $bp->groups->id, 'new_forum_post', __( 'New group forum post','buddypress' ) );1333 bp_activity_set_action( $bp->groups->id, 'new_forum_post', __( 'New group forum post', 'buddypress' ) ); 1326 1334 1327 1335 do_action( 'groups_register_activity_actions' ); … … 1335 1343 return false; 1336 1344 1337 / * If the group is not public, hide the activity sitewide. */1345 // If the group is not public, hide the activity sitewide. 1338 1346 if ( 'public' == $bp->groups->current_group->status ) 1339 1347 $hide_sitewide = false; … … 1341 1349 $hide_sitewide = true; 1342 1350 1343 $defaults = array (1344 'id' => false,1345 'user_id' => $bp->loggedin_user->id,1346 'action' => '',1347 'content' => '',1348 'primary_link' => '',1349 'component' => $bp->groups->id,1350 'type' => false,1351 'item_id' => false,1351 $defaults = array ( 1352 'id' => false, 1353 'user_id' => $bp->loggedin_user->id, 1354 'action' => '', 1355 'content' => '', 1356 'primary_link' => '', 1357 'component' => $bp->groups->id, 1358 'type' => false, 1359 'item_id' => false, 1352 1360 'secondary_item_id' => false, 1353 'recorded_time' => bp_core_current_time(),1354 'hide_sitewide' => $hide_sitewide1361 'recorded_time' => bp_core_current_time(), 1362 'hide_sitewide' => $hide_sitewide 1355 1363 ); 1356 1364 … … 1361 1369 } 1362 1370 1363 function groups_update_last_activity( $group_id = false) {1371 function groups_update_last_activity( $group_id = 0 ) { 1364 1372 global $bp; 1365 1373 … … 1395 1403 return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . 'admin/membership-requests/?n=1" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . sprintf( __( '%1$s requests membership for the group "%2$s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name ); 1396 1404 } 1397 break;1405 break; 1398 1406 1399 1407 case 'membership_request_accepted': … … 1408 1416 return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name ); 1409 1417 1410 break;1418 break; 1411 1419 1412 1420 case 'membership_request_rejected': … … 1421 1429 return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name ); 1422 1430 1423 break;1431 break; 1424 1432 1425 1433 case 'member_promoted_to_admin': … … 1434 1442 return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to an admin in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name ); 1435 1443 1436 break;1444 break; 1437 1445 1438 1446 case 'member_promoted_to_mod': … … 1447 1455 return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to a mod in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name ); 1448 1456 1449 break;1457 break; 1450 1458 1451 1459 case 'group_invite': … … 1460 1468 return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name ); 1461 1469 1462 break;1470 break; 1463 1471 } 1464 1472 … … 1480 1488 function groups_get_group( $args = '' ) { 1481 1489 $defaults = array( 1482 'group_id' => false,1490 'group_id' => false, 1483 1491 'load_users' => false 1484 1492 ); … … 1544 1552 return false; 1545 1553 1554 // If this is a new group, set up the creator as the first member and admin 1546 1555 if ( !$group_id ) { 1547 // If this is a new group, set up the creator as the first member and admin 1548 $member = new BP_Groups_Member; 1549 $member->group_id = $group->id; 1550 $member->user_id = $group->creator_id; 1551 $member->is_admin = 1; 1552 $member->user_title = __( 'Group Admin', 'buddypress' ); 1553 $member->is_confirmed = 1; 1556 $member = new BP_Groups_Member; 1557 $member->group_id = $group->id; 1558 $member->user_id = $group->creator_id; 1559 $member->is_admin = 1; 1560 $member->user_title = __( 'Group Admin', 'buddypress' ); 1561 $member->is_confirmed = 1; 1554 1562 $member->date_modified = bp_core_current_time(); 1555 1563 … … 1572 1580 return false; 1573 1581 1574 $group = new BP_Groups_Group( $group_id );1575 $group->name = $group_name;1582 $group = new BP_Groups_Group( $group_id ); 1583 $group->name = $group_name; 1576 1584 $group->description = $group_desc; 1577 1585 … … 1602 1610 groups_accept_all_pending_membership_requests( $group->id ); 1603 1611 1604 / * Now update the status */1612 // Now update the status 1605 1613 $group->status = $status; 1606 1614 … … 1608 1616 return false; 1609 1617 1610 / * If forums have been enabled, and a forum does not yet exist, we need to create one. */1618 // If forums have been enabled, and a forum does not yet exist, we need to create one. 1611 1619 if ( $group->enable_forum ) { 1612 1620 if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group->id, 'forum_id' ) ) { … … 1675 1683 $slug = substr( $slug, 2, strlen( $slug ) - 2 ); 1676 1684 1677 if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) {1685 if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) 1678 1686 $slug = $slug . '-' . rand(); 1679 }1680 1687 1681 1688 if ( BP_Groups_Group::check_slug( $slug ) ) { … … 1696 1703 /*** User Actions ***************************************************************/ 1697 1704 1698 function groups_leave_group( $group_id, $user_id = false) {1705 function groups_leave_group( $group_id, $user_id = 0 ) { 1699 1706 global $bp; 1700 1707 … … 1702 1709 $user_id = $bp->loggedin_user->id; 1703 1710 1704 / * Don't let single admins leave the group. */1711 // Don't let single admins leave the group. 1705 1712 if ( count( groups_get_group_admins( $group_id ) ) < 2 ) { 1706 1713 if ( groups_is_user_admin( $user_id, $group_id ) ) { … … 1716 1723 return false; 1717 1724 1718 / * Modify group member count */1725 // Modify group member count 1719 1726 groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 ); 1720 1727 1721 / * Modify user's group memberhip count */1728 // Modify user's group memberhip count 1722 1729 update_user_meta( $user_id, 'total_group_count', (int) get_user_meta( $user_id, 'total_group_count', true ) - 1 ); 1723 1730 1724 /* If the user joined this group less than five minutes ago, remove the joined_group activity so 1725 * users cannot flood the activity stream by joining/leaving the group in quick succession. 1731 /** 1732 * If the user joined this group less than five minutes ago, remove the 1733 * joined_group activity so users cannot flood the activity stream by 1734 * joining/leaving the group in quick succession. 1726 1735 */ 1727 1736 if ( function_exists( 'bp_activity_delete' ) && gmmktime() <= strtotime( '+5 minutes', (int)strtotime( $membership->date_modified ) ) ) … … 1735 1744 } 1736 1745 1737 function groups_join_group( $group_id, $user_id = false) {1746 function groups_join_group( $group_id, $user_id = 0 ) { 1738 1747 global $bp; 1739 1748 … … 1753 1762 return true; 1754 1763 1755 $new_member = new BP_Groups_Member;1756 $new_member->group_id = $group_id;1757 $new_member->user_id = $user_id;1758 $new_member->inviter_id = 0;1759 $new_member->is_admin = 0;1760 $new_member->user_title = '';1764 $new_member = new BP_Groups_Member; 1765 $new_member->group_id = $group_id; 1766 $new_member->user_id = $user_id; 1767 $new_member->inviter_id = 0; 1768 $new_member->is_admin = 0; 1769 $new_member->user_title = ''; 1761 1770 $new_member->date_modified = bp_core_current_time(); 1762 $new_member->is_confirmed = 1;1771 $new_member->is_confirmed = 1; 1763 1772 1764 1773 if ( !$new_member->save() ) … … 1772 1781 // Record this in activity streams 1773 1782 groups_record_activity( array( 1774 'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( bp_get_group_name( $group ) ) . '</a>' ) ),1775 'type' => 'joined_group',1783 'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( bp_get_group_name( $group ) ) . '</a>' ) ), 1784 'type' => 'joined_group', 1776 1785 'item_id' => $group_id, 1777 1786 'user_id' => $user_id … … 1815 1824 1816 1825 $defaults = array( 1817 'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts1818 'user_id' => false,// Pass a user_id to limit to only groups that this user is a member of1819 'include' => false,// Only include these specific groups (group_ids)1820 'exclude' => false,// Do not include these specific groups (group_ids)1821 'search_terms' => false,// Limit to groups that match these search terms1822 'show_hidden' => false,// Show hidden groups to non-admins1823 1824 'per_page' => 20,// The number of results to return per page1825 'page' => 1,// The page to return if limiting per page1826 'populate_extras' => true, // Fetch meta such as is_banned and is_member1826 'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts 1827 'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of 1828 'include' => false, // Only include these specific groups (group_ids) 1829 'exclude' => false, // Do not include these specific groups (group_ids) 1830 'search_terms' => false, // Limit to groups that match these search terms 1831 'show_hidden' => false, // Show hidden groups to non-admins 1832 1833 'per_page' => 20, // The number of results to return per page 1834 'page' => 1, // The page to return if limiting per page 1835 'populate_extras' => true, // Fetch meta such as is_banned and is_member 1827 1836 ); 1828 1837 … … 1844 1853 } 1845 1854 1846 function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false) {1855 function groups_get_user_groups( $user_id = 0, $pag_num = 0, $pag_page = 0 ) { 1847 1856 global $bp; 1848 1857 … … 1853 1862 } 1854 1863 1855 function groups_total_groups_for_user( $user_id = false) {1864 function groups_total_groups_for_user( $user_id = 0 ) { 1856 1865 global $bp; 1857 1866 … … 1869 1878 /*** Group Avatars *************************************************************/ 1870 1879 1871 function groups_avatar_upload_dir( $group_id = false) {1880 function groups_avatar_upload_dir( $group_id = 0 ) { 1872 1881 global $bp; 1873 1882 … … 1875 1884 $group_id = $bp->groups->current_group->id; 1876 1885 1877 $path = BP_AVATAR_UPLOAD_PATH . '/group-avatars/' . $group_id;1886 $path = BP_AVATAR_UPLOAD_PATH . '/group-avatars/' . $group_id; 1878 1887 $newbdir = $path; 1879 1888 … … 1881 1890 @wp_mkdir_p( $path ); 1882 1891 1883 $newurl = BP_AVATAR_URL . '/group-avatars/' . $group_id;1884 $newburl = $newurl;1892 $newurl = BP_AVATAR_URL . '/group-avatars/' . $group_id; 1893 $newburl = $newurl; 1885 1894 $newsubdir = '/group-avatars/' . $group_id; 1886 1895 … … 1924 1933 1925 1934 $defaults = array( 1926 'content' => false,1927 'user_id' => $bp->loggedin_user->id,1935 'content' => false, 1936 'user_id' => $bp->loggedin_user->id, 1928 1937 'group_id' => $bp->groups->current_group->id 1929 1938 ); … … 1932 1941 extract( $r, EXTR_SKIP ); 1933 1942 1934 if ( empty( $content) || !strlen( trim( $content ) ) || empty($user_id) || empty($group_id) )1943 if ( empty( $content ) || !strlen( trim( $content ) ) || empty( $user_id ) || empty( $group_id ) ) 1935 1944 return false; 1936 1945 1937 1946 $bp->groups->current_group = new BP_Groups_Group( $group_id ); 1938 1947 1939 / * Be sure the user is a member of the group before posting. */1948 // Be sure the user is a member of the group before posting. 1940 1949 if ( !is_super_admin() && !groups_is_user_member( $user_id, $group_id ) ) 1941 1950 return false; 1942 1951 1943 / * Record this in activity streams */1944 $activity_action = sprintf( __( '%1$s posted an update in the group %2$s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );1952 // Record this in activity streams 1953 $activity_action = sprintf( __( '%1$s posted an update in the group %2$s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ); 1945 1954 $activity_content = $content; 1946 1955 1947 1956 $activity_id = groups_record_activity( array( 1948 1957 'user_id' => $user_id, 1949 'action' => apply_filters( 'groups_activity_new_update_action', $activity_action),1958 'action' => apply_filters( 'groups_activity_new_update_action', $activity_action ), 1950 1959 'content' => apply_filters( 'groups_activity_new_update_content', $activity_content ), 1951 'type' => 'activity_update',1960 'type' => 'activity_update', 1952 1961 'item_id' => $group_id 1953 1962 ) ); 1954 1963 1955 /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */ 1964 // Require the notifications code so email notifications can be set on 1965 // the 'bp_activity_posted_update' action. 1956 1966 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); 1957 1967 … … 1964 1974 /*** Group Forums **************************************************************/ 1965 1975 1966 function groups_new_group_forum( $group_id = false, $group_name = false, $group_desc = false) {1976 function groups_new_group_forum( $group_id = 0, $group_name = '', $group_desc = '' ) { 1967 1977 global $bp; 1968 1978 … … 2008 2018 2009 2019 $post_text = apply_filters( 'group_forum_post_text_before_save', $post_text ); 2010 $topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );2020 $topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id ); 2011 2021 2012 2022 if ( $post_id = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) { … … 2020 2030 $primary_link .= "?topic_page=" . $page; 2021 2031 2022 / * Record this in activity streams */2032 // Record this in activity streams 2023 2033 groups_record_activity( array( 2024 'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_id, $post_text, &$topic ),2025 'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_id, $post_text, &$topic ),2026 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),2027 'type' => 'new_forum_post',2028 'item_id' => $bp->groups->current_group->id,2034 'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_id, $post_text, &$topic ), 2035 'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_id, $post_text, &$topic ), 2036 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ), 2037 'type' => 'new_forum_post', 2038 'item_id' => $bp->groups->current_group->id,