Skip to:
Content

BuddyPress.org

Changeset 3728


Ignore:
Timestamp:
01/18/2011 12:53:31 PM (16 years ago)
Author:
johnjamesjacoby
Message:

Code normalization and whitespace clean-up. Introduce bp-core-deprecated.php. Introduce root_slug globals into components with directories, to help with WP page slugs. Fixes #2600. Optimus Props boonebgorges

Location:
trunk
Files:
1 added
1 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r3666 r3728  
    11<?php
     2
     3// Required Files
    24require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
    35require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
    … …  
    79        global $bp, $current_blog;
    810
     11        // Define a slug, if necessary
    912        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 ) );
    1114
    1215        // For internal identification
    13         $bp->activity->id = 'activity';
     16        $bp->activity->id   = 'activity';
    1417        $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
    1724        $bp->activity->table_name      = $bp->table_prefix . 'bp_activity';
    1825        $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
    1926
     27        // Notifications
    2028        $bp->activity->format_notification_function = 'bp_activity_format_notifications';
    2129
    … …  
    3846        $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain;
    3947        $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 . '/';
    4149
    4250        /* Add the subnav items to the activity nav item if we are using a theme that supports this */
    … …  
    4452
    4553        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' ) );
    4755
    4856        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' ) );
    5058
    5159        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' ) );
    … …  
    6068                }
    6169        }
    62 
     70       
    6371        do_action( 'bp_activity_setup_nav' );
    6472}
  • trunk/bp-activity/bp-activity-templatetags.php

    r3685 r3728  
    176176
    177177        // 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 ) )
    179179                $scope = $bp->active_components[$bp->current_action];
    180         } else {
     180        else
    181181                $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/
    185184        if ( $bp->current_action == $bp->activity->slug )
    186185                $include = $bp->action_variables[0];
    187186
    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.
    189188        $defaults = array(
    190                 'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
    191                 'include' => $include, // pass an activity_id or string of IDs comma-separated
    192                 'exclude' => $exclude, // pass an activity_id or string of IDs comma-separated
    193                 'in' => $in, // comma-separated list or array of activity IDs among which to search
    194                 'sort' => 'DESC', // sort DESC or ASC
    195                 'page' => 1, // which page to load
    196                 'per_page' => 20, // number of items per page
    197                 'max' => false, // max number to return
    198                 '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 on
    205                 'object' => $object, // object to filter on e.g. groups, profile, status, friends
    206                 'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated
    207                 '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_id
    209 
    210                 /* Searching */
    211                 'search_terms' => false // specify terms to search on
     189                '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
    212211        );
    213212
    … …  
    215214        extract( $r );
    216215
    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.
    218217        if ( 'just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope ) {
    219218                if ( 'just-me' == $scope )
    … …  
    272271        }
    273272
    274         /* Support for basic filters in earlier BP versions. */
    275         $filter = false;
     273        // Support for basic filters in earlier BP versions.
    276274        if ( isset( $_GET['afilter'] ) )
    277275                $filter = array( 'object' => $_GET['afilter'] );
    278276        else if ( !empty( $user_id ) || !empty( $object ) || !empty( $action ) || !empty( $primary_id ) || !empty( $secondary_id ) )
    279277                $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
     278        else
     279                $filter = false;
    280280
    281281        $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  
    11<?php
     2
     3// Required Files
    24require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' );
    35require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' );
    46
    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
    68if ( is_multisite() )
    79        require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
    … …  
    1113
    1214        if ( !defined( 'BP_BLOGS_SLUG' ) && isset( $bp->pages->blogs->slug ) )
    13                 define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );
    14         elseif( !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' ) )
    1517                define ( 'BP_BLOGS_SLUG', 'blogs' );
    1618
    1719        // 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
    2228        $bp->blogs->table_name          = $bp->table_prefix . 'bp_user_blogs';
    2329        $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta';
    2430
    25         $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
     31        // Notifications
     32        $bp->blogs->format_notification_function      = 'bp_blogs_format_notifications';
    2633
    2734        // 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;
    2936
    3037        // The default text for the blogs directory search box
    … …  
    3643
    3744/**
    38  * bp_blogs_setup_nav()
    39  *
    4045 * Adds "Blog" to the navigation arrays for the current and logged in user.
    4146 *
    … …  
    4752        global $bp;
    4853
    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         */
    5159        if ( !is_multisite() )
    5260                return false;
    5361
    54         /* Add 'Blogs' to the main navigation */
     62        // Add 'Blogs' to the main navigation
    5563        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 ) );
    5664
    5765        $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
    5866
    59         /* Set up the component options navigation for Blog */
     67        // Set up the component options navigation for Blog
    6068        if ( $bp->blogs->slug == $bp->current_component ) {
    6169                if ( bp_is_my_profile() ) {
    … …  
    6472                        }
    6573                } 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
    6776                        $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    6877                        $bp->bp_options_title = $bp->displayed_user->fullname;
    … …  
    8796
    8897
    89 /********************************************************************************
     98/*******************************************************************************
    9099 * Screen Functions
    91100 *
    … …  
    117126        bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
    118127}
    119 /* The create screen is not attached to a nav item, so we need to attach it to an action */
    120128add_action( 'wp', 'bp_blogs_screen_create_a_blog', 3 );
    121129
    122130
    123 /********************************************************************************
     131/*******************************************************************************
    124132 * Activity & Notification Functions
    125133 *
    … …  
    148156                return false;
    149157
    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         */
    152163        if ( !$bp->activity && function_exists('bp_activity_setup_globals') )
    153164                bp_activity_setup_globals();
    154165
    155166        $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,
    163174                'secondary_item_id' => false,
    164                 'recorded_time' => bp_core_current_time(),
    165                 'hide_sitewide' => false
     175                'recorded_time'     => bp_core_current_time(),
     176                'hide_sitewide'     => false
    166177        );
    167178
    … …  
    169180        extract( $r, EXTR_SKIP );
    170181
    171         /* Remove large images and replace them with just one image thumbnail */
     182        // Remove large images and replace them with just one image thumbnail
    172183        if ( function_exists( 'bp_activity_thumbnail_content_images' ) && !empty( $content ) )
    173184                $content = bp_activity_thumbnail_content_images( $content, $primary_link );
    … …  
    179190                $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content );
    180191
    181         /* Check for an existing entry and update if one exists. */
     192        // Check for an existing entry and update if one exists.
    182193        $id = bp_activity_get_activity_id( array(
    183194                'user_id' => $user_id,
    … …  
    194205        global $bp;
    195206
    196         if ( function_exists('bp_activity_delete_by_item_id') ) {
     207        if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
    197208                $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,
    202213                        'secondary_item_id' => false
    203214                );
    … …  
    229240
    230241        $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
    237247        );
    238248
    … …  
    246256        global $bp, $wpdb;
    247257
    248         /* Truncate user blogs table and re-record. */
     258        // Truncate user blogs table and re-record.
    249259        $wpdb->query( "TRUNCATE TABLE {$bp->blogs->table_name}" );
    250260
    … …  
    320330
    321331/**
    322  * bp_blogs_update_option_blogname()
    323  *
    324332 * Updates blogname in BuddyPress blogmeta table
    325333 *
    … …  
    330338function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
    331339        global $wpdb;
     340
    332341        bp_blogs_update_blogmeta( $wpdb->blogid, 'name', $newvalue );
    333342}
    … …  
    335344
    336345/**
    337  * bp_blogs_update_option_blogdescription()
    338  *
    339346 * Updates blogdescription in BuddyPress blogmeta table
    340347 *
    … …  
    345352function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) {
    346353        global $wpdb;
     354
    347355        bp_blogs_update_blogmeta( $wpdb->blogid, 'description', $newvalue );
    348356}
    … …  
    380388
    381389                        bp_blogs_record_activity( array(
    382                                 'user_id'            => (int)$post->post_author,
     390                                'user_id'           => (int)$post->post_author,
    383391                                'action'            => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
    384392                                'content'           => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
    … …  
    402410
    403411/**
    404  * bp_blogs_record_comment()
    405  *
    406412 * Record blog comment activity. Checks if blog is public and post is not
    407413 * password protected.
    … …  
    428434
    429435        // 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 );
    431437        $user_id = (int)$user->ID;
    432438
    … …  
    436442
    437443        // Get blog and post data
    438         $blog_id = (int)$wpdb->blogid;
     444        $blog_id                = (int)$wpdb->blogid;
    439445        $recorded_comment->post = get_post( $recorded_comment->comment_post_ID );
    440446
    … …  
    451457
    452458                // 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>' );
    458463
    459464                $activity_content       = $recorded_comment->comment_content;
    … …  
    478483}
    479484add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
    480 add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );
     485add_action( 'edit_comment', 'bp_blogs_record_comment', 10    );
    481486
    482487function bp_blogs_manage_comment( $comment_id, $comment_status ) {
    … …  
    509514}
    510515add_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' );
     516add_action( 'profile_update',   'bp_blogs_add_user_to_blog'        );
     517add_action( 'user_register',    'bp_blogs_add_user_to_blog'        );
    513518
    514519function bp_blogs_remove_user_from_blog( $user_id, $blog_id = false ) {
    … …  
    605610        global $bp;
    606611
    607         /* If this is regular blog, delete all data for that blog. */
     612        // If this is regular blog, delete all data for that blog.
    608613        BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    609614
    … …  
    643648
    644649
    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 */
    651658
    652659function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
    … …  
    663670        $meta_value = trim( $meta_value );
    664671
    665         if ( !$meta_key ) {
     672        if ( !$meta_key )
    666673                $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 )
    668675                $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
    670677                $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
    671         }
    672678
    673679        wp_cache_delete( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, 'bp' );
    … …  
    723729        $meta_value = maybe_serialize($meta_value);
    724730
    725         if (empty($meta_value)) {
     731        if (empty( $meta_value ) )
    726732                return bp_blogs_delete_blogmeta( $blog_id, $meta_key );
    727         }
    728733
    729734        $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 ) );
    730735
    731         if ( !$cur ) {
     736        if ( !$cur )
    732737                $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 )
    734739                $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;
    738742
    739743        wp_cache_set( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, $meta_value, 'bp' );
    … …  
    746750                return false;
    747751
    748         /* If this is regular blog, delete all data for that blog. */
     752        // If this is regular blog, delete all data for that blog.
    749753        BP_Blogs_Blog::delete_blogs_for_user( $user_id );
    750754
    751755        do_action( 'bp_blogs_remove_data', $user_id );
    752756}
    753 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' );
    754 add_action( 'delete_user', 'bp_blogs_remove_data' );
     757add_action( 'wpmu_delete_user',  'bp_blogs_remove_data' );
     758add_action( 'delete_user',       'bp_blogs_remove_data' );
    755759add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' );
    756760
    757761
    758 /********************************************************************************
     762/*******************************************************************************
    759763 * Caching
    760764 *
    … …  
    775779// List actions to clear object caches on
    776780add_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 );
     781add_action( 'bp_blogs_new_blog',             'bp_blogs_format_clear_blog_cache', 10, 2 );
    778782
    779783// List actions to clear super cached pages on, if super cache is installed
    780784add_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' );
     785add_action( 'bp_blogs_remove_comment',       'bp_core_clear_cache' );
     786add_action( 'bp_blogs_remove_post',          'bp_core_clear_cache' );
    783787add_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' );
     788add_action( 'bp_blogs_remove_blog',          'bp_core_clear_cache' );
     789add_action( 'bp_blogs_new_blog_comment',     'bp_core_clear_cache' );
     790add_action( 'bp_blogs_new_blog_post',        'bp_core_clear_cache' );
     791add_action( 'bp_blogs_new_blog',             'bp_core_clear_cache' );
     792add_action( 'bp_blogs_remove_data',          'bp_core_clear_cache' );
    789793
    790794?>
  • trunk/bp-core.php

    r3720 r3728  
    99define( 'BP_PLUGIN_URL', plugins_url( $path = '/buddypress' ) );
    1010
    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.
    1212require ( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
    1313
    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.
    1515if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
    1616        require( WP_PLUGIN_DIR . '/bp-custom.php' );
    1717
    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.
    1919if ( !defined( 'CUSTOM_USER_TABLE' ) )
    2020        define( 'CUSTOM_USER_TABLE', $wpdb->base_prefix . 'users' );
    … …  
    2525// The search slug has to be defined nice and early because of the way search requests are loaded
    2626if ( !defined( 'BP_SEARCH_SLUG' ) )
    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' );
     27        define( 'BP_SEARCH_SLUG', 'search' );
     28
     29// Load the files containing functions that we globally will need.
     30require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php'      );
     31require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php'       );
     32require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php'       );
     33require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php'         );
     34require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php'       );
     35require ( BP_PLUGIN_DIR . '/bp-core/bp-core-templatetags.php'  );
     36require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php'      );
     37require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php'       );
    3838require ( 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. */
     39require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php'        );
     40require ( 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.
    4243if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
    4344        require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
    4445
    45 /* Register BuddyPress themes contained within the bp-theme folder */
     46// Register BuddyPress themes contained within the bp-theme folder
    4647register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
    4748
    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/**
    5552 * Sets up default global BuddyPress configuration settings and stores
    5653 * them in a $bp variable.
    … …  
    7673
    7774        // 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();
    7976
    8077        // 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 *****************************************************/
    8281
    8382        // Set up the members id and active components entry
    84         $bp->members->id = 'members';
    85 
     83        $bp->members->id  = 'members';
     84
     85        // Members Slugs
    8686        $bp->members->slug = $bp->pages->members->slug;
    8787        $bp->active_components[$bp->members->slug] = $bp->members->id;
    … …  
    8989        // The user ID of the user who is currently logged in.
    9090        $bp->loggedin_user->id = $current_user->ID;
     91
     92        /** Logged in user ********************************************************/
    9193
    9294        // The domain for the user currently logged in. eg: http://domain.com/members/andy
    … …  
    100102        $bp->loggedin_user->is_site_admin  = $bp->loggedin_user->is_super_admin; // deprecated 1.2.6
    101103
     104        /** Displayed user ********************************************************/
     105
    102106        // The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php
    103107        $bp->displayed_user->id = $displayed_user_id;
    … …  
    109113        $bp->displayed_user->userdata = bp_core_get_core_userdata( $bp->displayed_user->id );
    110114
     115        /** Component and Action **************************************************/
     116
    111117        // The component being used eg: http://domain.com/members/andy/ [profile]
    112118        $bp->current_component = $current_component; // type: string
    … …  
    121127        $bp->current_item = ''; // type: string
    122128
    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)
    124131        $bp->is_single_item = false;
    125132
    … …  
    134141        }
    135142
    136         // Fetches all of the core database based BuddyPress settings in one foul swoop
     143        // Fetches all of the core BuddyPress settings in one fell swoop
    137144        $bp->site_options = bp_core_get_site_options();
    138145
    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()
    140148        $bp->bp_nav = array();
    141149
    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()
    143152        $bp->bp_options_nav = array();
    144153
    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.
    146156        $bp->active_components = array();
     157
     158        /** Avatars ***************************************************************/
    147159
    148160        // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
    … …  
    155167        $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
    156168
    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         */
    161175        $bp->is_item_admin = bp_user_has_access();
    162176
    … …  
    164178        $bp->is_item_mod = false;
    165179
     180        // Notifications Table
    166181        $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
    167182
     183        // Default Component
    168184        if ( !$bp->current_component && $bp->displayed_user->id )
    169185                $bp->current_component = $bp->default_component;
    170186
    171187        // The default text for the members directory search box
    172         $bp->default_search_strings[$bp->members->slug] = __( 'Search Members...', 'buddypress' );
     188        $bp->default_search_strings[$bp->members->slug] = __( 'Search Members...', 'buddypress' );
    173189
    174190        do_action( 'bp_core_setup_globals' );
    … …  
    177193
    178194/**
    179  * bp_core_get_table_prefix()
    180  *
    181195 * Allow filtering of database prefix. Intended for use in multinetwork installations.
    182196 *
    … …  
    191205
    192206/**
    193  * bp_core_define_slugs()
    194  *
    195207 * Define the slugs used for BuddyPress pages, based on the slugs of the WP pages used.
    196208 * These can be overridden manually by defining these slugs in wp-config.php.
    … …  
    215227
    216228/**
    217  * bp_core_get_page_meta()
    218  *
    219229 * Fetches BP pages from the meta table, depending on setup
    220230 *
    … …  
    231241
    232242/**
    233  * bp_core_update_page_meta()
    234  *
    235243 * Stores BP pages in the meta table, depending on setup
    236244 *
    … …  
    285293}
    286294
    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 */
     318function 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/**
    290326 * Initializes the wp-admin area "BuddyPress" menus and sub menus.
    291327 *
    … …  
    302338
    303339/**
    304  * bp_core_add_admin_menu()
    305  *
    306340 * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
    307341 *
    … …  
    334368
    335369/**
    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-group
    340  *
    341  * @package BuddyPress Core
    342  * @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  *
    358370 * Sets up the profile navigation item if the Xprofile component is not installed.
    359371 *
    … …  
    419431
    420432/**
    421  * bp_core_action_directory_members()
    422  *
    423433 * Listens to the $bp component and action variables to determine if the user is viewing the members
    424434 * directory page. If they are, it will set up the directory and load the members directory template.
    … …  
    442452
    443453/**
    444  * bp_core_action_set_spammer_status()
    445  *
    446454 * When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
    447455 * this action will fire and mark or unmark the user and their blogs as spam.
    … …  
    458466
    459467        if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
    460                 /* Check the nonce */
     468                // Check the nonce
    461469                check_admin_referer( 'mark-unmark-spammer' );
    462470
    463                 /* Get the functions file */
     471                // Get the functions file
    464472                if ( is_multisite() )
    465473                        require_once( ABSPATH . 'wp-admin/includes/ms.php' );
    … …  
    470478                        $is_spam = 0;
    471479
    472                 /* Get the blogs for the user */
     480                // Get the blogs for the user
    473481                $blogs = get_blogs_of_user( $bp->displayed_user->id, true );
    474482
    475483                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
    477485                        if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id )
    478486                                continue;
    479487
    480                         /* Update the blog status */
     488                        // Update the blog status
    481489                        update_blog_status( $details->userblog_id, 'spam', $is_spam );
    482490
    483                         /* Fire the standard WPMU hook */
     491                        // Fire the standard multisite hook
    484492                        do_action( 'make_spam_blog', $details->userblog_id );
    485493                }
    486494
    487                 /* Finally, mark this user as a spammer */
     495                // Finally, mark this user as a spammer
    488496                if ( is_multisite() )
    489497                        $wpdb->update( $wpdb->users, array( 'spam' => $is_spam ), array( 'ID' => $bp->displayed_user->id ) );
    … …  
    496504                        bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
    497505
    498                 /* Hide this user's activity */
     506                // Hide this user's activity
    499507                if ( $is_spam && function_exists( 'bp_activity_hide_user_activity' ) )
    500508                        bp_activity_hide_user_activity( $bp->displayed_user->id );
    501509
    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
    503512                if ( $is_spam )
    504                         do_action( 'bp_make_spam_user', $bp->displayed_user->id );
     513                        do_action( 'bp_make_spam_user', $bp->displayed_user->id );
    505514
    506515                do_action( 'bp_core_action_set_spammer_status', $bp->displayed_user->id, $is_spam );
    … …  
    512521
    513522/**
    514  * bp_core_action_delete_user()
    515  *
    516523 * Allows a site admin to delete a user from the adminbar menu.
    517524 *
    … …  
    526533
    527534        if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
    528                 /* Check the nonce */
     535                // Check the nonce
    529536                check_admin_referer( 'delete-user' );
    530537
    … …  
    559566
    560567/**
    561  * bp_core_get_users()
    562  *
    563568 * Return an array of users IDs based on the parameters passed.
    564569 *
    … …  
    587592
    588593/**
    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/
    593595 *
    594596 * @package BuddyPress Core
    … …  
    605607                $username = bp_core_get_username( $user_id, $user_nicename, $user_login );
    606608
    607                 /* If we are using a members slug, include it. */
     609                // If we are using a members slug, include it.
    608610                if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
    609611                        $domain = $bp->root_domain . '/' . $bp->members->slug . '/' . $username . '/';
    … …  
    611613                        $domain = $bp->root_domain . '/' . $username . '/';
    612614
    613                 /* Cache the link */
     615                // Cache the link
    614616                if ( !empty( $domain ) )
    615617                        wp_cache_set( 'bp_user_domain_' . $user_id, $domain, 'bp' );
    … …  
    620622
    621623/**
    622  * bp_core_get_core_userdata()
    623  *
    624624 * Fetch everything in the wp_users table for a user, without any usermeta.
    625625 *
    … …  
    640640
    641641/**
    642  * bp_core_get_root_domain()
    643  *
    644642 * Returns the domain for the root blog.
    645643 * eg: http://domain.com/ OR https://domain.com
    … …  
    661659
    662660/**
    663  * bp_core_get_displayed_userid()
    664  *
    665661 * Returns the user id for the user that is currently being displayed.
    666662 * eg: http://andy.domain.com/ or http://domain.com/andy/
    … …  
    675671
    676672/**
    677  * bp_core_new_nav_item()
    678  *
    679673 * Adds a navigation item to the main navigation array used in BuddyPress themes.
    680674 *
    … …  
    686680
    687681        $defaults = array(
    688                 'name' => false, // Display name for the nav item
    689                 'slug' => false, // URL slug for the nav item
    690                 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
    691                 '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 positioned
    694                 'screen_function' => false, // The name of the function to run when clicked
    695                 'default_subnav_slug' => false // The slug of the default subnav item to select when clicked
     682                '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
    696690        );
    697691
    … …  
    699693        extract( $r, EXTR_SKIP );
    700694
    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
    702696        if ( empty($name) || empty($slug) )
    703697                return false;
    704698
    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
    706700        if ( $site_admin_only && !is_super_admin() )
    707701                return false;
    … …  
    711705
    712706        $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,
    717711                'show_for_displayed_user' => $show_for_displayed_user,
    718                 'position' => $position,
    719                 'screen_function' => &$screen_function
     712                'position'                => $position,
     713                'screen_function'         => &$screen_function
    720714        );
    721715
    … …  
    732726         * default subnav function so we can display a directory or something else.
    733727         */
    734         if ( bp_core_is_root_component( $slug ) && !$bp->displayed_user->id )
     728        if ( bp_is_root_component( $slug ) && !$bp->displayed_user->id )
    735729                return;
    736730
    … …  
    747741
    748742/**
    749  * bp_core_new_nav_default()
    750  *
    751743 * Modify the default subnav item to load when a top level nav item is clicked.
    752744 *
    … …  
    758750
    759751        $defaults = array(
    760                 'parent_slug' => false, // Slug of the parent
     752                'parent_slug'     => false, // Slug of the parent
    761753                '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 clicked
     754                'subnav_slug'     => false // The slug of the subnav item to select when clicked
    763755        );
    764756
    … …  
    787779
    788780/**
    789  * bp_core_sort_nav_items()
    790  *
    791781 * We can only sort nav items by their position integer at a later point in time, once all
    792782 * plugins have registered their navigation items.
    … …  
    817807        $bp->bp_nav = &$temp;
    818808}
    819 add_action( 'wp_head', 'bp_core_sort_nav_items' );
     809add_action( 'wp_head',    'bp_core_sort_nav_items' );
    820810add_action( 'admin_head', 'bp_core_sort_nav_items' );
    821811
    822812/**
    823  * bp_core_new_subnav_item()
    824  *
    825813 * Adds a navigation item to the sub navigation array used in BuddyPress themes.
    826814 *
    … …  
    832820
    833821        $defaults = array(
    834                 'name' => false, // Display name for the nav item
    835                 'slug' => false, // URL slug for the nav item
    836                 'parent_slug' => false, // URL slug of the parent nav item
    837                 'parent_url' => false, // URL of the parent item
    838                 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item
    839                 '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?
    840828                'site_admin_only' => false, // Can only site admins see this nav item?
    841                 'position' => 90, // Index of where this nav item should be positioned
    842                 'screen_function' => false // The name of the function to run when clicked
     829                'position'        => 90,    // Index of where this nav item should be positioned
     830                'screen_function' => false  // The name of the function to run when clicked
    843831        );
    844832
    … …  
    846834        extract( $r, EXTR_SKIP );
    847835
    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
    853841        if ( $site_admin_only && !is_super_admin() )
    854842                return false;
    … …  
    858846
    859847        $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,
    865853                'user_has_access' => $user_has_access,
    866854                'screen_function' => &$screen_function
    867855        );
    868 
     856       
    869857        if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
    870858                if ( !is_object( $screen_function[0] ) )
    … …  
    899887                ksort( $temp );
    900888                $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}
     892add_action( 'wp_head',    'bp_core_sort_subnav_items' );
    905893add_action( 'admin_head', 'bp_core_sort_subnav_items' );
    906894
    907895/**
    908  * bp_core_remove_nav_item()
    909  *
    910896 * Removes a navigation item from the sub navigation array used in BuddyPress themes.
    911897 *
    … …  
    917903        global $bp;
    918904
    919         /* Unset subnav items for this nav item */
     905        // Unset subnav items for this nav item
    920906        if ( is_array( $bp->bp_options_nav[$parent_id] ) ) {
    921907                foreach( (array)$bp->bp_options_nav[$parent_id] as $subnav_item ) {
    … …  
    935921
    936922/**
    937  * bp_core_remove_subnav_item()
    938  *
    939923 * Removes a navigation item from the sub navigation array used in BuddyPress themes.
    940924 *
    … …  
    962946
    963947/**
    964  * bp_core_reset_subnav_items()
    965  *
    966948 * Clear the subnav items for a specific nav item.
    967949 *
    … …  
    970952 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    971953 */
    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  *
     954function bp_core_reset_subnav_items( $parent_slug ) {
     955        global $bp;
     956
     957        unset( $bp->bp_options_nav[$parent_slug] );
     958}
     959
     960/**
    981961 * Returns the user_id for a user based on their username.
    982962 *
    … …  
    997977
    998978/**
    999  * bp_core_get_userid()
    1000  *
    1001979 * Returns the user_id for a user based on their username.
    1002980 *
    … …  
    1017995
    1018996/**
    1019  * bp_core_get_userid_from_nicename()
    1020  *
    1021997 * Returns the user_id for a user based on their user_nicename.
    1022998 *
    … …  
    10371013
    10381014/**
    1039  * bp_core_get_username()
    1040  *
    10411015 * Returns the username for a user based on their user id.
    10421016 *
    … …  
    10761050        }
    10771051
    1078         /* Add this to cache */
     1052        // Add this to cache
    10791053        if ( !empty( $username ) )
    10801054                wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' );
    … …  
    10841058
    10851059/**
    1086  * bp_core_get_user_email()
    1087  *
    10881060 * Returns the email address for the user based on user ID
    10891061 *
    … …  
    11051077
    11061078/**
    1107  * bp_core_get_userlink()
    1108  *
    11091079 * Returns a HTML formatted link for a user with the user's full name as the link text.
    11101080 * eg: <a href="http://andy.domain.com/">Andy Peatling</a>
    … …  
    11461116
    11471117/**
    1148  * bp_core_get_user_displayname()
    1149  *
    11501118 * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed.
    11511119 * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set.
    … …  
    12031171}
    12041172add_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  *
     1173add_filter( 'bp_core_get_user_displayname', 'trim'          );
     1174add_filter( 'bp_core_get_user_displayname', 'stripslashes'  );
     1175
     1176
     1177/**
    12121178 * Returns the user link for the user based on user email address
    12131179 *
    … …  
    12241190
    12251191/**
    1226  * bp_core_get_userlink_by_username()
    1227  *
    12281192 * Returns the user link for the user based on user's username
    12291193 *
    … …  
    12411205
    12421206/**
    1243  * bp_core_get_total_member_count()
    1244  *
    12451207 * Returns the total number of members for the installation.
    12461208 *
    … …  
    12611223
    12621224/**
    1263  * bp_core_is_user_spammer()
    1264  *
    12651225 * Checks if the user has been marked as a spammer.
    12661226 *
    … …  
    12811241
    12821242/**
    1283  * bp_core_is_user_deleted()
    1284  *
    12851243 * Checks if the user has been marked as deleted.
    12861244 *
    … …  
    12961254
    12971255/**
    1298  * bp_core_current_time()
    1299  *
    13001256 * Get the current GMT time to save into the DB
    13011257 *
    … …  
    13111267
    13121268/**
    1313  * bp_core_add_message()
    1314  *
    13151269 * Adds a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
    13161270 *
    … …  
    13231277                $type = 'success';
    13241278
    1325         /* Send the values to the cookie for page reload display */
     1279        // Send the values to the cookie for page reload display
    13261280        @setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH );
    13271281        @setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH );
    … …  
    13311285         * without a page reload
    13321286         */
    1333         $bp->template_message = $message;
     1287        $bp->template_message      = $message;
    13341288        $bp->template_message_type = $type;
    13351289}
    13361290
    13371291/**
    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.
    13451298 *
    13461299 * @package BuddyPress Core
    … …  
    13661319
    13671320/**
    1368  * bp_core_render_message()
    1369  *
    13701321 * Renders a feedback message (either error or success message) to the theme template.
    13711322 * The hook action 'template_notices' is used to call this function, it is not called directly.
    … …  
    13781329
    13791330        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
    13821333                <div id="message" class="<?php echo $type; ?>">
    13831334                        <p><?php echo stripslashes( esc_attr( $bp->template_message ) ); ?></p>
    13841335                </div>
     1336
    13851337        <?php
     1338
    13861339                do_action( 'bp_core_render_message' );
    13871340        }
    … …  
    13891342
    13901343/**
    1391  * bp_core_time_since()
    1392  *
    13931344 * Based on function created by Dunstan Orchard - http://1976design.com
    13941345 *
    … …  
    14241375        }
    14251376
    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         */
    14281382        $newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time() ) : $newer_date;
    14291383
    1430         /* Difference in seconds */
     1384        // Difference in seconds
    14311385        $since = $newer_date - $older_date;
    14321386
    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.
    14341388        if ( 0 > $since )
    14351389                return __( 'sometime', 'buddypress' );
    … …  
    14421396         */
    14431397
    1444         /* Step one: the first chunk */
     1398        // Step one: the first chunk
    14451399        for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
    14461400                $seconds = $chunks[$i][0];
    14471401
    1448                 /* Finding the biggest chunk (if the chunk fits, break) */
     1402                // Finding the biggest chunk (if the chunk fits, break)
    14491403                if ( ( $count = floor($since / $seconds) ) != 0 )
    14501404                        break;
    14511405        }
    14521406
    1453         // If $i iterates all the way to $j, then the event happened 0 seconds ago
    1454         if ( !isset( $chunks[$i] ) )
     1407        // If $i iterates all the way to $j, then the event happened 0 seconds ago
     1408        if ( !isset( $chunks[$i] ) )
    14551409                return '0 ' . __( 'seconds', 'buddypress' );
    14561410
    1457         /* Set output var */
     1411        // Set output var
    14581412        $output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
    14591413
    1460         /* Step two: the second chunk */
     1414        // Step two: the second chunk
    14611415        if ( $i + 2 < $j ) {
    14621416                $seconds2 = $chunks[$i + 1][0];
    … …  
    14691423        }
    14701424
    1471         if ( !(int)trim($output) )
     1425        if ( !(int)trim( $output ) )
    14721426                $output = '0 ' . __( 'seconds', 'buddypress' );
    14731427
    … …  
    14771431
    14781432/**
    1479  * bp_core_record_activity()
    1480  *
    14811433 * Record user activity to the database. Many functions use a "last active" feature to
    14821434 * show the length of time since the user was last active.
    … …  
    15011453        $current_time = bp_core_current_time();
    15021454
    1503         if ( '' == $activity || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )
     1455        if ( empty( $activity ) || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )
    15041456                update_user_meta( $bp->loggedin_user->id, 'last_activity', $current_time );
    15051457}
    … …  
    15081460
    15091461/**
    1510  * bp_core_get_last_activity()
    1511  *
    15121462 * Formats last activity based on time since date given.
    15131463 *
    … …  
    15191469 */
    15201470function 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 ) )
    15221472                $last_active = __( 'not recently active', 'buddypress' );
    1523         } else {
     1473        else
    15241474                $last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
    1525         }
    15261475
    15271476        return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
    … …  
    15291478
    15301479function bp_core_number_format( $number, $decimals = false ) {
    1531         /* Check we actually have a number first. */
     1480        // Check we actually have a number first.
    15321481        if ( empty( $number ) )
    15331482                return $number;
    … …  
    15371486
    15381487/**
    1539  * bp_core_get_all_posts_for_user()
    1540  *
    15411488 * Fetch every post that is authored by the given user for the current blog.
    15421489 *
    … …  
    15461493 * @return array of post ids.
    15471494 */
    1548 function bp_core_get_all_posts_for_user( $user_id = null ) {
     1495function bp_core_get_all_posts_for_user( $user_id = 0 ) {
    15491496        global $bp, $wpdb;
    15501497
    1551         if ( !$user_id )
     1498        if ( empty( $user_id ) )
    15521499                $user_id = $bp->displayed_user->id;
    15531500
    … …  
    15561503
    15571504/**
    1558  * bp_core_get_site_path()
    1559  *
    15601505 * Get the path of of the current site.
    15611506 *
    … …  
    15771522                        $site_path = '/';
    15781523                else {
    1579                         /* Unset the first three segments (http(s)://domain.com part) */
     1524                        // Unset the first three segments (http(s)://domain.com part)
    15801525                        unset( $site_path[0] );
    15811526                        unset( $site_path[1] );
    … …  
    15931538
    15941539/**
    1595  * bp_core_redirect()
    1596  *
    15971540 * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
    15981541 *
    … …  
    16141557
    16151558/**
    1616  * bp_core_referrer()
    1617  *
    16181559 * Returns the referrer URL without the http(s)://
    16191560 *
    … …  
    16281569
    16291570/**
    1630  * bp_core_add_illegal_names()
    1631  *
    16321571 * Adds illegal names to WP so that root components will not conflict with
    16331572 * blog names on a subdirectory installation.
    … …  
    16401579
    16411580/**
    1642  * bp_core_delete_account()
    1643  *
    16441581 * Allows a user to completely remove their account from the system
    16451582 *
    … …  
    16571594                $user_id = $bp->loggedin_user->id;
    16581595
    1659         /* Make sure account deletion is not disabled */
     1596        // Make sure account deletion is not disabled
    16601597        if ( !empty( $bp->site_options['bp-disable-account-deletion'] ) && !$bp->loggedin_user->is_super_admin )
    16611598                return false;
    16621599
    1663         /* Site admins cannot be deleted */
     1600        // Site admins cannot be deleted
    16641601        if ( is_super_admin( bp_core_get_username( $user_id ) ) )
    16651602                return false;
    16661603
    1667         /* Specifically handle multi-site environment */
     1604        // Specifically handle multi-site environment
    16681605        if ( is_multisite() ) {
    16691606                if ( $wp_version >= '3.0' )
    … …  
    16761613                return wpmu_delete_user( $user_id );
    16771614
    1678         /* Single site user deletion */
     1615        // Single site user deletion
    16791616        } else {
    16801617                require_once( ABSPATH . '/wp-admin/includes/user.php' );
    … …  
    16841621
    16851622/**
    1686  * bp_core_search_site()
    1687  *
    16881623 * A javascript free implementation of the search functions in BuddyPress
    16891624 *
    … …  
    17121647                                $slug = bp_is_active( 'blogs' )  ? $bp->blogs->slug  : '';
    17131648                                break;
     1649
    17141650                        case 'forums':
    17151651                                $slug = bp_is_active( 'forums' ) ? $bp->forums->slug : '';
    17161652                                $query_string = '/?fs=';
    17171653                                break;
     1654
    17181655                        case 'groups':
    17191656                                $slug = bp_is_active( 'groups' ) ? $bp->groups->slug : '';
    17201657                                break;
     1658
    17211659                        case 'members':
    17221660                        default:
    … …  
    17351673add_action( 'init', 'bp_core_action_search_site', 5 );
    17361674
    1737 
    1738 /**
    1739  * bp_core_ucfirst()
    1740  *
     1675/**
    17411676 * Localization safe ucfirst() support.
    17421677 *
    … …  
    17521687}
    17531688
    1754 
    1755 /**
    1756  * bp_core_strip_username_spaces()
    1757  *
     1689/**
    17581690 * Strips spaces from usernames that are created using add_user() and wp_insert_user()
    17591691 *
    … …  
    17611693 */
    17621694function bp_core_strip_username_spaces( $username ) {
    1763         // Don't alter the user_login of existing users, as it causes user_nicename problems.
    1764         // See http://trac.buddypress.org/ticket/2642
    1765         if ( username_exists( $username ) && ( !defined( 'BP_ENABLE_USER_COMPATIBILITY_MODE' ) || !BP_ENABLE_USER_COMPATIBILITY_MODE ) )
    1766                 return $username;
     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;
    17671699
    17681700        return str_replace( ' ', '-', $username );
    … …  
    17701702add_action( 'pre_user_login', 'bp_core_strip_username_spaces' );
    17711703
    1772 
    1773 /**
    1774  * bp_core_clear_cache()
     1704/**
    17751705 * REQUIRES WP-SUPER-CACHE
    17761706 *
    … …  
    17911721
    17921722/**
    1793  * bp_core_print_generation_time()
    1794  *
    17951723 * Prints the generation time in the footer of the site.
    17961724 *
    … …  
    18071735
    18081736/**
    1809  * bp_core_add_admin_menu_page()
    1810  *
    18111737 * A better version of add_admin_menu_page() that allows positioning of menus.
    18121738 *
    … …  
    18541780
    18551781/**
    1856  * bp_core_boot_spammer()
    1857  *
    18581782 * When a user logs in, check if they have been marked as a spammer. If yes then simply
    18591783 * redirect them to the home page and stop them from logging in.
    … …  
    18701794
    18711795        if ( !$user = get_userdatabylogin( $username ) )
    1872                 return false;
     1796                return false;
    18731797
    18741798        if ( ( is_multisite() && (int)$user->spam ) || 1 == (int)$user->user_status )
    … …  
    18801804
    18811805/**
    1882  * bp_core_remove_data()
    1883  *
    18841806 * Deletes usermeta for the user when the user is deleted.
    18851807 *
    … …  
    18891811 */
    18901812function bp_core_remove_data( $user_id ) {
    1891         /* Remove usermeta */
     1813        // Remove usermeta
    18921814        delete_user_meta( $user_id, 'last_activity' );
    18931815
    1894         /* Flush the cache to remove the user from all cached objects */
     1816        // Flush the cache to remove the user from all cached objects
    18951817        wp_cache_flush();
    18961818}
    1897 add_action( 'wpmu_delete_user', 'bp_core_remove_data' );
    1898 add_action( 'delete_user', 'bp_core_remove_data' );
     1819add_action( 'wpmu_delete_user',  'bp_core_remove_data' );
     1820add_action( 'delete_user',       'bp_core_remove_data' );
    18991821add_action( 'bp_make_spam_user', 'bp_core_remove_data' );
    19001822
    19011823/**
    1902  * bp_load_buddypress_textdomain()
    1903  *
    19041824 * Load the buddypress translation file for current language
    19051825 *
    … …  
    19221842
    19231843function 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
    19251845        if ( !defined( 'WP_ADMIN' ) && isset( $_REQUEST['action'] ) )
    19261846                do_action( 'wp_ajax_' . $_REQUEST['action'] );
    … …  
    19291849
    19301850/**
    1931  * bp_core_update_message()
    1932  *
    19331851 * Add an extra update message to the update plugin notification.
    19341852 *
    … …  
    19411859
    19421860/**
    1943  * bp_core_activation_notice()
    1944  *
    19451861 * When BuddyPress is activated we must make sure that mod_rewrite is enabled.
    19461862 * We must also make sure a BuddyPress compatible theme is enabled. This function
    … …  
    19641880
    19651881        if ( empty( $wp_rewrite->permalink_structure ) ) { ?>
     1882
    19661883                <div id="message" class="updated fade">
    19671884                        <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>
    19681885                </div><?php
     1886
    19691887        } else {
    1970                 /* Get current theme info */
     1888                // Get current theme info
    19711889                $ct = current_theme_info();
    19721890
    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.
    19741893                if ( !defined( 'BP_SILENCE_THEME_NOTICE' ) && !in_array( 'buddypress', (array)$ct->tags ) ) { ?>
     1894
    19751895                        <div id="message" class="updated fade">
    19761896                                <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
    19781900                }
    19791901        }
    … …  
    19821904
    19831905/**
    1984  * bp_core_activate_site_options()
    1985  *
    19861906 * When switching from single to multisite we need to copy blog options to
    19871907 * site options.
    … …  
    20191939
    20201940/**
    2021  * bp_include()
    2022  *
    20231941 * Allow plugins to include their files ahead of core filters
    20241942 */
    … …  
    20291947
    20301948/**
    2031  * bp_setup_root_components()
    2032  *
    20331949 * Allow core components and dependent plugins to set root components
    20341950 */
    … …  
    20391955
    20401956/**
    2041  * bp_setup_globals()
    2042  *
    20431957 * Allow core components and dependent plugins to set globals
    20441958 */
    … …  
    20491963
    20501964/**
    2051  * bp_setup_nav()
    2052  *
    20531965 * Allow core components and dependent plugins to set their nav
    20541966 */
    … …  
    20591971
    20601972/**
    2061  * bp_setup_widgets()
    2062  *
    20631973 * Allow core components and dependent plugins to register widgets
    20641974 */
    … …  
    20691979
    20701980/**
    2071  * bp_init()
    2072  *
    20731981 * Allow components to initialize themselves cleanly
    20741982 */
    … …  
    20871995
    20881996/**
    2089  * bp_core_add_global_group()
    2090  *
    20911997 * Add's 'bp' to global group of network wide cachable objects
    20921998 *
    … …  
    21022008
    21032009/**
    2104  * bp_core_clear_user_object_cache()
    2105  *
    21062010 * Clears all cached objects for a user, or a user is part of.
    21072011 *
    … …  
    21132017
    21142018// List actions to clear super cached pages on, if super cache is installed
    2115 add_action( 'wp_login', 'bp_core_clear_cache' );
     2019add_action( 'wp_login',              'bp_core_clear_cache' );
    21162020add_action( 'bp_core_render_notice', 'bp_core_clear_cache' );
    21172021
    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 been
    2127  * updated to do so.
    2128  *
    2129  * @deprecated 1.3
    2130  * @deprecated Use wp_insert_post() to create a page
    2131  * @package BuddyPress Core
    2132  * @param $slug str The slug of the component
    2133  * @global $bp BuddyPress global settings
    2134  */
    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 }
    21722022?>
  • trunk/bp-core/admin/bp-core-admin.php

    r3716 r3728  
    66                <div id="bp-admin-header">
    77                        <h3><?php _e( 'BuddyPress', 'buddypress' ) ?></h3>
    8                         <h2><?php _e( 'Dashboard', 'buddypress' ) ?></h2>
     8                        <h2><?php _e( 'Dashboard',  'buddypress' ) ?></h2>
    99                </div>
    1010
    … …  
    1818
    1919        </div>
     20
    2021<?php
    2122}
    … …  
    2526
    2627        $ud = get_userdata( $bp->loggedin_user->id );
    27 ?>
    28 
    29         <?php
     28
    3029        if ( isset( $_POST['bp-admin-submit'] ) && isset( $_POST['bp-admin'] ) ) {
    3130                if ( !check_admin_referer('bp-admin') )
    … …  
    5251
    5352                <?php if ( isset( $_POST['bp-admin'] ) ) : ?>
     53
    5454                        <div id="message" class="updated fade">
    5555                                <p><?php _e( 'Settings Saved', 'buddypress' ) ?></p>
    5656                        </div>
     57
    5758                <?php endif; ?>
    5859
    … …  
    6061
    6162                        <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' ) ?> &nbsp;
    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' ) ?> &nbsp;
    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' ) ?> &nbsp;
    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' ) ?> &nbsp;
    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' ) ?> &nbsp;
    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' ) ?> &nbsp;
    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' ) ?> &nbsp;
     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' ) ?> &nbsp;
     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' ) ?> &nbsp;
     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' ) ?> &nbsp;
     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' ) ?> &nbsp;
     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' ) ?> &nbsp;
     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>
    126138                        </table>
    127139
    … …  
    143155function bp_core_admin_component_setup() {
    144156        global $wpdb, $bp;
    145 ?>
    146 
    147         <?php
     157
    148158        if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) {
    149159                if ( !check_admin_referer('bp-admin-component-setup') )
    … …  
    156166                }
    157167                update_site_option( 'bp-deactivated-components', $disabled );
    158         }
    159         ?>
     168        } ?>
    160169
    161170        <div class="wrap">
    … …  
    164173
    165174                <?php if ( isset( $_POST['bp-admin-component-submit'] ) ) : ?>
     175
    166176                        <div id="message" class="updated fade">
    167177                                <p><?php _e( 'Settings Saved', 'buddypress' ) ?></p>
    168178                        </div>
     179
    169180                <?php endif; ?>
    170181
    … …  
    176187
    177188                        <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' ) ?> &nbsp;
    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' ) ?>  &nbsp;
    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' ) ?>  &nbsp;
    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' ) ?>  &nbsp;
    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' ) ?>  &nbsp;
    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' ) ?>  &nbsp;
    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' ) ?>  &nbsp;
    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' ) ?> &nbsp;
     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' ) ?>  &nbsp;
     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' ) ?>  &nbsp;
     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' ) ?>  &nbsp;
     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' ) ?>  &nbsp;
     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' ) ?>  &nbsp;
     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' ) ?>  &nbsp;
     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>
    245280                        </table>
    246281
    … …  
    252287
    253288                </form>
    254 
    255289        </div>
    256290
  • trunk/bp-core/admin/bp-core-update.php

    r3721 r3728  
    1212
    1313/**
    14  * bp_core_activate_site_options()
    15  *
    1614 * When switching from single to multisite we need to copy blog options to
    1715 * site options.
    … …  
    9189                global $wp_rewrite;
    9290
     91                // Setup wizard steps
    9392                if ( 'new' == $this->setup_type ) {
    94                         // Setup wizard steps
    9593                        $steps = array(
    9694                                __( 'Components', 'buddypress' ),
    97                                 __( 'Pages', 'buddypress' ),
     95                                __( 'Pages',      'buddypress' ),
    9896                                __( 'Permalinks', 'buddypress' ),
    99                                 __( 'Theme', 'buddypress' ),
    100                                 __( 'Finish', 'buddypress' )
     97                                __( 'Theme',      'buddypress' ),
     98                                __( 'Finish',     'buddypress' )
    10199                        );
    102100
    … …  
    108106                                $steps = array_merge( array(), $steps );
    109107                        }
     108
     109                // Update wizard steps
    110110                } else {
    111                         // Update wizard steps
    112 
    113111                        if ( $this->is_network_activate )
    114112                                $steps[] = __( 'Multisite Update', 'buddypress' );
    … …  
    167165                        <div id="bp-admin-header">
    168166                                <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>
    180168                        </div>
    181169
    182170                        <?php
    183171                                do_action( 'bp_admin_notices' );
     172
    184173                                $step_count  = count( $this->steps ) - 1;
    185174                                $wiz_or_set  = $this->current_step >= $step_count ? 'bp-general-settings' : 'bp-wizard';
    … …  
    190179                                <div id="bp-admin-nav">
    191180                                        <ol>
     181
    192182                                                <?php foreach( (array)$this->steps as $i => $name ) : ?>
     183
    193184                                                        <li<?php if ( $this->current_step == $i ) : ?> class="current"<?php endif; ?>>
    194185                                                                <?php if ( $this->current_step > $i ) : ?>
     186
    195187                                                                        <span class="complete">&nbsp;</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
    200196                                                        </li>
     197
    201198                                                <?php endforeach; ?>
     199
    202200                                        </ol>
    203201                                        <div class="prev-next submit clear">
    … …  
    207205
    208206                                <div id="bp-admin-content">
     207
    209208                                        <?php switch ( $this->steps[$this->current_step] ) {
    210209                                                case __( 'Database Update', 'buddypress'):
    … …  
    233232                                                        break;
    234233                                        } ?>
     234
    235235                                </div>
    236236                        </form>
    237 
    238                 </div>
     237                </div>
     238
    239239        <?php
    240240        }
    241241
    242         /* Setup Step HTML */
     242        // Setup Step HTML
    243243
    244244        function step_db_update() {
    245245                if ( !current_user_can( 'activate_plugins' ) )
    246                         return false;
    247         ?>
     246                        return false; ?>
     247
    248248                <div class="prev-next submit clear">
    249249                        <p><input type="submit" value="<?php _e( 'Update &amp; Next &rarr;', 'buddypress' ) ?>" name="submit" /></p>
    … …  
    257257                        <input type="hidden" name="save" value="db_update" />
    258258                        <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
     259
    259260                        <?php wp_nonce_field( 'bpwizard_db_update' ) ?>
    260                 </div>
     261
     262                </div>
     263
    261264        <?php
    262265        }
    … …  
    319322                        <input type="hidden" name="save" value="ms_update" />
    320323                        <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
     324
    321325                        <?php wp_nonce_field( 'bpwizard_ms_update' ) ?>
     326
    322327                </div>
    323328
    … …  
    327332                        });
    328333                </script>
     334
    329335        <?php
    330336        }
    331 
    332337
    333338        function step_components() {
    … …  
    455460                $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
    456461
    457                 /* Check for defined slugs */
     462                // Check for defined slugs
    458463                if ( defined( 'BP_MEMBERS_SLUG' ) )
    459464                        $members_slug = constant( 'BP_MEMBERS_SLUG' );
    … …  
    628633
    629634                if ( !got_mod_rewrite() && !iis7_supports_permalinks() )
    630                         $prefix = '/index.php';
    631         ?>
     635                        $prefix = '/index.php'; ?>
    632636
    633637                <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>
    … …  
    654658                        <input type="hidden" name="save" value="permalinks" />
    655659                        <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
     660
    656661                        <?php wp_nonce_field( 'bpwizard_permalinks' ) ?>
     662
    657663                </div>
    658664        <?php
    … …  
    665671                require_once( ABSPATH . WPINC . '/plugin.php' );
    666672                $installed_plugins = get_plugins();
    667                 $installed_themes = get_themes();
     673                $installed_themes  = get_themes();
    668674
    669675                $template_pack_installed = false;
    670                 $bp_autotheme_installed = false;
    671                 $bp_theme_installed = false;
     676                $bp_autotheme_installed  = false;
     677                $bp_theme_installed      = false;
    672678
    673679                foreach ( (array)$installed_plugins as $plugin ) {
    … …  
    700706                                </td>
    701707                        </tr>
     708
    702709                        <?php /*
    703710                        <tr>
    … …  
    714721                        </tr>
    715722                        */ ?>
     723
    716724                        <tr>
    717725                                <th>
    … …  
    732740                                </td>
    733741                        </tr>
     742
    734743                        <tr>
    735744                                <th>
    … …  
    774783                        });
    775784                </script>
     785
    776786        <?php
    777787        }
    … …  
    811821        }
    812822
    813         /* Save Step Methods */
     823        // Save Step Methods
    814824
    815825        function step_db_update_save() {
    … …  
    837847                        // Transfer important settings from blog options to site options
    838848                        $options = array(
    839                                 'bp-db-version' => $this->current_version,
     849                                'bp-db-version'             => $this->current_version,
    840850                                'bp-deactivated-components' => $disabled,
    841                                 'avatar-default' => get_option( 'avatar-default' )
     851                                'avatar-default'            => get_option( 'avatar-default' )
    842852                        );
    843853                        bp_core_activate_site_options( $options );
    … …  
    853863
    854864                                $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 );
    859867
    860868                                update_option( 'bp-pages', $bp_pages );
    … …  
    942950                                if ( !empty($permalink_structure) )
    943951                                        $permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] );
     952
    944953                                if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path )
    945954                                        $permalink_structure = '/blog' . $permalink_structure;
    … …  
    965974                        if ( $iis7_permalinks || ( !$usingpi && !$writable ) ) {
    966975                                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
    970980                                        <?php
    971981                                                _e( 'Oops, there was a problem creating a configuration file. ', 'buddypress' );
    … …  
    982992                                                }
    983993                                        ?>
     994
    984995                                        <br /><br />
     996
    985997                                        <?php
    986998                                                if ( empty( $iis7_permalinks ) )
    987999                                                        _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' );
    9881000                                        ?>
    989                                         </p></div><?php
     1001
     1002                                        </p></div>
     1003
     1004                                <?php
    9901005                                }
    9911006                                add_action( 'bp_admin_notices', '_bp_core_wizard_step_permalinks_message' );
    … …  
    10781093        }
    10791094
    1080         /* Database update methods based on version numbers */
     1095        // Database update methods based on version numbers
    10811096        function update_1_3() {
    10821097                // Run the schema install to update tables
    … …  
    10851100                // Delete old database version options
    10861101                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'   );
    10901105                delete_site_option( 'bp-messages-db-version' );
    10911106                delete_site_option( 'bp-xprofile-db-version' );
    … …  
    12161231                $message = __( 'Installation was successful. The available options have now been updated, please continue with your selection.', 'buddypress' );
    12171232        else
    1218                 return false;
    1219 ?>
     1233                return false; ?>
     1234
    12201235        <div id="message" class="updated">
    12211236                <p><?php echo esc_attr( $message ) ?></p>
    12221237        </div>
     1238
    12231239<?php
    12241240}
    12251241add_action( 'bp_admin_notices', 'bp_core_wizard_message' );
    12261242
    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.
    12281245function bp_core_wizard_thickbox() {
    12291246        $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' ) ); ?>
    … …  
    12421259                }
    12431260        </script>
     1261
    12441262<?php
    12451263}
    … …  
    12471265
    12481266/**
    1249  * bp_core_add_admin_menu()
    1250  *
    12511267 * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
    12521268 *
    … …  
    12911307
    12921308        wp_enqueue_script( 'thickbox' );
    1293         wp_enqueue_style( 'thickbox' );
    1294 ?>
     1309        wp_enqueue_style( 'thickbox' ); ?>
     1310
    12951311        <style type="text/css">
    12961312                /* Wizard Icon */
    … …  
    13101326                }
    13111327        </style>
     1328
    13121329<?php
    13131330}
    13141331add_action( 'admin_head', 'bp_core_add_admin_menu_styles' );
     1332
    13151333?>
  • trunk/bp-core/bp-core-templatetags.php

    r3701 r3728  
    163163
    164164        // 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 )
    166166                return false;
    167167
    … …  
    583583function bp_get_options_nav() {
    584584        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 )
    587591                return false;
    588592
    589593        /* 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 ) {
    591595                if ( !$subnav_item['user_has_access'] )
    592596                        continue;
    … …  
    15571561        }
    15581562
     1563/**
     1564 * Echoes the output of bp_get_root_slug()
     1565 *
     1566 * @package BuddyPress Core
     1567 * @since 1.3
     1568 */
     1569function 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
    15591619/* 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 */
     1634function 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 */
     1680function 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}
    15601690
    15611691/**
    … …  
    15911721                return true;
    15921722
    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 ) )
    15941724                return true;
    15951725
    … …  
    16611791
    16621792function 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 ) )
    16661794                return true;
    16671795
    … …  
    16701798
    16711799function 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 ) )
    16751801                return true;
    16761802
    … …  
    16791805
    16801806function 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 ) )
    16841808                return true;
    16851809
    … …  
    16881812
    16891813function 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 ) )
    16931815                return true;
    16941816
    … …  
    16971819
    16981820function 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 ) )
    17021822                return true;
    17031823
    … …  
    17061826
    17071827function 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 ) )
    17111829                return true;
    17121830
    … …  
    17151833
    17161834function 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 ) )
    17201836                return true;
    17211837
    … …  
    17351851        global $bp;
    17361852
    1737         if ( $bp->activity->slug == $bp->current_component )
     1853        if ( bp_is_current_component( $bp->activity->slug ) )
    17381854                return true;
    17391855
    … …  
    17441860        global $bp;
    17451861
    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 )
    17471863                return true;
    17481864
    … …  
    17531869        global $bp;
    17541870
    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 ) )
    17561872                return true;
    17571873
    … …  
    17621878        global $bp;
    17631879
    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 ) )
    17651881                return true;
    17661882
    … …  
    17711887        global $bp;
    17721888
    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 )
    17741890                return true;
    17751891
    … …  
    17801896        global $bp;
    17811897
    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 )
    17831899                return true;
    17841900
    … …  
    17881904function bp_is_user_groups() {
    17891905        global $bp;
    1790 
    1791         if ( $bp->groups->slug == $bp->current_component )
     1906       
     1907        if ( bp_is_current_component( BP_GROUPS_SLUG ) )
    17921908                return true;
    17931909
    … …  
    17971913function bp_is_group() {
    17981914        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 )
    18011917                return true;
    18021918
    … …  
    18071923        global $bp;
    18081924
    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 ) )
    18101926                return true;
    18111927
    … …  
    18161932        global $bp;
    18171933
    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 )
    18191935                return true;
    18201936
    … …  
    18261942        global $bp;
    18271943
    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 )
    18291945                return true;
    18301946
    … …  
    18351951        global $bp;
    18361952
    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 )
    18381954                return true;
    18391955
    … …  
    18441960        global $bp;
    18451961
    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 )
    18471963                return true;
    18481964
    … …  
    18531969        global $bp;
    18541970
    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] )
    18561972                return true;
    18571973
    … …  
    18621978        global $bp;
    18631979
    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] )
    18651981                return true;
    18661982
    … …  
    18711987        global $bp;
    18721988
    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 )
    18741990                return true;
    18751991
    … …  
    18801996        global $bp;
    18811997
    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 )
    18831999                return true;
    18842000
    … …  
    18892005        global $bp;
    18902006
    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 )
    18922008                return true;
    18932009
    … …  
    18982014        global $bp;
    18992015
    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 )
    19012017                return true;
    19022018
    … …  
    19072023        global $bp;
    19082024
    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 )
    19102026                return true;
    19112027
    … …  
    19162032        global $bp;
    19172033
    1918         if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component )
     2034        if ( is_multisite() && bp_is_current_component( BP_BLOGS_SLUG ) )
    19192035                return true;
    19202036
    … …  
    19252041        global $bp;
    19262042
    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 )
    19282044                return true;
    19292045
    … …  
    19342050        global $bp;
    19352051
    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 )
    19372053                return true;
    19382054
    … …  
    19432059        global $bp;
    19442060
    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 )
    19462062                return true;
    19472063
    … …  
    19502066
    19512067function 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 ) )
    19552069                return true;
    19562070
    … …  
    19612075        global $bp;
    19622076
    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 )
    19642078                return true;
    19652079
    … …  
    19682082
    19692083function 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 ) )
    19732085                return true;
    19742086
    … …  
    19792091        global $bp;
    19802092
    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 ) )
    19822094                return true;
    19832095
    … …  
    19882100        global $bp;
    19892101
    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 )
    19912103                return true;
    19922104
    … …  
    19982110        global $bp;
    19992111
    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 )
    20012113                return true;
    20022114
    … …  
    20082120        global $bp;
    20092121
    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 )
    20112123                return true;
    20122124
    … …  
    20242136
    20252137function 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 ) )
    20292139                return true;
    20302140
    … …  
    20332143
    20342144function 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 ) )
    20382146                return true;
    20392147
  • trunk/bp-core/css/admin.dev.css

    r3727 r3728  
     1html {
     2        padding-top: 28px !important;
     3}
     4
    15div#bp-admin {
    26        margin: 25px 15px 25px 0;
    … …  
    913
    1014div#bp-admin div#bp-admin-header {
    11         height: 45px;
     15       
    1216}
    1317
  • trunk/bp-forums.php

    r3713 r3728  
    11<?php
    22
    3 /* Define the parent forum ID */
     3// Define the parent forum ID
    44if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
    55        define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
    … …  
    1919function bp_forums_setup() {
    2020        global $bp;
    21        
    22         if ( !defined( 'BP_FORUMS_SLUG' ) )
    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 ) );
    2424
    2525        // For internal identification
    2626        $bp->forums->id = 'forums';
    2727
     28        // Slugs
     29        $bp->forums->slug      = BP_FORUMS_SLUG;
     30        $bp->forums->root_slug = $bp->pages->forums->slug;
     31
     32        // Images
    2833        $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
    29         $bp->forums->slug = BP_FORUMS_SLUG;
    3034
    3135        if ( isset( $bp->site_options['bb-config-location'] ) )
    … …  
    8185                do_action( 'bbpress_init' );
    8286
    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.
    8488                if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
    85                         /* Check the nonce */
    8689                        check_admin_referer( 'bp_forums_new_topic' );
    8790
    8891                        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
    9093                                if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    9194                                        groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
    … …  
    134137        require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' );
    135138
    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
    137140        add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
    138141}
    139142add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_forums_add_admin_menu' );
    140143
    141 /* Forum Functions */
     144/** Forum Functions ***********************************************************/
    142145
    143146function bp_forums_get_forum( $forum_id ) {
    … …  
    150153
    151154        $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,
    156159                'forum_is_category' => 0
    157160        );
    … …  
    182185}
    183186
    184 /* Topic Functions */
     187/** Topic Functions ***********************************************************/
    185188
    186189function bp_forums_get_forum_topics( $args = '' ) {
    … …  
    207210                        $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' );
    208211                        $topics =& $query->results;
    209                 break;
     212                        break;
    210213
    211214                case 'popular':
    212215                        $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 ) );
    213216                        $topics =& $query->results;
    214                 break;
     217                        break;
    215218
    216219                case 'unreplied':
    217220                        $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 ) );
    218221                        $topics =& $query->results;
    219                 break;
     222                        break;
    220223
    221224                case 'tags':
    222225                        $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 ) );
    223226                        $topics =& $query->results;
    224                 break;
     227                        break;
    225228        }
    226229
    … …  
    247250
    248251        $defaults = array(
    249                 'topic_title' => '',
    250                 'topic_slug' => '',
    251                 'topic_text' => '',
    252                 'topic_poster' => $bp->loggedin_user->id, // accepts ids
    253                 'topic_poster_name' => $bp->loggedin_user->fullname, // accept names
    254                 'topic_last_poster' => $bp->loggedin_user->id, // accepts ids
     252                '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
    255258                '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 delim
    260                 'forum_id' => 0 // accepts ids or slugs
     259                '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
    261264        );
    262265
    … …  
    275278                return false;
    276279
    277         /* Now insert the first post. */
     280        // Now insert the first post.
    278281        if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) )
    279282                return false;
    … …  
    290293
    291294        $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
     316function bp_forums_sticky_topic( $args = '' ) {
     317        global $bp;
     318
     319        do_action( 'bbpress_init' );
     320
     321        $defaults = array(
    292322                '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
    321324        );
    322325
    … …  
    339342        $defaults = array(
    340343                'topic_id' => false,
    341                 'mode' => 'close' // stick/unstick
     344                'mode'     => 'close' // stick/unstick
    342345        );
    343346
    … …  
    398401                return $topics;
    399402
    400         /* Get the topic ids */
     403        // Get the topic ids
    401404        foreach ( (array)$topics as $topic ) $topic_ids[] = $topic->topic_id;
    402405        $topic_ids = $wpdb->escape( join( ',', (array)$topic_ids ) );
    403406
    404         /* Fetch the topic's last poster details */
     407        // Fetch the topic's last poster details
    405408        $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} )" ) );
    406409        for ( $i = 0; $i < count( $topics ); $i++ ) {
    407410                foreach ( (array)$poster_details as $poster ) {
    408411                        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;
    412415                                $topics[$i]->topic_last_poster_displayname = $poster->display_name;
    413416                        }
    … …  
    415418        }
    416419
    417         /* Fetch fullname for the topic's last poster */
     420        // Fetch fullname for the topic's last poster
    418421        if ( bp_is_active( 'xprofile' ) ) {
    419422                $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} )" ) );
    … …  
    429432}
    430433
    431 /* Post Functions */
     434/** Post Functions ************************************************************/
    432435
    433436function bp_forums_get_topic_posts( $args = '' ) {
    … …  
    436439        $defaults = array(
    437440                'topic_id' => false,
    438                 'page' => 1,
     441                'page'     => 1,
    439442                '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 );
    445447        $query = new BB_Query( 'post', $args, 'get_thread' );
     448
    446449        return bp_forums_get_post_extras( $query->results );
    447450}
    … …  
    473476
    474477        $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 names
    480                 'poster_ip' => $_SERVER['REMOTE_ADDR'],
    481                 'post_status' => 0, // use bb_delete_post() instead
     478                '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
    482485                'post_position' => false
    483486        );
    … …  
    503506        $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 ) );
    504507
    505         if ( $post_id )
     508        if ( !empty( $post_id ) )
    506509                do_action( 'bp_forums_new_post', $post_id );
    507510
    … …  
    515518                return $posts;
    516519
    517         /* Get the user ids */
     520        // Get the user ids
    518521        foreach ( (array)$posts as $post ) $user_ids[] = $post->poster_id;
    519522        $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
    520523
    521         /* Fetch the poster's user_email, user_nicename and user_login */
     524        // Fetch the poster's user_email, user_nicename and user_login
    522525        $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} )" ) );
    523526
    … …  
    525528                foreach ( (array)$poster_details as $poster ) {
    526529                        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;
    529532                                $posts[$i]->poster_nicename = $poster->user_login;
    530                                 $posts[$i]->poster_name = $poster->display_name;
     533                                $posts[$i]->poster_name     = $poster->display_name;
    531534                        }
    532535                }
    533536        }
    534537
    535         /* Fetch fullname for each poster. */
     538        // Fetch fullname for each poster.
    536539        if ( bp_is_active( 'xprofile' ) ) {
    537540                $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} )" ) );
    … …  
    552555        do_action( 'bbpress_init' );
    553556
    554         /* Need to find a bbPress function that does this */
     557        // Need to find a bbPress function that does this
    555558        return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );
    556559}
    … …  
    586589add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' );
    587590add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' );
    588 add_action( 'bp_forums_new_post', 'bp_core_clear_cache' );
     591add_action( 'bp_forums_new_post',  'bp_core_clear_cache' );
     592
    589593?>
  • trunk/bp-friends.php

    r3633 r3728  
    11<?php
    22
     3// Required Files
     4require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
     5require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
     6
    37define ( 'BP_FRIENDS_DB_VERSION', '1800' );
    48
    5 /* Define the slug for the component */
     9// Define the slug for the component
    610if ( !defined( 'BP_FRIENDS_SLUG' ) )
    711        define ( 'BP_FRIENDS_SLUG', 'friends' );
    812
    9 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
    10 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
    11 
    1213function friends_setup_globals() {
    1314        global $bp;
    1415
    15         /* For internal identification */
     16        // For internal identification
    1617        $bp->friends->id = 'friends';
    1718
     19        // Slug
    1820        $bp->friends->slug = BP_FRIENDS_SLUG;
    1921
     22        // Table
    2023        $bp->friends->table_name = $bp->table_prefix . 'bp_friends';
    2124
     25        // Notifications
    2226        $bp->friends->format_notification_function = 'friends_format_notifications';
    2327
    24         /* Register this in the active components array */
     28        // Register this in the active components array
    2529        $bp->active_components[$bp->friends->slug] = $bp->friends->id;
    2630
    … …  
    3236        global $bp;
    3337
    34         /* Add 'Friends' to the main navigation */
     38        // Add 'Friends' to the main navigation
    3539        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 ) );
    3640
    3741        $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
    3842
    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()  ) );
    4246
    4347        if ( $bp->current_component == $bp->friends->slug ) {
    … …  
    7781
    7882        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
    8084                check_admin_referer( 'friends_accept_friendship' );
    8185
    … …  
    8892
    8993        } 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
    9195                check_admin_referer( 'friends_reject_friendship' );
    9296
    … …  
    110114        global $bp;
    111115
    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 ) )
    118121                $accept_requests = 'yes';
    119122?>
     123
    120124        <table class="notification-settings zebra" id="friends-notification-settings">
    121125                <thead>
    … …  
    143147
    144148                        <?php do_action( 'friends_screen_notification_settings' ); ?>
     149
    145150                </tbody>
    146151        </table>
     152
    147153<?php
    148154}
    … …  
    184190                        bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
    185191                }
     192
    186193        } else if ( 'is_friend' == $friendship_status ) {
    187194                bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
    … …  
    222229                        bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
    223230                }
     231
    224232        } else if ( 'is_friends' == $friendship_status ) {
    225233                bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
    … …  
    248256                return false;
    249257
    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,
    258266                'secondary_item_id' => false,
    259                 'recorded_time' => bp_core_current_time(),
    260                 'hide_sitewide' => false
     267                'recorded_time'     => bp_core_current_time(),
     268                'hide_sitewide'     => false
    261269        );
    262270
    … …  
    300308                                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 );
    301309                        }
    302                 break;
     310                        break;
    303311
    304312                case 'friendship_request':
    … …  
    310318                                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 );
    311319                        }
    312                 break;
     320                        break;
    313321        }
    314322
    … …  
    337345
    338346        $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();
    343351
    344352        if ( $force_accept )
    … …  
    370378
    371379        $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 );
    373381
    374382        // Remove the activity stream item for the user who canceled the friendship
    … …  
    427435
    428436                do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
     437
    429438                return true;
    430439        }
    … …  
    456465}
    457466
     467// Returns - 'is_friend', 'not_friends', 'pending'
    458468function friends_check_friendship_status( $user_id, $possible_friend_id ) {
    459         /* Returns - 'is_friend', 'not_friends', 'pending' */
    460469        return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
    461470}
    462471
    463 function friends_get_total_friend_count( $user_id = false ) {
     472function friends_get_total_friend_count( $user_id = 0 ) {
    464473        global $bp;
    465474
    … …  
    504513}
    505514
    506 function friends_get_recently_active( $user_id, $per_page = false, $page = false, $filter = false ) {
     515function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
    507516        return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
    508517}
    509518
    510 function friends_get_alphabetically( $user_id, $per_page = false, $page = false, $filter = false ) {
     519function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
    511520        return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
    512521}
    513522
    514 function friends_get_newest( $user_id, $per_page = false, $page = false, $filter = false ) {
     523function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
    515524        return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
    516525}
    … …  
    520529}
    521530
    522 function friends_get_friends_invite_list( $user_id = false ) {
     531function friends_get_friends_invite_list( $user_id = 0 ) {
    523532        global $bp;
    524533
    … …  
    549558}
    550559
    551 function friends_search_users( $search_terms, $user_id, $pag_num = false, $pag_page = false ) {
     560function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) {
    552561        global $bp;
    553562
    … …  
    557566                return false;
    558567
    559         for ( $i = 0; $i < count($user_ids); $i++ ) {
     568        for ( $i = 0; $i < count( $user_ids ); $i++  )
    560569                $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 ) );
    564572}
    565573
    … …  
    584592        BP_Friends_Friendship::delete_all_for_user($user_id);
    585593
    586         /* Remove usermeta */
     594        // Remove usermeta
    587595        delete_user_meta( $user_id, 'total_friend_count' );
    588596
    589         /* Remove friendship requests FROM user */
     597        // Remove friendship requests FROM user
    590598        bp_core_delete_notifications_from_user( $user_id, $bp->friends->id, 'friendship_request' );
    591599
    592600        do_action( 'friends_remove_data', $user_id );
    593601}
    594 add_action( 'wpmu_delete_user', 'friends_remove_data' );
    595 add_action( 'delete_user', 'friends_remove_data' );
     602add_action( 'wpmu_delete_user',  'friends_remove_data' );
     603add_action( 'delete_user',       'friends_remove_data' );
    596604add_action( 'bp_make_spam_user', 'friends_remove_data' );
    597605
    … …  
    608616                return false;
    609617
    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' );
    612620        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' );
    614622}
    615623
    … …  
    624632// List actions to clear object caches on
    625633add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
    626 add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );
     634add_action( 'friends_friendship_deleted',  'friends_clear_friend_object_cache' );
    627635
    628636// 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' );
     637add_action( 'friends_friendship_rejected',  'bp_core_clear_cache' );
     638add_action( 'friends_friendship_accepted',  'bp_core_clear_cache' );
     639add_action( 'friends_friendship_deleted',   'bp_core_clear_cache' );
    632640add_action( 'friends_friendship_requested', 'bp_core_clear_cache' );
    633641
  • trunk/bp-groups.php

    r3648 r3728  
    11<?php
     2
     3// Required Files
    24require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php' );
    35require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-templatetags.php' );
    … …  
    1416        global $bp;
    1517
     18        // Define a slug, if necessary
    1619        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
    2431        $bp->groups->table_name           = $bp->table_prefix . 'bp_groups';
    2532        $bp->groups->table_name_members   = $bp->table_prefix . 'bp_groups_members';
    2633        $bp->groups->table_name_groupmeta = $bp->table_prefix . 'bp_groups_groupmeta';
    2734
     35        // Notifications
    2836        $bp->groups->format_notification_function = 'groups_format_notifications';
    2937
    30         /* Register this in the active components array */
     38        // Register this in the active components array
    3139        $bp->active_components[$bp->groups->slug] = $bp->groups->id;
    3240
    … …  
    3442
    3543        $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 ),
    3745                '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 ),
    3947        ) );
    4048
    … …  
    4856
    4957        // The default text for the groups directory search box
    50         $bp->default_search_strings[$bp->groups->slug] = __( 'Search Groups...', 'buddypress' );
     58        $bp->default_search_strings[$bp->groups->slug] = __( 'Search Groups...', 'buddypress' );
    5159
    5260        do_action( 'groups_setup_globals' );
    … …  
    5765        global $bp;
    5866
    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.
    6270                $bp->is_single_item = true;
    6371                $bp->groups->current_group = new BP_Groups_Group( $group_id );
    6472
    65                 /* Using "item" not "group" for generic support in other components. */
     73                // Using "item" not "group" for generic support in other components.
    6674                if ( is_super_admin() )
    6775                        $bp->is_item_admin = 1;
    … …  
    6977                        $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id );
    7078
    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
    7280                if ( !$bp->is_item_admin )
    7381                        $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id );
    7482
    75                 /* Is the logged in user a member of the group? */
     83                // Is the logged in user a member of the group?
    7684                $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;
    7785
    78                 /* Should this group be visible to the logged in user? */
     86                // Should this group be visible to the logged in user?
    7987                $bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $bp->groups->current_group->is_user_member ) ? true : false;
    8088        }
    8189
    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 ) ) {
    92100
    93101                if ( bp_is_my_profile() && !$bp->is_single_item ) {
    … …  
    104112                        // group navigation menu using the $bp->groups->current_group global.
    105113
    106                         /* When in a single group, the first action is bumped down one because of the
    107                            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;
    109117                        $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 );
    111119
    112120                        $bp->bp_options_title = $bp->groups->current_group->name;
    … …  
    115123                                $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
    116124
    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 . '/';
    118126
    119127                        // If this is a private or hidden group, does the user have access?
    … …  
    127135                        }
    128136
    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
    139147                        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' ) );
    141149
    142150                        // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
    143151                        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'  ) );
    150159
    151160                        if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    152161                                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 ) );
    154163                        }
    155164                }
    … …  
    165174function groups_directory_groups_setup() {
    166175        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 ) ) {
    169178                $bp->is_directory = true;
    170179
    … …  
    181190                return false;
    182191
    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
    184193        if ( !is_super_admin() )
    185                 return false;
    186         ?>
     194                return false; ?>
     195
    187196        <li id="bp-adminbar-adminoptions-menu">
    188197                <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
    … …  
    192201
    193202                        <?php do_action( 'groups_adminbar_menu_items' ) ?>
     203
    194204                </ul>
    195205        </li>
     206
    196207        <?php
    197208}
    198209add_action( 'bp_adminbar_menus', 'groups_setup_adminbar_menu', 20 );
    199 
    200210
    201211/********************************************************************************
    … …  
    210220        global $bp;
    211221
    212         if ( isset($_GET['n']) ) {
    213                 // Delete group request notifications for the user
     222        // Delete group request notifications for the user
     223        if ( isset( $_GET['n'] ) ) {
    214224                bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
    215225                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'    );
    218228        }
    219229
    … …  
    231241
    232242        if ( isset( $bp->action_variables ) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric( $group_id ) ) {
    233                 /* Check the nonce */
     243                // Check the nonce
    234244                if ( !check_admin_referer( 'groups_accept_invite' ) )
    235245                        return false;
    … …  
    240250                        bp_core_add_message( __('Group invite accepted', 'buddypress') );
    241251
    242                         /* Record this in activity streams */
     252                        // Record this in activity streams
    243253                        $group = new BP_Groups_Group( $group_id );
    244254
    245255                        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',
    248258                                'item_id' => $group->id
    249259                        ) );
    … …  
    253263
    254264        } elseif ( isset( $bp->action_variables ) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric( $group_id ) ) {
    255                 /* Check the nonce */
     265                // Check the nonce
    256266                if ( !check_admin_referer( 'groups_reject_invite' ) )
    257267                        return false;
    … …  
    277287
    278288        if ( $bp->is_single_item ) {
    279                 if ( isset($_GET['n']) ) {
    280                         // Delete group request notifications for the user
     289                if ( isset( $_GET['n'] ) ) {
    281290                        bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
    282291                        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'    );
    285294                }
    286295
    … …  
    296305        if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) {
    297306
    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' );
    303311                $user_is_banned = false;
     312
    304313                if ( !is_super_admin() && groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    305314                        $user_is_banned = true;
    … …  
    307316                if ( $topic_slug && $topic_id ) {
    308317
    309                         /* Posting a reply */
     318                        // Posting a reply
    310319                        if ( !$user_is_banned && !isset( $bp->action_variables[2] ) && isset( $_POST['submit_reply'] ) ) {
    311                                 /* Check the nonce */
     320                                // Check the nonce
    312321                                check_admin_referer( 'bp_forums_new_reply' );
    313322
    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
    315324                                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 ) )
    316325                                        groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    317326
    318                                 $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false;
     327                                $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false;
    319328
    320329                                if ( !$post_id = groups_new_group_forum_post( $_POST['reply_text'], $topic_id, $topic_page ) )
    … …  
    329338                        }
    330339
    331                         /* Sticky a topic */
     340                        // Sticky a topic
    332341                        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
    334343                                check_admin_referer( 'bp_forums_stick_topic' );
    335344
    … …  
    343352                        }
    344353
    345                         /* Un-Sticky a topic */
     354                        // Un-Sticky a topic
    346355                        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
    348357                                check_admin_referer( 'bp_forums_unstick_topic' );
    349358
    … …  
    357366                        }
    358367
    359                         /* Close a topic */
     368                        // Close a topic
    360369                        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
    362371                                check_admin_referer( 'bp_forums_close_topic' );
    363372
    … …  
    371380                        }
    372381
    373                         /* Open a topic */
     382                        // Open a topic
    374383                        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
    376385                                check_admin_referer( 'bp_forums_open_topic' );
    377386
    … …  
    385394                        }
    386395
    387                         /* Delete a topic */
     396                        // Delete a topic
    388397                        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
    390399                                $topic = bp_forums_get_topic_details( $topic_id );
    391400
    … …  
    394403                                        bp_core_redirect( wp_get_referer() );
    395404
    396                                 /* Check the nonce */
     405                                // Check the nonce
    397406                                check_admin_referer( 'bp_forums_delete_topic' );
    398407
    … …  
    407416                        }
    408417
    409                         /* Editing a topic */
     418                        // Editing a topic
    410419                        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
    412421                                $topic = bp_forums_get_topic_details( $topic_id );
    413422
    414                                 /* Check the logged in user can edit this topic */
     423                                // Check the logged in user can edit this topic
    415424                                if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster )
    416425                                        bp_core_redirect( wp_get_referer() );
    417426
    418427                                if ( isset( $_POST['save_changes'] ) ) {
    419                                         /* Check the nonce */
     428                                        // Check the nonce
    420429                                        check_admin_referer( 'bp_forums_edit_topic' );
    421430
    … …  
    432441                        }
    433442
    434                         /* Delete a post */
     443                        // Delete a post
    435444                        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
    437446                                $post = bp_forums_get_post( $post_id );
    438447
    439                                 /* Check the logged in user can edit this topic */
     448                                // Check the logged in user can edit this topic
    440449                                if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id )
    441450                                        bp_core_redirect( wp_get_referer() );
    442451
    443                                 /* Check the nonce */
     452                                // Check the nonce
    444453                                check_admin_referer( 'bp_forums_delete_post' );
    445454
    … …  
    455464                        }
    456465
    457                         /* Editing a post */
     466                        // Editing a post
    458467                        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
    460469                                $post = bp_forums_get_post( $bp->action_variables[4] );
    461470
    462                                 /* Check the logged in user can edit this topic */
     471                                // Check the logged in user can edit this topic
    463472                                if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$post->poster_id )
    464473                                        bp_core_redirect( wp_get_referer() );
    465474
    466475                                if ( isset( $_POST['save_changes'] ) ) {
    467                                         /* Check the nonce */
     476                                        // Check the nonce
    468477                                        check_admin_referer( 'bp_forums_edit_post' );
    469478
    … …  
    483492                        }
    484493
    485                         /* Standard topic display */
     494                        // Standard topic display
    486495                        else {
    487496                                if ( $user_is_banned )
    … …  
    492501
    493502                } else {
    494                         /* Posting a topic */
     503                        // Posting a topic
    495504                        if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) {
    496                                 /* Check the nonce */
     505                                // Check the nonce
    497506                                check_admin_referer( 'bp_forums_new_topic' );
    498507
    … …  
    578587                // If the user has submitted a request, send it.
    579588                if ( isset( $_POST['group-request-send']) ) {
    580                         /* Check the nonce first. */
     589                        // Check the nonce
    581590                        if ( !check_admin_referer( 'groups_request_membership' ) )
    582591                                return false;
    … …  
    599608        global $bp;
    600609
    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] ) )
    602611                return false;
    603612
    … …  
    611620        global $bp;
    612621
    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 )
    614623                return false;
    615624
    … …  
    623632        global $bp;
    624633
    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] ) {
    626635
    627636                if ( $bp->is_item_admin || $bp->is_item_mod  ) {
    … …  
    629638                        // If the edit form has been submitted, save the edited details
    630639                        if ( isset( $_POST['save'] ) ) {
    631                                 /* Check the nonce first. */
     640                                // Check the nonce
    632641                                if ( !check_admin_referer( 'groups_edit_group_details' ) )
    633642                                        return false;
    … …  
    655664        global $bp;
    656665
    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] ) {
    658667
    659668                if ( !$bp->is_item_admin )
    … …  
    667676                        $status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public';
    668677
    669                         /* Check the nonce first. */
     678                        // Check the nonce
    670679                        if ( !check_admin_referer( 'groups_edit_group_settings' ) )
    671680                                return false;
    … …  
    692701        global $bp;
    693702
    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] ) {
    695704
    696705                if ( !$bp->is_item_admin )
    697706                        return false;
    698707
    699                 /* If the group admin has deleted the admin avatar */
     708                // If the group admin has deleted the admin avatar
    700709                if ( 'delete' == $bp->action_variables[1] ) {
    701710
    702                         /* Check the nonce */
     711                        // Check the nonce
    703712                        check_admin_referer( 'bp_group_avatar_delete' );
    704713
    … …  
    714723                if ( !empty( $_FILES ) ) {
    715724
    716                         /* Check the nonce */
     725                        // Check the nonce
    717726                        check_admin_referer( 'bp_avatar_upload' );
    718727
    719                         /* Pass the file to the avatar upload handler */
     728                        // Pass the file to the avatar upload handler
    720729                        if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
    721730                                $bp->avatar_admin->step = 'crop-image';
    722731
    723                                 /* Make sure we include the jQuery jCrop file for image cropping */
     732                                // Make sure we include the jQuery jCrop file for image cropping
    724733                                add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
    725734                        }
    … …  
    727736                }
    728737
    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
    730739                if ( isset( $_POST['avatar-crop-submit'] ) ) {
    731740
    732                         /* Check the nonce */
     741                        // Check the nonce
    733742                        check_admin_referer( 'bp_avatar_cropstore' );
    734743
    … …  
    750759        global $bp;
    751760
    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] ) {
    753762
    754763                if ( !$bp->is_item_admin )
    … …  
    856865        global $bp;
    857866
    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
    861870                if ( !is_user_logged_in() )
    862871                        bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests/' ) );
    … …  
    874883                        if ( 'accept' == $request_action && is_numeric($membership_id) ) {
    875884
    876                                 /* Check the nonce first. */
     885                                // Check the nonce first.
    877886                                if ( !check_admin_referer( 'groups_accept_membership_request' ) )
    878887                                        return false;
    … …  
    914923        global $bp;
    915924
    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] ) {
    917926
    918927                if ( !$bp->is_item_admin && !is_super_admin() )
    … …  
    920929
    921930                if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) {
    922                         /* Check the nonce first. */
     931                        // Check the nonce first.
    923932                        if ( !check_admin_referer( 'groups_delete_group' ) )
    924933                                return false;
    … …  
    950959        global $bp;
    951960
    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 ) )
    966971                $group_request = 'yes';
    967972?>
     973
    968974        <table class="notification-settings zebra" id="groups-notification-settings">
    969975                <thead>
    … …  
    10031009
    10041010                        <?php do_action( 'groups_screen_notification_settings' ); ?>
     1011
    10051012                </tbody>
    10061013        </table>
     1014
    10071015<?php
    10081016}
    … …  
    10211029        global $bp;
    10221030
    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 )
    10251033                return false;
    10261034
    … …  
    10281036                return false;
    10291037
    1030         /* Make sure creation steps are in the right order */
     1038        // Make sure creation steps are in the right order
    10311039        groups_action_sort_creation_steps();
    10321040
    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
    10341042        if ( !isset( $bp->action_variables[1] ) || !$bp->groups->current_create_step = $bp->action_variables[1] ) {
    10351043
    … …  
    10411049
    10421050                $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
    10471055        if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
    10481056                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
    10531061        if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !isset( $reset_steps ) )
    10541062                $bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE['bp_completed_create_steps'] ) );
    10551063
    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
    10571065        if ( isset( $_COOKIE['bp_new_group_id'] ) ) {
    10581066                $bp->groups->new_group_id = $_COOKIE['bp_new_group_id'];
    … …  
    10601068        }
    10611069
    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
    10631071        if ( isset( $_POST['save'] ) ) {
    10641072
    1065                 /* Check the nonce */
     1073                // Check the nonce
    10661074                check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );
    10671075
    … …  
    10691077                        if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) {
    10701078                                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 . '/' );
    10721080                        }
    10731081
    … …  
    10761084                        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' ) ) ) {
    10771085                                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 . '/' );
    10791087                        }
    10801088
    … …  
    10901098                                $group_enable_forum = 0;
    10911099                        } else {
    1092                                 /* Create the forum if enable_forum = 1 */
     1100                                // Create the forum if enable_forum = 1
    10931101                                if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) {
    10941102                                        groups_new_group_forum();
    … …  
    11031111                        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 ) ) ) {
    11041112                                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 . '/' );
    11061114                        }
    11071115                }
    11081116
    1109                 if ( 'group-invites' == $bp->groups->current_create_step ) {
     1117                if ( 'group-invites' == $bp->groups->current_create_step )
    11101118                        groups_send_invites( $bp->loggedin_user->id, $bp->groups->new_group_id );
    1111                 }
    11121119
    11131120                do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
    … …  
    11231130                        $bp->groups->completed_create_steps[] = $bp->groups->current_create_step;
    11241131
    1125                 /* Reset cookie info */
     1132                // Reset cookie info
    11261133                setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
    11271134                setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );
    11281135
    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
    11301138                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 ) ) ) {
    11311139                        unset( $bp->groups->current_create_step );
    11321140                        unset( $bp->groups->completed_create_steps );
    11331141
    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.
    11351143                        groups_record_activity( array(
    11361144                                '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>' ) ),
    … …  
    11591167                        }
    11601168
    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
    11661174        if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
    11671175                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
    11711179                        if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
    11721180                                $bp->avatar_admin->step = 'crop-image';
    11731181
    1174                                 /* Make sure we include the jQuery jCrop file for image cropping */
     1182                                // Make sure we include the jQuery jCrop file for image cropping
    11751183                                add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
    11761184                        }
    11771185                }
    11781186
    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
    11801188                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
    11821190
    11831191                        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'] ) ) )
    … …  
    11951203        global $bp;
    11961204
    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' )
    11981206                return false;
    11991207
    … …  
    12301238        global $bp;
    12311239
    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' )
    12331241                return false;
    12341242
    … …  
    12551263        global $bp;
    12561264
    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' )
    12581266                return false;
    12591267
    … …  
    12681276        }
    12691277
    1270         /* Sort the steps by their position key */
     1278        // Sort the steps by their position key
    12711279        ksort($temp);
    12721280        unset($bp->groups->group_creation_steps);
    … …  
    12791287        global $bp, $wpdb;
    12801288
    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'] ) ) {
    12821290                $group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) );
    12831291
    … …  
    12901298        global $bp, $wp_query;
    12911299
    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' )
    12931301                return false;
    12941302
    … …  
    13201328                return false;
    13211329
    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' ) );
    13241332        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' ) );
    13261334
    13271335        do_action( 'groups_register_activity_actions' );
    … …  
    13351343                return false;
    13361344
    1337         /* If the group is not public, hide the activity sitewide. */
     1345        // If the group is not public, hide the activity sitewide.
    13381346        if ( 'public' == $bp->groups->current_group->status )
    13391347                $hide_sitewide = false;
    … …  
    13411349                $hide_sitewide = true;
    13421350
    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,
    13521360                'secondary_item_id' => false,
    1353                 'recorded_time' => bp_core_current_time(),
    1354                 'hide_sitewide' => $hide_sitewide
     1361                'recorded_time'     => bp_core_current_time(),
     1362                'hide_sitewide'     => $hide_sitewide
    13551363        );
    13561364
    … …  
    13611369}
    13621370
    1363 function groups_update_last_activity( $group_id = false ) {
     1371function groups_update_last_activity( $group_id = 0 ) {
    13641372        global $bp;
    13651373
    … …  
    13951403                                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 );
    13961404                        }
    1397                 break;
     1405                        break;
    13981406
    13991407                case 'membership_request_accepted':
    … …  
    14081416                                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 );
    14091417
    1410                 break;
     1418                        break;
    14111419
    14121420                case 'membership_request_rejected':
    … …  
    14211429                                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 );
    14221430
    1423                 break;
     1431                        break;
    14241432
    14251433                case 'member_promoted_to_admin':
    … …  
    14341442                                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 );
    14351443
    1436                 break;
     1444                        break;
    14371445
    14381446                case 'member_promoted_to_mod':
    … …  
    14471455                                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 );
    14481456
    1449                 break;
     1457                        break;
    14501458
    14511459                case 'group_invite':
    … …  
    14601468                                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 );
    14611469
    1462                 break;
     1470                        break;
    14631471        }
    14641472
    … …  
    14801488function groups_get_group( $args = '' ) {
    14811489        $defaults = array(
    1482                 'group_id' => false,
     1490                'group_id'   => false,
    14831491                'load_users' => false
    14841492        );
    … …  
    15441552                return false;
    15451553
     1554        // If this is a new group, set up the creator as the first member and admin
    15461555        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;
    15541562                $member->date_modified = bp_core_current_time();
    15551563
    … …  
    15721580                return false;
    15731581
    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;
    15761584        $group->description = $group_desc;
    15771585
    … …  
    16021610                groups_accept_all_pending_membership_requests( $group->id );
    16031611
    1604         /* Now update the status */
     1612        // Now update the status
    16051613        $group->status = $status;
    16061614
    … …  
    16081616                return false;
    16091617
    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.
    16111619        if ( $group->enable_forum ) {
    16121620                if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group->id, 'forum_id' ) ) {
    … …  
    16751683                $slug = substr( $slug, 2, strlen( $slug ) - 2 );
    16761684
    1677         if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) {
     1685        if ( in_array( $slug, (array)$bp->groups->forbidden_names ) )
    16781686                $slug = $slug . '-' . rand();
    1679         }
    16801687
    16811688        if ( BP_Groups_Group::check_slug( $slug ) ) {
    … …  
    16961703/*** User Actions ***************************************************************/
    16971704
    1698 function groups_leave_group( $group_id, $user_id = false ) {
     1705function groups_leave_group( $group_id, $user_id = 0 ) {
    16991706        global $bp;
    17001707
    … …  
    17021709                $user_id = $bp->loggedin_user->id;
    17031710
    1704         /* Don't let single admins leave the group. */
     1711        // Don't let single admins leave the group.
    17051712        if ( count( groups_get_group_admins( $group_id ) ) < 2 ) {
    17061713                if ( groups_is_user_admin( $user_id, $group_id ) ) {
    … …  
    17161723                return false;
    17171724
    1718         /* Modify group member count */
     1725        // Modify group member count
    17191726        groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
    17201727
    1721         /* Modify user's group memberhip count */
     1728        // Modify user's group memberhip count
    17221729        update_user_meta( $user_id, 'total_group_count', (int) get_user_meta( $user_id, 'total_group_count', true ) - 1 );
    17231730
    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.
    17261735         */
    17271736        if ( function_exists( 'bp_activity_delete' ) && gmmktime() <= strtotime( '+5 minutes', (int)strtotime( $membership->date_modified ) ) )
    … …  
    17351744}
    17361745
    1737 function groups_join_group( $group_id, $user_id = false ) {
     1746function groups_join_group( $group_id, $user_id = 0 ) {
    17381747        global $bp;
    17391748
    … …  
    17531762                return true;
    17541763
    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    = '';
    17611770        $new_member->date_modified = bp_core_current_time();
    1762         $new_member->is_confirmed = 1;
     1771        $new_member->is_confirmed  = 1;
    17631772
    17641773        if ( !$new_member->save() )
    … …  
    17721781        // Record this in activity streams
    17731782        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',
    17761785                'item_id' => $group_id,
    17771786                'user_id' => $user_id
    … …  
    18151824
    18161825        $defaults = array(
    1817                 'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts
    1818                 'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of
    1819                 '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 terms
    1822                 'show_hidden' => false, // Show hidden groups to non-admins
    1823 
    1824                 'per_page' => 20, // The number of results to return per page
    1825                 'page' => 1, // The page to return if limiting per page
    1826                 'populate_extras' => true, // Fetch meta such as is_banned and is_member
     1826                '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
    18271836        );
    18281837
    … …  
    18441853}
    18451854
    1846 function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
     1855function groups_get_user_groups( $user_id = 0, $pag_num = 0, $pag_page = 0 ) {
    18471856        global $bp;
    18481857
    … …  
    18531862}
    18541863
    1855 function groups_total_groups_for_user( $user_id = false ) {
     1864function groups_total_groups_for_user( $user_id = 0 ) {
    18561865        global $bp;
    18571866
    … …  
    18691878/*** Group Avatars *************************************************************/
    18701879
    1871 function groups_avatar_upload_dir( $group_id = false ) {
     1880function groups_avatar_upload_dir( $group_id = 0 ) {
    18721881        global $bp;
    18731882
    … …  
    18751884                $group_id = $bp->groups->current_group->id;
    18761885
    1877         $path = BP_AVATAR_UPLOAD_PATH . '/group-avatars/' . $group_id;
     1886        $path    = BP_AVATAR_UPLOAD_PATH . '/group-avatars/' . $group_id;
    18781887        $newbdir = $path;
    18791888
    … …  
    18811890                @wp_mkdir_p( $path );
    18821891
    1883         $newurl = BP_AVATAR_URL . '/group-avatars/' . $group_id;
    1884         $newburl = $newurl;
     1892        $newurl    = BP_AVATAR_URL . '/group-avatars/' . $group_id;
     1893        $newburl   = $newurl;
    18851894        $newsubdir = '/group-avatars/' . $group_id;
    18861895
    … …  
    19241933
    19251934        $defaults = array(
    1926                 'content' => false,
    1927                 'user_id' => $bp->loggedin_user->id,
     1935                'content'  => false,
     1936                'user_id'  => $bp->loggedin_user->id,
    19281937                'group_id' => $bp->groups->current_group->id
    19291938        );
    … …  
    19321941        extract( $r, EXTR_SKIP );
    19331942
    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 ) )
    19351944                return false;
    19361945
    19371946        $bp->groups->current_group = new BP_Groups_Group( $group_id );
    19381947
    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.
    19401949        if ( !is_super_admin() && !groups_is_user_member( $user_id, $group_id ) )
    19411950                return false;
    19421951
    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>' );
    19451954        $activity_content = $content;
    19461955
    19471956        $activity_id = groups_record_activity( array(
    19481957                '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 ),
    19501959                'content' => apply_filters( 'groups_activity_new_update_content', $activity_content ),
    1951                 'type' => 'activity_update',
     1960                'type'    => 'activity_update',
    19521961                'item_id' => $group_id
    19531962        ) );
    19541963
    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.
    19561966        require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
    19571967
    … …  
    19641974/*** Group Forums **************************************************************/
    19651975
    1966 function groups_new_group_forum( $group_id = false, $group_name = false, $group_desc = false ) {
     1976function groups_new_group_forum( $group_id = 0, $group_name = '', $group_desc = '' ) {
    19671977        global $bp;
    19681978
    … …  
    20082018
    20092019        $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 );
    20112021
    20122022        if ( $post_id = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
    … …  
    20202030                        $primary_link .= "?topic_page=" . $page;
    20212031
    2022                 /* Record this in activity streams */
     2032                // Record this in activity streams
    20232033                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,
    20292039                        'secondary_item_id' => $post_id
    20302040                ) );
    … …  
    20452055
    20462056        $topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
    2047         $topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
    2048         $topic_tags = apply_filters( 'group_forum_topic_tags_before_save', $topic_tags );
    2049         $forum_id = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id );
     2057        $topic_text  = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
     2058        $topic_tags  = apply_filters( 'group_forum_topic_tags_before_save', $topic_tags );
     2059        $forum_id    = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id );
    20502060
    20512061        if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) {
    … …  
    20552065                $activity_content = bp_create_excerpt( $topic_text );
    20562066
    2057                 /* Record this in activity streams */
     2067                // Record this in activity streams
    20582068                groups_record_activity( array(
    2059                         'action' => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
    2060                         'content' => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
    2061                         'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
    2062                         'type' => 'new_forum_topic',
    2063                         'item_id' => $bp->groups->current_group->id,
     2069                        'action'            => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
     2070                        'content'           => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
     2071                        'primary_link'      => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
     2072                        'type'              => 'new_forum_topic',
     2073                        'item_id'           => $bp->groups->current_group->id,
    20642074                        'secondary_item_id' => $topic->topic_id
    20652075                ) );
    … …  
    20772087
    20782088        $topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
    2079         $topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
     2089        $topic_text  = apply_filters( 'group_forum_topic_text_before_save',  $topic_text );
    20802090
    20812091        if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) {
    2082                 /* Update the activity stream item */
     2092                // Update the activity stream item
    20832093                if ( function_exists( 'bp_activity_delete_by_item_id' ) )
    20842094                        bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
    … …  
    20872097                $activity_content = bp_create_excerpt( $topic_text );
    20882098
    2089                 /* Record this in activity streams */
     2099                // Record this in activity streams
    20902100                groups_record_activity( array(
    2091                         'action' => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
    2092                         'content' => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
    2093                         'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
    2094                         'type' => 'new_forum_topic',
    2095                         'item_id' => (int)$bp->groups->current_group->id,
    2096                         'user_id' => (int)$topic->topic_poster,
     2101                        'action'            => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
     2102                        'content'           => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
     2103                        'primary_link'      => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
     2104                        'type'              => 'new_forum_topic',
     2105                        'item_id'           => (int)$bp->groups->current_group->id,
     2106                        'user_id'           => (int)$topic->topic_poster,
    20972107                        'secondary_item_id' => $topic->topic_id,
    2098                         'recorded_time' => $topic->topic_time
     2108                        'recorded_time '    => $topic->topic_time
    20992109                ) );
    21002110
    … …  
    21112121
    21122122        $post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
    2113         $topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
    2114 
    2115         $post = bp_forums_get_post( $post_id );
     2123        $topic_id  = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
     2124        $post      = bp_forums_get_post( $post_id );
    21162125
    21172126        if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
    … …  
    21252134                        $primary_link .= "?topic_page=" . $page;
    21262135
    2127                 /* Fetch an existing entry and update if one exists. */
     2136                // Fetch an existing entry and update if one exists.
    21282137                if ( function_exists( 'bp_activity_get_activity_id' ) )
    21292138                        $id = bp_activity_get_activity_id( array( 'user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id ) );
    21302139
    2131                 /* Update the entry in activity streams */
     2140                // Update the entry in activity streams
    21322141                groups_record_activity( array(
    2133                         'id' => $id,
    2134                         'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
    2135                         'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
    2136                         'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
    2137                         'type' => 'new_forum_post',
    2138                         'item_id' => (int)$bp->groups->current_group->id,
    2139                         'user_id' => (int)$post->poster_id,
     2142                        'id'                => $id,
     2143                        'action'            => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
     2144                        'content'           => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
     2145                        'primary_link'      => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
     2146                        'type'              => 'new_forum_post',
     2147                        'item_id'           => (int)$bp->groups->current_group->id,
     2148                        'user_id'           => (int)$post->poster_id,
    21402149                        'secondary_item_id' => $post_id,
    2141                         'recorded_time' => $post->post_time
     2150                        'recorded_time'     => $post->post_time
    21422151                ) );
    21432152
    … …  
    21562165                do_action( 'groups_before_delete_group_forum_topic', $topic_id );
    21572166
    2158                 /* Delete the activity stream item */
    2159                 if ( function_exists( 'bp_activity_delete' ) ) {
     2167                // Delete the activity stream item
     2168                if ( function_exists( 'bp_activity_delete' ) )
    21602169                        bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
    2161                 }
    21622170
    21632171                do_action( 'groups_delete_group_forum_topic', $topic_id );
    … …  
    21752183                do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
    21762184
    2177                 /* Delete the activity stream item */
    2178                 if ( function_exists( 'bp_activity_delete' ) ) {
     2185                // Delete the activity stream item
     2186                if ( function_exists( 'bp_activity_delete' ) )
    21792187                        bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
    2180                 }
    21812188
    21822189                do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
    … …  
    22082215
    22092216        $defaults = array(
    2210                 'user_id' => false,
    2211                 'group_id' => false,
    2212                 'inviter_id' => $bp->loggedin_user->id,
     2217                'user_id'       => false,
     2218                'group_id'      => false,
     2219                'inviter_id'    => $bp->loggedin_user->id,
    22132220                'date_modified' => bp_core_current_time(),
    2214                 'is_confirmed' => 0
     2221                'is_confirmed'  => 0
    22152222        );
    22162223
    … …  
    22222229
    22232230        if ( !groups_is_user_member( $user_id, $group_id ) && !groups_check_user_has_invite( $user_id, $group_id ) ) {
    2224                 $invite = new BP_Groups_Member;
    2225                 $invite->group_id = $group_id;
    2226                 $invite->user_id = $user_id;
     2231                $invite                = new BP_Groups_Member;
     2232                $invite->group_id      = $group_id;
     2233                $invite->user_id       = $user_id;
    22272234                $invite->date_modified = $date_modified;
    2228                 $invite->inviter_id = $inviter_id;
    2229                 $invite->is_confirmed = $is_confirmed;
     2235                $invite->inviter_id    = $inviter_id;
     2236                $invite->is_confirmed  = $is_confirmed;
    22302237
    22312238                if ( !$invite->save() )
    … …  
    22612268                return false;
    22622269
    2263         /* Remove request to join */
     2270        // Remove request to join
    22642271        if ( $member->check_for_membership_request( $user_id, $group_id ) )
    22652272                $member->delete_request( $user_id, $group_id );
    22662273
    2267         /* Modify group meta */
     2274        // Modify group meta
    22682275        groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
    22692276        groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
    … …  
    24032410        global $bp;
    24042411
    2405         /* Prevent duplicate requests */
     2412        // Prevent duplicate requests
    24062413        if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) )
    24072414                return false;
    24082415
    2409         /* Check if the user is already a member or is banned */
     2416        // Check if the user is already a member or is banned
    24102417        if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) )
    24112418                return false;
    24122419
    2413         $requesting_user = new BP_Groups_Member;
    2414         $requesting_user->group_id = $group_id;
    2415         $requesting_user->user_id = $requesting_user_id;
    2416         $requesting_user->inviter_id = 0;
    2417         $requesting_user->is_admin = 0;
    2418         $requesting_user->user_title = '';
     2420        $requesting_user                = new BP_Groups_Member;
     2421        $requesting_user->group_id      = $group_id;
     2422        $requesting_user->user_id       = $requesting_user_id;
     2423        $requesting_user->inviter_id    = 0;
     2424        $requesting_user->is_admin      = 0;
     2425        $requesting_user->user_title    = '';
    24192426        $requesting_user->date_modified = bp_core_current_time();
    2420         $requesting_user->is_confirmed = 0;
    2421         $requesting_user->comments = $_POST['group-request-membership-comments'];
     2427        $requesting_user->is_confirmed  = 0;
     2428        $requesting_user->comments      = $_POST['group-request-membership-comments'];
    24222429
    24232430        if ( $requesting_user->save() ) {
    … …  
    24262433                require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
    24272434
    2428                 for ( $i = 0; $i < count( $admins ); $i++ ) {
    2429                         // Saved okay, now send the email notification
     2435                // Saved okay, now send the email notification
     2436                for ( $i = 0; $i < count( $admins ); $i++ )
    24302437                        groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
    2431                 }
    24322438
    24332439                do_action( 'groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id );
    … …  
    24522458                return false;
    24532459
    2454         /* Check if the user has an outstanding invite, if so delete it. */
     2460        // Check if the user has an outstanding invite, if so delete it.
    24552461        if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) )
    24562462                groups_delete_invite( $membership->user_id, $membership->group_id );
    24572463
    2458         /* Modify group member count */
     2464        // Modify group member count
    24592465        groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
    24602466
    2461         /* Record this in activity streams */
     2467        // Record this in activity streams
    24622468        $group = new BP_Groups_Group( $membership->group_id );
    24632469
    24642470        groups_record_activity( array(
    2465                 'action'        => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ),
    2466                 'type'          => 'joined_group',
    2467                 'item_id'       => $membership->group_id,
    2468                 'user_id'       => $membership->user_id
     2471                'action'  => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ),
     2472                'type'    => 'joined_group',
     2473                'item_id' => $membership->group_id,
     2474                'user_id' => $membership->user_id
    24692475        ) );
    24702476
    2471         /* Send a notification to the user. */
     2477        // Send a notification to the user.
    24722478        require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
    24732479        groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );
    … …  
    25132519                return false;
    25142520
    2515         foreach ( (array) $user_ids as $user_id ) {
     2521        foreach ( (array) $user_ids as $user_id )
    25162522                groups_accept_membership_request( false, $user_id, $group_id );
    2517         }
    25182523
    25192524        do_action( 'groups_accept_all_pending_membership_requests', $group_id );
    … …  
    25302535                return false;
    25312536
    2532         $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    2533 
    2534         if ( is_array($meta_value) || is_object($meta_value) )
     2537        $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
     2538
     2539        if ( is_array( $meta_value ) || is_object( $meta_value ) )
    25352540                $meta_value = serialize($meta_value);
    25362541
    25372542        $meta_value = trim( $meta_value );
    25382543
    2539         if ( !$meta_key ) {
     2544        if ( !$meta_key )
    25402545                $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) );
    2541         } else if ( $meta_value ) {
     2546        else if ( $meta_value )
    25422547                $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) );
    2543         } else {
     2548        else
    25442549                $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
    2545         }
    2546 
    2547         /* Delete the cached object */
     2550
     2551        // Delete the cached object
    25482552        wp_cache_delete( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, 'bp' );
    25492553
    … …  
    25602564
    25612565        if ( !empty($meta_key) ) {
    2562                 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
     2566                $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
    25632567
    25642568                if ( !$metas = wp_cache_get( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, 'bp' ) ) {
    … …  
    25702574        }
    25712575
    2572         if ( empty($metas) ) {
    2573                 if ( empty($meta_key) )
     2576        if ( empty( $metas ) ) {
     2577                if ( empty( $meta_key ) )
    25742578                        return array();
    25752579                else
    … …  
    25772581        }
    25782582
    2579         $metas = array_map('maybe_unserialize', (array)$metas);
    2580 
    2581         if ( 1 == count($metas) )
     2583        $metas = array_map( 'maybe_unserialize', (array)$metas );
     2584
     2585        if ( 1 == count( $metas ) )
    25822586                return $metas[0];
    25832587        else
    … …  
    25932597        $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
    25942598
    2595         if ( is_string($meta_value) )
    2596                 $meta_value = stripslashes($wpdb->escape($meta_value));
    2597 
    2598         $meta_value = maybe_serialize($meta_value);
    2599 
    2600         if (empty($meta_value)) {
     2599        if ( is_string( $meta_value ) )
     2600                $meta_value = stripslashes( $wpdb->escape( $meta_value ) );
     2601
     2602        $meta_value = maybe_serialize( $meta_value );
     2603
     2604        if ( empty( $meta_value ) )
    26012605                return groups_delete_groupmeta( $group_id, $meta_key );
    2602         }
    26032606
    26042607        $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
    26052608
    2606         if ( !$cur ) {
     2609        if ( !$cur )
    26072610                $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp->groups->table_name_groupmeta . " ( group_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $group_id, $meta_key, $meta_value ) );
    2608         } else if ( $cur->meta_value != $meta_value ) {
     2611        else if ( $cur->meta_value != $meta_value )
    26092612                $wpdb->query( $wpdb->prepare( "UPDATE " . $bp->groups->table_name_groupmeta . " SET meta_value = %s WHERE group_id = %d AND meta_key = %s", $meta_value, $group_id, $meta_key ) );
    2610         } else {
    2611                 return false;
    2612         }
    2613 
    2614         /* Update the cached object and recache */
     2613        else
     2614                return false;
     2615
     2616        // Update the cached object and recache
    26152617        wp_cache_set( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, $meta_value, 'bp' );
    26162618
    … …  
    26212623
    26222624function groups_remove_data_for_user( $user_id ) {
    2623         BP_Groups_Member::delete_all_for_user($user_id);
     2625        BP_Groups_Member::delete_all_for_user( $user_id );
    26242626
    26252627        do_action( 'groups_remove_data_for_user', $user_id );
    26262628}
    2627 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' );
    2628 add_action( 'delete_user', 'groups_remove_data_for_user' );
     2629add_action( 'wpmu_delete_user',  'groups_remove_data_for_user' );
     2630add_action( 'delete_user',       'groups_remove_data_for_user' );
    26292631add_action( 'bp_make_spam_user', 'groups_remove_data_for_user' );
    26302632
    … …  
    26402642        wp_cache_delete( 'bp_total_group_count', 'bp' );
    26412643}
    2642 add_action( 'groups_group_deleted', 'groups_clear_group_object_cache' );
    2643 add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' );
    2644 add_action( 'groups_details_updated', 'groups_clear_group_object_cache' );
    2645 add_action( 'groups_group_avatar_updated', 'groups_clear_group_object_cache' );
     2644add_action( 'groups_group_deleted',              'groups_clear_group_object_cache' );
     2645add_action( 'groups_settings_updated',           'groups_clear_group_object_cache' );
     2646add_action( 'groups_details_updated',            'groups_clear_group_object_cache' );
     2647add_action( 'groups_group_avatar_updated',       'groups_clear_group_object_cache' );
    26462648add_action( 'groups_create_group_step_complete', 'groups_clear_group_object_cache' );
    26472649
    … …  
    26492651        wp_cache_delete( 'bp_total_groups_for_user_' . $user_id );
    26502652}
    2651 add_action( 'groups_join_group', 'groups_clear_group_user_object_cache', 10, 2 );
    2652 add_action( 'groups_leave_group', 'groups_clear_group_user_object_cache', 10, 2 );
    2653 add_action( 'groups_ban_member', 'groups_clear_group_user_object_cache', 10, 2 );
     2653add_action( 'groups_join_group',   'groups_clear_group_user_object_cache', 10, 2 );
     2654add_action( 'groups_leave_group',  'groups_clear_group_user_object_cache', 10, 2 );
     2655add_action( 'groups_ban_member',   'groups_clear_group_user_object_cache', 10, 2 );
    26542656add_action( 'groups_unban_member', 'groups_clear_group_user_object_cache', 10, 2 );
    26552657
    26562658/* List actions to clear super cached pages on, if super cache is installed */
    2657 add_action( 'groups_join_group', 'bp_core_clear_cache' );
    2658 add_action( 'groups_leave_group', 'bp_core_clear_cache' );
    2659 add_action( 'groups_accept_invite', 'bp_core_clear_cache' );
    2660 add_action( 'groups_reject_invite', 'bp_core_clear_cache' );
    2661 add_action( 'groups_invite_user', 'bp_core_clear_cache' );
    2662 add_action( 'groups_uninvite_user', 'bp_core_clear_cache' );
    2663 add_action( 'groups_details_updated', 'bp_core_clear_cache' );
    2664 add_action( 'groups_settings_updated', 'bp_core_clear_cache' );
    2665 add_action( 'groups_unban_member', 'bp_core_clear_cache' );
    2666 add_action( 'groups_ban_member', 'bp_core_clear_cache' );
    2667 add_action( 'groups_demote_member', 'bp_core_clear_cache' );
    2668 add_action( 'groups_premote_member', 'bp_core_clear_cache' );
    2669 add_action( 'groups_membership_rejected', 'bp_core_clear_cache' );
    2670 add_action( 'groups_membership_accepted', 'bp_core_clear_cache' );
    2671 add_action( 'groups_membership_requested', 'bp_core_clear_cache' );
     2659add_action( 'groups_join_group',                 'bp_core_clear_cache' );
     2660add_action( 'groups_leave_group',                'bp_core_clear_cache' );
     2661add_action( 'groups_accept_invite',              'bp_core_clear_cache' );
     2662add_action( 'groups_reject_invite',              'bp_core_clear_cache' );
     2663add_action( 'groups_invite_user',                'bp_core_clear_cache' );
     2664add_action( 'groups_uninvite_user',              'bp_core_clear_cache' );
     2665add_action( 'groups_details_updated',            'bp_core_clear_cache' );
     2666add_action( 'groups_settings_updated',           'bp_core_clear_cache' );
     2667add_action( 'groups_unban_member',               'bp_core_clear_cache' );
     2668add_action( 'groups_ban_member',                 'bp_core_clear_cache' );
     2669add_action( 'groups_demote_member',              'bp_core_clear_cache' );
     2670add_action( 'groups_premote_member',             'bp_core_clear_cache' );
     2671add_action( 'groups_membership_rejected',        'bp_core_clear_cache' );
     2672add_action( 'groups_membership_accepted',        'bp_core_clear_cache' );
     2673add_action( 'groups_membership_requested',       'bp_core_clear_cache' );
    26722674add_action( 'groups_create_group_step_complete', 'bp_core_clear_cache' );
    2673 add_action( 'groups_created_group', 'bp_core_clear_cache' );
    2674 add_action( 'groups_group_avatar_updated', 'bp_core_clear_cache' );
     2675add_action( 'groups_created_group',              'bp_core_clear_cache' );
     2676add_action( 'groups_group_avatar_updated',       'bp_core_clear_cache' );
    26752677
    26762678?>
  • trunk/bp-groups/bp-groups-templatetags.php

    r3685 r3728  
    351351                        $group =& $groups_template->group;
    352352
    353                 return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/' );
     353                return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $group->slug . '/' );
    354354        }
    355355
    … …  
    363363                        $group =& $groups_template->group;
    364364
    365                 return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' );
     365                return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $group->slug . '/admin' );
    366366        }
    367367
    … …  
    548548        global $bp;
    549549
    550         if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug )
     550        if ( !$bp->is_single_item || !bp_is_current_component( $bp->groups->slug ) || $bp->current_action != $bp->activity->slug )
    551551                return false;
    552552
    … …  
    930930?>
    931931        <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?>
    932                 <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
     932                <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
    933933        <?php } ?>
    934934
    … …  
    937937                        return false;
    938938        ?>
    939         <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li>
    940         <li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li>
    941         <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li>
     939        <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li>
     940        <li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li>
     941        <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li>
    942942
    943943        <?php if ( $groups_template->group->status == 'private' ) : ?>
    944                 <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
     944                <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
    945945        <?php endif; ?>
    946946
    947947        <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
    948948
    949         <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
     949        <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
    950950<?php
    951951}
    … …  
    16201620                $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
    16211621
    1622                 <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/create/step/<?php echo $slug ?>/"><?php else: ?><span><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php else: ?></span><?php endif ?></li><?php
     1622                <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/create/step/<?php echo $slug ?>/"><?php else: ?><span><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php else: ?></span><?php endif ?></li><?php
    16231623                $counter++;
    16241624        }
    … …  
    16441644                        $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
    16451645
    1646                 return apply_filters( 'bp_get_group_creation_form_action', $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
     1646                return apply_filters( 'bp_get_group_creation_form_action', $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->action_variables[1] );
    16471647        }
    16481648
    … …  
    16511651
    16521652        /* Make sure we are in the groups component */
    1653         if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action )
     1653        if ( !bp_is_current_component( $bp->groups->slug ) || 'create' != $bp->current_action )
    16541654                return false;
    16551655
    … …  
    19301930        global $bp;
    19311931
    1932         if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
     1932        if ( !bp_is_current_component( $bp->groups->slug ) || 'admin' != $bp->current_action )
    19331933                return false;
    19341934
    … …  
    19471947
    19481948        if ( $bp->groups->current_group->avatar_full ) { ?>
     1949
    19491950                <img src="<?php echo esc_attr( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
     1951
    19501952        <?php } else { ?>
     1953
    19511954                <img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
     1955
    19521956        <?php }
    19531957}
    … …  
    20412045                        'next_text' => '&rarr;',
    20422046                        'mid_size' => 1
    2043                 ));
     2047                ) );
    20442048        }
    20452049
    … …  
    20602064        function rewind_requests() {
    20612065                $this->current_request = -1;
    2062                 if ( $this->request_count > 0 ) {
     2066
     2067                if ( $this->request_count > 0 )
    20632068                        $this->request = $this->requests[0];
    2064                 }
    20652069        }
    20662070
    … …  
    20952099                'group_id' => $groups_template->group->id,
    20962100                'per_page' => 10,
    2097                 'max' => false
     2101                'max'      => false
    20982102        );
    20992103
    … …  
    22022206        function rewind_invites() {
    22032207                $this->current_invite = -1;
    2204                 if ( $this->invite_count > 0 ) {
     2208                if ( $this->invite_count > 0 )
    22052209                        $this->invite = $this->invites[0];
    2206                 }
    22072210        }
    22082211
    … …  
    22472250
    22482251        if ( !$group_id ) {
    2249                 /* Backwards compatibility */
     2252                // Backwards compatibility
    22502253                if ( !empty( $bp->groups->current_group ) )
    22512254                        $group_id = $bp->groups->current_group->id;
     2255
    22522256                if ( !empty( $bp->groups->new_group_id ) )
    22532257                        $group_id = $bp->groups->new_group_id;
  • trunk/bp-loader.php

    r3713 r3728  
    3838        do_action( 'bp_core_loaded' );
    3939
    40         /* Activity Streams */
     40        // Activity Streams
    4141        if ( !isset( $bp_deactivated['bp-activity.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity.php') )
    4242                include( BP_PLUGIN_DIR . '/bp-activity.php' );
    4343
    44         /* Blog Tracking */
     44        // Blog Tracking
    4545        if ( !isset( $bp_deactivated['bp-blogs.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') )
    4646                include( BP_PLUGIN_DIR . '/bp-blogs.php' );
    4747
    48         /* bbPress Forum Integration */
     48        // bbPress Forum Integration
    4949        if ( !isset( $bp_deactivated['bp-forums.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums.php') )
    5050                include( BP_PLUGIN_DIR . '/bp-forums.php' );
    5151
    52         /* Friend Connections */
     52        // Friend Connections
    5353        if ( !isset( $bp_deactivated['bp-friends.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends.php') )
    5454                include( BP_PLUGIN_DIR . '/bp-friends.php' );
    5555
    56         /* Groups Support */
     56        // Groups Support
    5757        if ( !isset( $bp_deactivated['bp-groups.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups.php') )
    5858                include( BP_PLUGIN_DIR . '/bp-groups.php' );
    5959
    60         /* Private Messaging */
     60        // Private Messaging
    6161        if ( !isset( $bp_deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') )
    6262                include( BP_PLUGIN_DIR . '/bp-messages.php' );
    6363
    64         /* Extended Profiles */
     64        // Extended Profiles
    6565        if ( !isset( $bp_deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
    6666                include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
    … …  
    7070
    7171/**
    72 * bp_loaded()
    73 *
    74 * Allow dependent plugins and core actions to attach themselves in a safe way.
    75 *
    76 * See bp-core.php for the following core actions:
    77 *      - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets
    78 */
     72 * Allow dependent plugins and core actions to attach themselves in a safe way.
     73 *
     74 * See bp-core.php for the following core actions:
     75 *      - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets
     76 */
    7977function bp_loaded() {
    8078        do_action( 'bp_loaded' );
    … …  
    8280
    8381/**
    84  * bp_core_get_site_options()
    85  *
    8682 * BuddyPress uses site options to store configuration settings. Many of these settings are needed
    8783 * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
    … …  
    126122                $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
    127123
    128         $root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'";
    129 
     124        $root_blog_meta_keys  = "'" . implode( "','", (array)$root_blog_options ) ."'";
    130125        $root_blog_meta_table = $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'options';
    131         $root_blog_meta = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) );
     126        $root_blog_meta       = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) );
    132127
    133128        $site_options = array();
    … …  
    141136}
    142137
    143 /* Activation Function */
     138// Activation Function
    144139function bp_loader_activate() {
    145         /* Force refresh theme roots. */
     140        // Force refresh theme roots.
    146141        delete_site_transient( 'theme_roots' );
    147142
    148         /* Switch the user to the new bp-default if they are using the old bp-default on activation. */
     143        // Switch the user to the new bp-default if they are using the old
     144        // bp-default on activation.
    149145        if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) )
    150146                switch_theme( 'bp-default', 'bp-default' );
    … …  
    154150register_activation_hook( 'buddypress/bp-loader.php', 'bp_loader_activate' );
    155151
    156 /* Deactivation Function */
     152// Deactivation Function
    157153function bp_loader_deactivate() {
    158154        do_action( 'bp_loader_deactivate' );
  • trunk/bp-messages.php

    r3633 r3728  
    11<?php
    2 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php' );
    3 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php' );
     2
     3// Required Files
     4require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php'      );
     5require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php'        );
    46require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-templatetags.php' );
    5 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php' );
     7require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php'      );
    68
    79function messages_setup_globals() {
    … …  
    1416        $bp->messages->id = 'messages';
    1517
     18        // Slug
    1619        $bp->messages->slug = BP_MESSAGES_SLUG;
     20
     21        // Tables
    1722        $bp->messages->table_name_notices               = $bp->table_prefix . 'bp_messages_notices';
    1823        $bp->messages->table_name_messages              = $bp->table_prefix . 'bp_messages_messages';
    1924        $bp->messages->table_name_recipients    = $bp->table_prefix . 'bp_messages_recipients';
     25
     26        // Notifications
    2027        $bp->messages->format_notification_function = 'messages_format_notifications';
    2128
    … …  
    3845                $name = __('Messages <strong></strong>', 'buddypress');
    3946
    40         /* Add 'Messages' to the main navigation */
     47        // Add 'Messages' to the main navigation
    4148        bp_core_new_nav_item( array( 'name' => $name, 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) );
    4249
    4350        $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/';
    4451
    45         /* Add the subnav items to the profile */
     52        // Add the subnav items to the profile
    4653        bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ), 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_my_profile() ) );
    4754        bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) );
    … …  
    170177        global $bp;
    171178
    172         $new_messages = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true );
    173         if ( !$new_messages )
     179        if ( !$new_messages = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true ) )
    174180                $new_messages = 'yes';
    175181
    176         $new_notices = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true );
    177         if ( !$new_notices )
    178                 $new_notices = 'yes';
     182        if ( !$new_notices = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true ) )
     183                $new_notices  = 'yes';
    179184?>
     185
    180186        <table class="notification-settings zebra" id="messages-notification-settings">
    181187                <thead>
    … …  
    205211                </tbody>
    206212        </table>
     213
    207214<?php
    208215}
    … …  
    229236                bp_core_redirect( $bp->displayed_user->domain . $bp->current_component );
    230237
    231         /* Check if a new reply has been submitted */
     238        // Check if a new reply has been submitted
    232239        if ( isset( $_POST['send'] ) ) {
    233240
    234                 /* Check the nonce */
     241                // Check the nonce
    235242                check_admin_referer( 'messages_send_message', 'send_message_nonce' );
    236243
    237                 /* Send the reply */
     244                // Send the reply
    238245                if ( messages_new_message( array( 'thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) )
    239246                        bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
    … …  
    244251        }
    245252
    246         /* Mark message read */
     253        // Mark message read
    247254        messages_mark_thread_read( $thread_id );
    248255
    … …  
    268275                        return false;
    269276
    270                 // delete message
     277                // Delete message
    271278                if ( !messages_delete_thread($thread_id) ) {
    272279                        bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
    … …  
    293300                        return false;
    294301
    295                 if ( !messages_delete_thread( $thread_ids ) ) {
     302                if ( !messages_delete_thread( $thread_ids ) )
    296303                        bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' );
    297                 } else {
     304                else
    298305                        bp_core_add_message( __('Messages deleted.', 'buddypress') );
    299                 }
     306
    300307                bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
    301308        }
    … …  
    339346        global $bp;
    340347
    341         $defaults = array(
    342                 'thread_id' => false, // false for a new message, thread id for a reply to a thread.
    343                 'sender_id' => $bp->loggedin_user->id,
     348        $defaults = array (
     349                'sender_id'  => $bp->loggedin_user->id,
     350                'thread_id'  => false, // false for a new message, thread id for a reply to a thread.
    344351                'recipients' => false, // Can be an array of usernames, user_ids or mixed.
    345                 'subject' => false,
    346                 'content' => false,
    347                 'date_sent' => bp_core_current_time()
     352                'subject'    => false,
     353                'content'    => false,
     354                'date_sent'  => bp_core_current_time()
    348355        );
    349356
    … …  
    354361                return false;
    355362
    356         /* Create a new message object */
    357         $message = new BP_Messages_Message;
     363        // Create a new message object
     364        $message            = new BP_Messages_Message;
    358365        $message->thread_id = $thread_id;
    359366        $message->sender_id = $sender_id;
    360         $message->subject = $subject;
    361         $message->message = $content;
     367        $message->subject   = $subject;
     368        $message->message   = $content;
    362369        $message->date_sent = $date_sent;
    363370
    … …  
    382389                        $message->subject = __( 'No Subject', 'buddypress' );
    383390
    384                 /* Loop the recipients and convert all usernames to user_ids where needed */
     391                // Loop the recipients and convert all usernames to user_ids where needed
    385392                foreach( (array) $recipients as $recipient ) {
    386393                        if ( is_numeric( trim( $recipient ) ) )
    … …  
    391398                }
    392399
    393                 /* Strip the sender from the recipient list if they exist */
     400                // Strip the sender from the recipient list if they exist
    394401                if ( $key = array_search( $sender_id, (array)$recipient_ids ) )
    395402                        unset( $recipient_ids[$key] );
    396403
    397                 /* Remove duplicates */
     404                // Remove duplicates
    398405                $recipient_ids = array_unique( (array)$recipient_ids );
    399406
    … …  
    401408                        return false;
    402409
    403                 /* Format this to match existing recipients */
     410                // Format this to match existing recipients
    404411                foreach( (array)$recipient_ids as $i => $recipient_id ) {
    405412                        $message->recipients[$i] = new stdClass;
    … …  
    430437        if ( !is_super_admin() || empty( $subject ) || empty( $message ) ) {
    431438                return false;
     439
     440        // Has access to send notices, lets do it.
    432441        } else {
    433                 // Has access to send notices, lets do it.
    434                 $notice = new BP_Messages_Notice;
    435                 $notice->subject = $subject;
    436                 $notice->message = $message;
     442                $notice            = new BP_Messages_Notice;
     443                $notice->subject   = $subject;
     444                $notice->message   = $message;
    437445                $notice->date_sent = bp_core_current_time();
    438446                $notice->is_active = 1;
    … …  
    470478}
    471479
    472 function messages_check_thread_access( $thread_id, $user_id = false ) {
     480function messages_check_thread_access( $thread_id, $user_id = 0 ) {
    473481        global $bp;
    474482
    … …  
    499507}
    500508
    501 function messages_get_unread_count( $user_id = false ) {
     509function messages_get_unread_count( $user_id = 0 ) {
    502510        global $bp;
    503511
    … …  
    529537
    530538// List actions to clear super cached pages on, if super cache is installed
    531 add_action( 'messages_delete_thread', 'bp_core_clear_cache' );
    532 add_action( 'messages_send_notice', 'bp_core_clear_cache' );
    533 add_action( 'messages_message_sent', 'bp_core_clear_cache' );
     539add_action( 'messages_delete_thread',  'bp_core_clear_cache' );
     540add_action( 'messages_send_notice',    'bp_core_clear_cache' );
     541add_action( 'messages_message_sent',   'bp_core_clear_cache' );
    534542
    535543// Don't cache message inbox/sentbox/compose as it's too problematic
    536544add_action( 'messages_screen_compose', 'bp_core_clear_cache' );
    537545add_action( 'messages_screen_sentbox', 'bp_core_clear_cache' );
    538 add_action( 'messages_screen_inbox', 'bp_core_clear_cache' );
     546add_action( 'messages_screen_inbox',   'bp_core_clear_cache' );
    539547
    540548?>
  • trunk/bp-themes/bp-default/groups/index.php

    r3460 r3728  
    55
    66                <form action="" method="post" id="groups-directory-form" class="dir-form">
    7                         <h3><?php _e( 'Groups Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> &nbsp;<a class="button" href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG . '/create/' ?>"><?php _e( 'Create a Group', 'buddypress' ) ?></a><?php endif; ?></h3>
     7                        <h3><?php _e( 'Groups Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> &nbsp;<a class="button" href="<?php echo bp_get_root_domain() . '/' . bp_get_root_slug() . '/create/' ?>"><?php _e( 'Create a Group', 'buddypress' ) ?></a><?php endif; ?></h3>
    88
    99                        <?php do_action( 'bp_before_directory_groups_content' ) ?>
  • trunk/bp-xprofile.php

    r3713 r3728  
    11<?php
    2 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php' );
    3 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php' );
    4 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-filters.php' );
     2
     3// Required files
     4require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php'       );
     5require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php'      );
     6require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-filters.php'      );
    57require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-templatetags.php' );
    6 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-cssjs.php' );
    7 
    8 /**
    9  * xprofile_setup_globals()
    10  *
     8require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-cssjs.php'        );
     9
     10/**
    1111 * Add the profile globals to the $bp global for use across the installation
    1212 *
    … …  
    2525                define ( 'BP_XPROFILE_SLUG', 'profile' );
    2626
    27         /* Assign the base group and fullname field names to constants to use in SQL statements */
     27        // Assign the base group and fullname field names to constants to use
     28        // in SQL statements
    2829        define ( 'BP_XPROFILE_BASE_GROUP_NAME', stripslashes( $bp->site_options['bp-xprofile-base-group-name'] ) );
    2930        define ( 'BP_XPROFILE_FULLNAME_FIELD_NAME', stripslashes( $bp->site_options['bp-xprofile-fullname-field-name'] ) );
    3031
    31         /* For internal identification */
     32        // For internal identification
    3233        $bp->profile->id = 'profile';
    3334
     35        // Slug
    3436        $bp->profile->slug = BP_XPROFILE_SLUG;
    3537
     38        // Tables
    3639        $bp->profile->table_name_data   = $bp->table_prefix . 'bp_xprofile_data';
    3740        $bp->profile->table_name_groups = $bp->table_prefix . 'bp_xprofile_groups';
    … …  
    3942        $bp->profile->table_name_meta   = $bp->table_prefix . 'bp_xprofile_meta';
    4043
     44        // Notifications
    4145        $bp->profile->format_notification_function = 'xprofile_format_notifications';
    4246
    43         /* Register this in the active components array */
     47        // Register this in the active components array
    4448        $bp->active_components[$bp->profile->slug] = $bp->profile->id;
    4549
    46         /* Set the support field type ids */
     50        // Set the support field type ids
    4751        $bp->profile->field_types = apply_filters( 'xprofile_field_types', array( 'textbox', 'textarea', 'radio', 'checkbox', 'selectbox', 'multiselectbox', 'datebox' ) );
    4852
    … …  
    5256
    5357/**
    54  * xprofile_add_admin_menu()
    55  *
    5658 * Creates the administration interface menus and checks to see if the DB
    5759 * tables are set up.
    … …  
    7375                return false;
    7476
    75         /* Add the administration tab under the "Site Admin" tab for site administrators */
     77        // Add the administration tab under the "Site Admin" tab for site administrators
    7678        add_submenu_page( 'bp-general-settings', __( 'Profile Field Setup', 'buddypress' ), __( 'Profile Field Setup', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
    7779}
    … …  
    7981
    8082/**
    81  * xprofile_setup_nav()
    82  *
    8383 * Sets up the navigation items for the xprofile component
    8484 *
    … …  
    9393        global $bp;
    9494
    95         /* Add 'Profile' to the main navigation */
     95        // Add 'Profile' to the main navigation
    9696        bp_core_new_nav_item( array( 'name' => __( 'Profile', 'buddypress' ), 'slug' => $bp->profile->slug, 'position' => 20, 'screen_function' => 'xprofile_screen_display_profile', 'default_subnav_slug' => 'public', 'item_css_id' => $bp->profile->id ) );
    9797
    9898        $profile_link = $bp->loggedin_user->domain . $bp->profile->slug . '/';
    9999
    100         /* Add the subnav items to the profile */
     100        // Add the subnav items to the profile
    101101        bp_core_new_subnav_item( array( 'name' => __( 'Public', 'buddypress' ), 'slug' => 'public', 'parent_url' => $profile_link, 'parent_slug' => $bp->profile->slug, 'screen_function' => 'xprofile_screen_display_profile', 'position' => 10 ) );
    102102        bp_core_new_subnav_item( array( 'name' => __( 'Edit Profile', 'buddypress' ), 'slug' => 'edit', 'parent_url' => $profile_link, 'parent_slug' => $bp->profile->slug, 'screen_function' => 'xprofile_screen_edit_profile', 'position' => 20 ) );
    … …  
    117117
    118118/**
    119  * xprofile_setup_adminbar_menu()
    120  *
    121119 * Adds an admin bar menu to any profile page providing site admin options for that user.
    122120 *
    … …  
    130128                return false;
    131129
    132         /* Don't show this menu to non site admins or if you're viewing your own profile */
     130        // Don't show this menu to non site admins or if you're viewing your own profile
    133131        if ( !is_super_admin() || bp_is_my_profile() )
    134                 return false;
    135         ?>
     132                return false; ?>
     133
    136134        <li id="bp-adminbar-adminoptions-menu">
    137135                <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
    … …  
    142140
    143141                        <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
     142
    144143                                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li>
     144
    145145                        <?php else : ?>
     146
    146147                                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>
     148
    147149                        <?php endif; ?>
    148150
    … …  
    150152
    151153                        <?php do_action( 'xprofile_adminbar_menu_items' ) ?>
     154
    152155                </ul>
    153156        </li>
     157
    154158        <?php
    155159}
    … …  
    165169
    166170/**
    167  * xprofile_screen_display_profile()
    168  *
    169171 * Handles the display of the profile page by loading the correct template file.
    170172 *
    … …  
    175177        global $bp;
    176178
    177         $new = '';
    178179        if ( isset( $_GET['new'] ) )
    179180                $new = $_GET['new'];
     181        else
     182                $new = '';
    180183
    181184        do_action( 'xprofile_screen_display_profile', $new );
    … …  
    184187
    185188/**
    186  * xprofile_screen_edit_profile()
    187  *
    188189 * Handles the display of the profile edit page by loading the correct template file.
    189190 * Also checks to make sure this can only be accessed for the logged in users profile.
    … …  
    199200                return false;
    200201
    201         /* Make sure a group is set. */
     202        // Make sure a group is set.
    202203        if ( empty( $bp->action_variables[1] ) )
    203204                bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/1' );
    204205
    205         /* Check the field group exists */
     206        // Check the field group exists
    206207        if ( !xprofile_get_field_group( $bp->action_variables[1] ) )
    207208                bp_core_redirect( $bp->root_domain );
    208209
    209         /* Check to see if any new information has been submitted */
     210        // Check to see if any new information has been submitted
    210211        if ( isset( $_POST['field_ids'] ) ) {
    211212
    212                 /* Check the nonce */
     213                // Check the nonce
    213214                check_admin_referer( 'bp_xprofile_edit' );
    214215
    215                 /* Check we have field ID's */
     216                // Check we have field ID's
    216217                if ( empty( $_POST['field_ids'] ) )
    217218                        bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' );
    218219
    219                 /* Explode the posted field IDs into an array so we know which fields have been submitted */
     220                // Explode the posted field IDs into an array so we know which
     221                // fields have been submitted
    220222                $posted_field_ids = explode( ',', $_POST['field_ids'] );
    221223
    222224                $is_required = array();
    223225
    224                 /* Loop through the posted fields formatting any datebox values then validate the field */
     226                // Loop through the posted fields formatting any datebox values
     227                // then validate the field
    225228                foreach ( (array)$posted_field_ids as $field_id ) {
    226229                        if ( !isset( $_POST['field_' . $field_id] ) ) {
    227230
    228231                                if ( !empty( $_POST['field_' . $field_id . '_day'] ) && is_numeric( $_POST['field_' . $field_id . '_day'] ) ) {
    229                                         /* Concatenate the values. */
    230                                         $date_value = $_POST['field_' . $field_id . '_day'] . ' ' .
    231                                                               $_POST['field_' . $field_id . '_month'] . ' ' .
    232                                                                   $_POST['field_' . $field_id . '_year'];
    233 
    234                                         /* Turn the concatenated value into a timestamp */
     232                                        // Concatenate the values
     233                                        $date_value =   $_POST['field_' . $field_id . '_day'] . ' ' .
     234                                                                        $_POST['field_' . $field_id . '_month'] . ' ' .
     235                                                                        $_POST['field_' . $field_id . '_year'];
     236
     237                                        // Turn the concatenated value into a timestamp
    235238                                        $_POST['field_' . $field_id] = strtotime( $date_value );
    236239                                }
    … …  
    246249                        bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' );
    247250                else {
    248                         /* Reset the errors var */
     251                        // Reset the errors var
    249252                        $errors = false;
    250253
    251                         /* Now we've checked for required fields, lets save the values. */
     254                        // Now we've checked for required fields, lets save the values.
    252255                        foreach ( (array)$posted_field_ids as $field_id ) {
    253256                               
    … …  
    266269                        do_action( 'xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors );
    267270
    268                         /* Set the feedback messages */
     271                        // Set the feedback messages
    269272                        if ( $errors )
    270273                                bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' );
    … …  
    272275                                bp_core_add_message( __( 'Changes saved.', 'buddypress' ) );
    273276
    274                         /* Redirect back to the edit screen to display the updates and message */
     277                        // Redirect back to the edit screen to display the updates and message
    275278                        bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' );
    276279                }
    … …  
    282285
    283286/**
    284  * xprofile_screen_change_avatar()
    285  *
    286287 * Handles the uploading and cropping of a user avatar. Displays the change avatar page.
    287288 *
    … …  
    300301        if ( !empty( $_FILES ) ) {
    301302
    302                 /* Check the nonce */
     303                // Check the nonce
    303304                check_admin_referer( 'bp_avatar_upload' );
    304305
    305                 /* Pass the file to the avatar upload handler */
     306                // Pass the file to the avatar upload handler
    306307                if ( bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ) ) {
    307308                        $bp->avatar_admin->step = 'crop-image';
    308309
    309                         /* Make sure we include the jQuery jCrop file for image cropping */
     310                        // Make sure we include the jQuery jCrop file for image cropping
    310311                        add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
    311312                }
    312313        }
    313314
    314         /* If the image cropping is done, crop the image and save a full/thumb version */
     315        // If the image cropping is done, crop the image and save a full/thumb version
    315316        if ( isset( $_POST['avatar-crop-submit'] ) ) {
    316317
    317                 /* Check the nonce */
     318                // Check the nonce
    318319                check_admin_referer( 'bp_avatar_cropstore' );
    319320
    … …  
    340341
    341342/**
    342  * xprofile_action_delete_avatar()
    343  *
    344343 * This function runs when an action is set for a screen:
    345344 * example.com/members/andy/profile/change-avatar/ [delete-avatar]
    … …  
    359358                return false;
    360359
    361         /* Check the nonce */
     360        // Check the nonce
    362361        check_admin_referer( 'bp_delete_avatar_link' );
    363362
    … …  
    387386                return false;
    388387
    389         /* Register the activity stream actions for this component */
    390         bp_activity_set_action( $bp->profile->id, 'new_member', __( 'New member registered', 'buddypress' ) );
    391         bp_activity_set_action( $bp->profile->id, 'updated_profile', __( 'Updated Profile', 'buddypress' ) );
     388        // Register the activity stream actions for this component
     389        bp_activity_set_action( $bp->profile->id, 'new_member',      __( 'New member registered', 'buddypress' ) );
     390        bp_activity_set_action( $bp->profile->id, 'updated_profile', __( 'Updated Profile',       'buddypress' ) );
    392391
    393392        do_action( 'xprofile_register_activity_actions' );
    … …  
    396395
    397396/**
    398  * xprofile_record_activity()
    399  *
    400397 * Records activity for the logged in user within the profile component so that
    401398 * it will show in the users activity stream (if installed)
    … …  
    412409                return false;
    413410
    414         $defaults = array(
    415                 'user_id' => $bp->loggedin_user->id,
    416                 'action' => '',
    417                 'content' => '',
    418                 'primary_link' => '',
    419                 'component' => $bp->profile->id,
    420                 'type' => false,
    421                 'item_id' => false,
     411        $defaults = array (
     412                'user_id'           => $bp->loggedin_user->id,
     413                'action'            => '',
     414                'content'           => '',
     415                'primary_link'      => '',
     416                'component'         => $bp->profile->id,
     417                'type'              => false,
     418                'item_id'           => false,
    422419                'secondary_item_id' => false,
    423                 'recorded_time' => bp_core_current_time(),
    424                 'hide_sitewide' => false
     420                'recorded_time'     => bp_core_current_time(),
     421                'hide_sitewide'     => false
    425422        );
    426423
    … …  
    432429
    433430/**
    434  * xprofile_delete_activity()
    435  *
    436431 * Deletes activity for a user within the profile component so that
    437432 * it will be removed from the users activity stream and sitewide stream (if installed)
    … …  
    446441
    447442        if ( function_exists('bp_activity_delete_by_item_id') ) {
    448                 extract($args);
     443                extract( $args );
    449444                bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component' => $bp->profile->id, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) );
    450445        }
    … …  
    475470        $defaults = array(
    476471                'field_group_id' => false,
    477                 'name' => false,
    478                 'description' => '',
    479                 'can_delete' => true
     472                'name'           => false,
     473                'description'    => '',
     474                'can_delete'     => true
    480475        );
    481476
    … …  
    486481                return false;
    487482
    488         $field_group = new BP_XProfile_Group( $field_group_id );
    489         $field_group->name = $name;
     483        $field_group              = new BP_XProfile_Group( $field_group_id );
     484        $field_group->name        = $name;
    490485        $field_group->description = $description;
    491         $field_group->can_delete = $can_delete;
     486        $field_group->can_delete  = $can_delete;
    492487
    493488        return $field_group->save();
    … …  
    536531         */
    537532
    538         /* Check we have the minimum details */
     533        // Check we have the minimum details
    539534        if ( !$field_group_id )
    540535                return false;
    541536
    542         /* Check this is a valid field type */
     537        // Check this is a valid field type
    543538        if ( !in_array( $type, (array) $bp->profile->field_types ) )
    544539                return false;
    545540
    546         /* Instantiate a new field object */
     541        // Instantiate a new field object
    547542        if ( $field_id )
    548543                $field = new BP_XProfile_Field( $field_id );
    … …  
    601596
    602597/**
    603  * xprofile_get_field_data()
    604  *
    605598 * Fetches profile data for a specific field for the user.
    606599 *
    … …  
    615608 * @return mixed The profile field data.
    616609 */
    617 function xprofile_get_field_data( $field, $user_id = null ) {
     610function xprofile_get_field_data( $field, $user_id = 0 ) {
    618611        global $bp;
    619612
    … …  
    622615                xprofile_setup_globals();
    623616
    624         if ( !$user_id )
     617        if ( empty( $user_id ) )
    625618                $user_id = $bp->displayed_user->id;
    626619
    627         if ( !$user_id )
     620        if ( empty( $user_id ) )
    628621                return false;
    629622
    … …  
    633626                $field_id = xprofile_get_field_id_from_name( $field );
    634627
    635         if ( !$field_id )
     628        if ( empty( $field_id ) )
    636629                return false;
    637630
    … …  
    651644
    652645/**
    653  * xprofile_set_field_data()
    654  *
    655646 * A simple function to set profile data for a specific field for a specific user.
    656647 *
    … …  
    669660                $field_id = xprofile_get_field_id_from_name( $field );
    670661
    671         if ( !$field_id )
     662        if ( empty( $field_id ) )
    672663                return false;
    673664
    … …  
    684675        }
    685676
    686         /* Check the value is an acceptable value */
     677        // Check the value is an acceptable value
    687678        if ( 'checkbox' == $field->type || 'radio' == $field->type || 'selectbox' == $field->type || 'multiselectbox' == $field->type ) {
    688679                $options = $field->get_children();
    … …  
    697688                        }
    698689
    699                         /* Reset the keys by merging with an empty array */
     690                        // Reset the keys by merging with an empty array
    700691                        $value = array_merge( array(), $value );
    701692                } else {
    … …  
    705696        }
    706697
    707         $field = new BP_XProfile_ProfileData();
     698        $field           = new BP_XProfile_ProfileData();
    708699        $field->field_id = $field_id;
    709         $field->user_id = $user_id;
    710         $field->value = maybe_serialize( $value );
     700        $field->user_id  = $user_id;
     701        $field->value    = maybe_serialize( $value );
    711702
    712703        return $field->save();
    … …  
    736727
    737728/**
    738  * xprofile_get_field_id_from_name()
    739  *
    740729 * Returns the ID for the field based on the field name.
    741730 *
    … …  
    749738
    750739/**
    751  * xprofile_get_random_profile_data()
    752  *
    753740 * Fetches a random piece of profile data for the user.
    754741 *
    … …  
    763750 */
    764751function xprofile_get_random_profile_data( $user_id, $exclude_fullname = true ) {
    765         $field_data = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname );
     752        $field_data           = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname );
    766753        $field_data[0]->value = xprofile_format_profile_field( $field_data[0]->type, $field_data[0]->value );
    767754
    … …  
    773760
    774761/**
    775  * xprofile_format_profile_field()
    776  *
    777762 * Formats a profile field according to its type. [ TODO: Should really be moved to filters ]
    778763 *
    … …  
    784769 */
    785770function xprofile_format_profile_field( $field_type, $field_value ) {
    786         if ( !isset($field_value) || empty( $field_value ) )
     771        if ( !isset( $field_value ) || empty( $field_value ) )
    787772                return false;
    788773
    … …  
    793778        } else {
    794779                $content = $field_value;
    795                 $field_value = str_replace(']]>', ']]&gt;', $content);
     780                $field_value = str_replace( ']]>', ']]&gt;', $content );
    796781        }
    797782
    … …  
    804789
    805790/**
    806  * xprofile_avatar_upload_dir()
    807  *
    808791 * Setup the avatar upload directory for a user.
    809792 *
    … …  
    813796 * @return array() containing the path and URL plus some other settings.
    814797 */
    815 function xprofile_avatar_upload_dir( $directory = false, $user_id = false ) {
    816         global $bp;
    817 
    818         if ( !$user_id )
     798function xprofile_avatar_upload_dir( $directory = false, $user_id = 0 ) {
     799        global $bp;
     800
     801        if ( empty( $user_id ) )
    819802                $user_id = $bp->displayed_user->id;
    820803
    821         if ( !$directory )
     804        if ( empty( $directory ) )
    822805                $directory = 'avatars';
    823806
    824         $path  = BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user_id;
     807        $path    = BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user_id;
    825808        $newbdir = $path;
    826809
    … …  
    828811                @wp_mkdir_p( $path );
    829812
    830         $newurl  = BP_AVATAR_URL . '/avatars/' . $user_id;
    831         $newburl = $newurl;
     813        $newurl    = BP_AVATAR_URL . '/avatars/' . $user_id;
     814        $newburl   = $newurl;
    832815        $newsubdir = '/avatars/' . $user_id;
    833816
    … …  
    836819
    837820/**
    838  * xprofile_sync_wp_profile()
    839  *
    840821 * Syncs Xprofile data to the standard built in WordPress profile data.
    841822 *
    842823 * @package BuddyPress Core
    843824 */
    844 function xprofile_sync_wp_profile( $user_id = false ) {
     825function xprofile_sync_wp_profile( $user_id = 0 ) {
    845826        global $bp, $wpdb;
    846827
    … …  
    862843        } else {
    863844                $firstname = substr( $fullname, 0, $space );
    864                 $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    865         }
    866 
    867         update_user_meta( $user_id, 'nickname', $fullname );
     845                $lastname = trim( substr( $fullname, $space, strlen( $fullname ) ) );
     846        }
     847
     848        update_user_meta( $user_id, 'nickname',   $fullname );
    868849        update_user_meta( $user_id, 'first_name', $firstname );
    869         update_user_meta( $user_id, 'last_name', $lastname );
     850        update_user_meta( $user_id, 'last_name',  $lastname );
    870851
    871852        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
    … …  
    876857
    877858
    878 /* xprofile_sync_bp_profile()
    879  *
     859/**
    880860 * Syncs the standard built in WordPress profile data to XProfile.
    881861 *
    … …  
    895875
    896876/**
    897  * xprofile_remove_data_on_user_deletion()
    898  *
    899877 * When a user is deleted, we need to clean up the database and remove all the
    900878 * profile data from each table. Also we need to clean anything up in the usermeta table
    … …  
    915893
    916894        // unset the usermeta for avatars from the usermeta table.
    917         delete_user_meta( $user_id, 'bp_core_avatar_v1' );
     895        delete_user_meta( $user_id, 'bp_core_avatar_v1'      );
    918896        delete_user_meta( $user_id, 'bp_core_avatar_v1_path' );
    919         delete_user_meta( $user_id, 'bp_core_avatar_v2' );
     897        delete_user_meta( $user_id, 'bp_core_avatar_v2'      );
    920898        delete_user_meta( $user_id, 'bp_core_avatar_v2_path' );
    921899}
    922 add_action( 'wpmu_delete_user', 'xprofile_remove_data' );
    923 add_action( 'delete_user', 'xprofile_remove_data' );
     900add_action( 'wpmu_delete_user',  'xprofile_remove_data' );
     901add_action( 'delete_user',       'xprofile_remove_data' );
    924902add_action( 'bp_make_spam_user', 'xprofile_remove_data' );
    925903
    … …  
    10711049// List actions to clear object caches on
    10721050add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' );
    1073 add_action( 'xprofile_groups_saved_group', 'xprofile_clear_profile_groups_object_cache' );
    1074 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' );
     1051add_action( 'xprofile_groups_saved_group',   'xprofile_clear_profile_groups_object_cache' );
     1052add_action( 'xprofile_updated_profile',      'xprofile_clear_profile_data_object_cache'  );
    10751053
    10761054// List actions to clear super cached pages on, if super cache is installed
Note: See TracChangeset for help on using the changeset viewer.