Skip to:
Content

BuddyPress.org

Changeset 10356


Ignore:
Timestamp:
11/15/2015 07:57:03 PM (5 years ago)
Author:
tw2113
Message:

[Samus Aran]
I first battled the documentation inconsistencies on planet Zebes. It was there that I foiled the plans of the
Space Pirate leader Mother Brain to use the issues to attack galactic civilization...

I next fought the inconsistencies on their homeworld SR388. I completely eradicated them except for an @since tag,
which after hatching followed me like a confused child...

I personally delivered it to the Galactic Research Station at Ceres so scientists could study its energy production qualities...

The scientists' findings were astounding! They discovered that the powers of the docs inconsistencies
might be harnessed for the good of galactic civilization!

Satisfied that all was well, I left the station to seek a new bounty to hunt. But, I had hardly gone beyond the asteroid
belt when I picked up a distress signal!

Ceres station was under attack!

More documentation cleanup for part of BP-Core component.

See #6398.

Location:
trunk/src/bp-core
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-actions.php

    r10153 r10356  
    4444
    4545/**
    46  * bp_loaded - Attached to 'plugins_loaded' above.
     46 * The bp_loaded hook - Attached to 'plugins_loaded' above.
    4747 *
    4848 * Attach various loader actions to the bp_loaded action.
     
    5959
    6060/**
    61  * bp_init - Attached to 'init' above.
     61 * The bp_init hook - Attached to 'init' above.
    6262 *
    6363 * Attach various initialization actions to the bp_init action.
     
    7777
    7878/**
    79  * bp_template_redirect - Attached to 'template_redirect' above.
     79 * The bp_template_redirect hook - Attached to 'template_redirect' above.
    8080 *
    8181 * Attach various template actions to the bp_template_redirect action.
  • trunk/src/bp-core/bp-core-admin.php

    r10318 r10356  
    1717 * @package BuddyPress
    1818 * @subpackage CoreAdministration
    19  * @todo Break this apart into each applicable Component
     19 * @todo Break this apart into each applicable Component.
    2020 *
    2121 * @since 1.6.0
     
    9797
    9898        // Paths and URLs
    99         $this->admin_dir  = trailingslashit( $bp->plugin_dir  . 'bp-core/admin' ); // Admin path
    100         $this->admin_url  = trailingslashit( $bp->plugin_url  . 'bp-core/admin' ); // Admin url
    101         $this->images_url = trailingslashit( $this->admin_url . 'images'        ); // Admin images URL
    102         $this->css_url    = trailingslashit( $this->admin_url . 'css'           ); // Admin css URL
    103         $this->js_url     = trailingslashit( $this->admin_url . 'js'            ); // Admin css URL
    104 
    105         // Main settings page
     99        $this->admin_dir  = trailingslashit( $bp->plugin_dir  . 'bp-core/admin' ); // Admin path.
     100        $this->admin_url  = trailingslashit( $bp->plugin_url  . 'bp-core/admin' ); // Admin url.
     101        $this->images_url = trailingslashit( $this->admin_url . 'images'        ); // Admin images URL.
     102        $this->css_url    = trailingslashit( $this->admin_url . 'css'           ); // Admin css URL.
     103        $this->js_url     = trailingslashit( $this->admin_url . 'js'            ); // Admin css URL.
     104
     105        // Main settings page.
    106106        $this->settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
    107107
    108         // Main capability
     108        // Main capability.
    109109        $this->capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options';
    110110    }
     
    134134    private function setup_actions() {
    135135
    136         /** General Actions ***************************************************/
    137 
    138         // Add some page specific output to the <head>
     136        /* General Actions ***************************************************/
     137
     138        // Add some page specific output to the <head>.
    139139        add_action( 'bp_admin_head',            array( $this, 'admin_head'  ), 999 );
    140140
    141         // Add menu item to settings menu
     141        // Add menu item to settings menu.
    142142        add_action( bp_core_admin_hook(),       array( $this, 'admin_menus' ), 5 );
    143143
    144         // Enqueue all admin JS and CSS
     144        // Enqueue all admin JS and CSS.
    145145        add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    146146
    147         /** BuddyPress Actions ************************************************/
    148 
    149         // Load the BuddyPress metabox in the WP Nav Menu Admin UI
     147        /* BuddyPress Actions ************************************************/
     148
     149        // Load the BuddyPress metabox in the WP Nav Menu Admin UI.
    150150        add_action( 'load-nav-menus.php', 'bp_admin_wp_nav_menu_meta_box' );
    151151
    152         // Add settings
     152        // Add settings.
    153153        add_action( 'bp_register_admin_settings', array( $this, 'register_admin_settings' ) );
    154154
    155         // Add a link to BuddyPress About page to the admin bar
     155        // Add a link to BuddyPress About page to the admin bar.
    156156        add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 15 );
    157157
    158         // Add a description of new BuddyPress tools in the available tools page
     158        // Add a description of new BuddyPress tools in the available tools page.
    159159        add_action( 'tool_box',            'bp_core_admin_available_tools_intro' );
    160160        add_action( 'bp_network_tool_box', 'bp_core_admin_available_tools_intro' );
    161161
    162         // On non-multisite, catch
     162        // On non-multisite, catch.
    163163        add_action( 'load-users.php', 'bp_core_admin_user_manage_spammers' );
    164164
    165         /** Filters ***********************************************************/
    166 
    167         // Add link to settings page
     165        /* Filters ***********************************************************/
     166
     167        // Add link to settings page.
    168168        add_filter( 'plugin_action_links',               array( $this, 'modify_plugin_action_links' ), 10, 2 );
    169169        add_filter( 'network_admin_plugin_action_links', array( $this, 'modify_plugin_action_links' ), 10, 2 );
    170170
    171         // Add "Mark as Spam" row actions on users.php
     171        // Add "Mark as Spam" row actions on users.php.
    172172        add_filter( 'ms_user_row_actions', 'bp_core_admin_user_row_actions', 10, 2 );
    173173        add_filter( 'user_row_actions',    'bp_core_admin_user_row_actions', 10, 2 );
     
    185185    public function admin_menus() {
    186186
    187         // Bail if user cannot moderate
     187        // Bail if user cannot moderate.
    188188        if ( ! bp_current_user_can( 'manage_options' ) ) {
    189189            return;
    190190        }
    191191
    192         // About
     192        // About.
    193193        add_dashboard_page(
    194194            __( 'Welcome to BuddyPress',  'buddypress' ),
     
    199199        );
    200200
    201         // Credits
     201        // Credits.
    202202        add_dashboard_page(
    203203            __( 'Welcome to BuddyPress',  'buddypress' ),
     
    210210        $hooks = array();
    211211
    212         // Changed in BP 1.6 . See bp_core_admin_backpat_menu()
     212        // Changed in BP 1.6 . See bp_core_admin_backpat_menu().
    213213        $hooks[] = add_menu_page(
    214214            __( 'BuddyPress', 'buddypress' ),
     
    229229        );
    230230
    231         // Add the option pages
     231        // Add the option pages.
    232232        $hooks[] = add_submenu_page(
    233233            $this->settings_page,
     
    258258
    259259        // For consistency with non-Multisite, we add a Tools menu in
    260         // the Network Admin as a home for our Tools panel
     260        // the Network Admin as a home for our Tools panel.
    261261        if ( is_multisite() && bp_core_do_network_admin() ) {
    262262            $tools_parent = 'network-tools';
     
    269269                'bp_core_tools_top_level_item',
    270270                '',
    271                 24 // just above Settings
     271                24 // Just above Settings.
    272272            );
    273273
     
    293293        );
    294294
    295         // Fudge the highlighted subnav item when on a BuddyPress admin page
     295        // Fudge the highlighted subnav item when on a BuddyPress admin page.
    296296        foreach( $hooks as $hook ) {
    297297            add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
     
    310310    public function register_admin_settings() {
    311311
    312         /** Main Section ******************************************************/
    313 
    314         // Add the main section
     312        /* Main Section ******************************************************/
     313
     314        // Add the main section.
    315315        add_settings_section( 'bp_main', __( 'Main Settings', 'buddypress' ), 'bp_admin_setting_callback_main_section', 'buddypress' );
    316316
    317         // Hide toolbar for logged out users setting
     317        // Hide toolbar for logged out users setting.
    318318        add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' );
    319319        register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' );
    320320
    321         // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade
     321        // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade.
    322322        if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) {
    323323            add_settings_field( '_bp_force_buddybar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_force_buddybar', 'buddypress', 'bp_main' );
     
    325325        }
    326326
    327         // Allow account deletion
     327        // Allow account deletion.
    328328        add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
    329329        register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
    330330
    331         /** XProfile Section **************************************************/
     331        /* XProfile Section **************************************************/
    332332
    333333        if ( bp_is_active( 'xprofile' ) ) {
    334334
    335             // Add the main section
     335            // Add the main section.
    336336            add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
    337337
    338             // Avatars
     338            // Avatars.
    339339            add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' );
    340340            register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
    341341
    342             // Cover images
     342            // Cover images.
    343343            if ( bp_is_active( 'xprofile', 'cover_image' ) ) {
    344344                add_settings_field( 'bp-disable-cover-image-uploads', __( 'Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_cover_image_uploads', 'buddypress', 'bp_xprofile' );
     
    346346            }
    347347
    348             // Profile sync setting
     348            // Profile sync setting.
    349349            add_settings_field( 'bp-disable-profile-sync',   __( 'Profile Syncing',  'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' );
    350350            register_setting  ( 'buddypress', 'bp-disable-profile-sync', 'intval' );
    351351        }
    352352
    353         /** Groups Section ****************************************************/
     353        /* Groups Section ****************************************************/
    354354
    355355        if ( bp_is_active( 'groups' ) ) {
    356356
    357             // Add the main section
     357            // Add the main section.
    358358            add_settings_section( 'bp_groups', __( 'Groups Settings',  'buddypress' ), 'bp_admin_setting_callback_groups_section', 'buddypress' );
    359359
    360             // Allow subscriptions setting
     360            // Allow subscriptions setting.
    361361            add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation', 'buddypress' ), 'bp_admin_setting_callback_group_creation',   'buddypress', 'bp_groups' );
    362362            register_setting( 'buddypress', 'bp_restrict_group_creation', 'intval' );
     
    373373        }
    374374
    375         /** Forums ************************************************************/
     375        /* Forums ************************************************************/
    376376
    377377        if ( bp_is_active( 'forums' ) ) {
    378378
    379             // Add the main section
     379            // Add the main section.
    380380            add_settings_section( 'bp_forums', __( 'Legacy Group Forums', 'buddypress' ), 'bp_admin_setting_callback_bbpress_section', 'buddypress' );
    381381
    382             // Allow subscriptions setting
     382            // Allow subscriptions setting.
    383383            add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' );
    384384            register_setting( 'buddypress', 'bb-config-location', '' );
    385385        }
    386386
    387         /** Activity Section **************************************************/
     387        /* Activity Section **************************************************/
    388388
    389389        if ( bp_is_active( 'activity' ) ) {
    390390
    391             // Add the main section
     391            // Add the main section.
    392392            add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' );
    393393
    394             // Activity commenting on blog and forum posts
     394            // Activity commenting on blog and forum posts.
    395395            add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog &amp; Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' );
    396396            register_setting( 'buddypress', 'bp-disable-blogforum-comments', 'bp_admin_sanitize_callback_blogforum_comments' );
    397397
    398             // Activity Heartbeat refresh
     398            // Activity Heartbeat refresh.
    399399            add_settings_field( '_bp_enable_heartbeat_refresh', __( 'Activity auto-refresh', 'buddypress' ), 'bp_admin_setting_callback_heartbeat', 'buddypress', 'bp_activity' );
    400400            register_setting( 'buddypress', '_bp_enable_heartbeat_refresh', 'intval' );
    401401
    402             // Allow activity akismet
     402            // Allow activity akismet.
    403403            if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) {
    404404                add_settings_field( '_bp_enable_akismet', __( 'Akismet', 'buddypress' ), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity' );
     
    433433     * @param array  $links Links array in which we would prepend our link.
    434434     * @param string $file  Current plugin basename.
    435      *
    436435     * @return array Processed links.
    437436     */
    438437    public function modify_plugin_action_links( $links, $file ) {
    439438
    440         // Return normal links if not BuddyPress
     439        // Return normal links if not BuddyPress.
    441440        if ( plugin_basename( buddypress()->basename ) != $file ) {
    442441            return $links;
    443442        }
    444443
    445         // Add a few links to the existing links array
     444        // Add a few links to the existing links array.
    446445        return array_merge( $links, array(
    447446            'settings' => '<a href="' . esc_url( add_query_arg( array( 'page' => 'bp-components' ), bp_get_admin_url( $this->settings_page ) ) ) . '">' . esc_html__( 'Settings', 'buddypress' ) . '</a>',
     
    457456    public function admin_head() {
    458457
    459         // Settings pages
     458        // Settings pages.
    460459        remove_submenu_page( $this->settings_page, 'bp-page-settings' );
    461460        remove_submenu_page( $this->settings_page, 'bp-settings'      );
    462461
    463         // Network Admin Tools
     462        // Network Admin Tools.
    464463        remove_submenu_page( 'network-tools', 'network-tools' );
    465464
    466         // About and Credits pages
     465        // About and Credits pages.
    467466        remove_submenu_page( 'index.php', 'bp-about'   );
    468467        remove_submenu_page( 'index.php', 'bp-credits' );
     
    797796    public static function welcome_text() {
    798797
    799         // Switch welcome text based on whether this is a new installation or not
     798        // Switch welcome text based on whether this is a new installation or not.
    800799        $welcome_text = ( self::is_new_install() )
    801800            ? __( 'Thank you for installing BuddyPress! BuddyPress helps you run any kind of social network on your WordPress, with member profiles, activity streams, user groups, messaging, and more.', 'buddypress' )
     
    825824     *
    826825     * @since 2.2.0
    827      * @param string $tab
     826     *
     827     * @param string $tab Tab to highlight as active.
    828828     */
    829829    public static function tab_navigation( $tab = 'whats_new' ) {
     
    865865    public static function display_version() {
    866866
    867         // Use static variable to prevent recalculations
     867        // Use static variable to prevent recalculations.
    868868        static $display = '';
    869869
    870         // Only calculate on first run
     870        // Only calculate on first run.
    871871        if ( '' === $display ) {
    872872
    873             // Get current version
     873            // Get current version.
    874874            $version = bp_get_version();
    875875
    876             // Check for prerelease hyphen
     876            // Check for prerelease hyphen.
    877877            $pre     = strpos( $version, '-' );
    878878
    879             // Strip prerelease suffix
     879            // Strip prerelease suffix.
    880880            $display = ( false !== $pre )
    881881                ? substr( $version, 0, $pre )
     
    887887    }
    888888}
    889 endif; // class_exists check
     889endif; // End class_exists check.
    890890
    891891/**
     
    902902
    903903    // These are strings we may use to describe maintenance/security releases, where we aim for no new strings.
    904 
    905904    _n_noop( 'Maintenance Release', 'Maintenance Releases', 'buddypress' );
    906905    _n_noop( 'Security Release', 'Security Releases', 'buddypress' );
  • trunk/src/bp-core/bp-core-adminbar.php

    r10108 r10356  
    1717 * @since 1.6.0
    1818 *
    19  * @global WP_Admin_Bar $wp_admin_bar
     19 * @global WP_Admin_Bar $wp_admin_bar.
    2020 */
    2121function bp_admin_bar_my_account_root() {
    2222    global $wp_admin_bar;
    2323
    24     // Bail if this is an ajax request
     24    // Bail if this is an ajax request.
    2525    if ( !bp_use_wp_admin_bar() || defined( 'DOING_AJAX' ) )
    2626        return;
    2727
    28     // Only add menu for logged in user
     28    // Only add menu for logged in user.
    2929    if ( is_user_logged_in() ) {
    3030
    31         // Add secondary parent item for all BuddyPress components
     31        // Add secondary parent item for all BuddyPress components.
    3232        $wp_admin_bar->add_menu( array(
    3333            'parent'    => 'my-account',
     
    4040        ) );
    4141
    42         // Remove 'Edit' post link as it's not applicable to BP
    43         // Remove when https://core.trac.wordpress.org/ticket/29538 is addressed
     42        // Remove 'Edit' post link as it's not applicable to BP.
     43        // Remove when https://core.trac.wordpress.org/ticket/29538 is addressed.
    4444        if ( is_buddypress() ) {
    4545            $wp_admin_bar->remove_node( 'edit' );
     
    6969function bp_core_load_admin_bar() {
    7070
    71     // Show the Toolbar for logged out users
     71    // Show the Toolbar for logged out users.
    7272    if ( ! is_user_logged_in() && (int) bp_get_option( 'hide-loggedout-adminbar' ) != 1 ) {
    7373        show_admin_bar( true );
    7474    }
    7575
    76     // Hide the WordPress Toolbar and show the BuddyBar
     76    // Hide the WordPress Toolbar and show the BuddyBar.
    7777    if ( ! bp_use_wp_admin_bar() ) {
    7878        _doing_it_wrong( __FUNCTION__, __( 'The BuddyBar is no longer supported. Please migrate to the WordPress toolbar as soon as possible.', 'buddypress' ), '2.1.0' );
    7979
    80         // Keep the WP Toolbar from loading
     80        // Keep the WP Toolbar from loading.
    8181        show_admin_bar( false );
    8282
    83         // Actions used to build the BP Toolbar
     83        // Actions used to build the BP Toolbar.
    8484        add_action( 'bp_adminbar_logo',  'bp_adminbar_logo'               );
    8585        add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu',    2   );
     
    8888        add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu',   100 );
    8989
    90         // Actions used to append BP Toolbar to footer
     90        // Actions used to append BP Toolbar to footer.
    9191        add_action( 'wp_footer',    'bp_core_admin_bar', 8 );
    9292        add_action( 'admin_footer', 'bp_core_admin_bar'    );
     
    125125    }
    126126
    127     // Enqueue the additional adminbar css
     127    // Enqueue the additional adminbar css.
    128128    wp_enqueue_style( 'bp-admin-bar' );
    129129}
  • trunk/src/bp-core/bp-core-attachments.php

    r10193 r10356  
    1717 * match with our needs.
    1818 *
    19  * @since  2.3.0
     19 * @since 2.3.0
    2020 *
    2121 * @return bool True if WordPress is 3.9+, false otherwise.
     
    2626
    2727/**
    28  * Get the Attachments Uploads dir data
    29  *
    30  * @since  2.4.0
    31  *
    32  * @param  string        $data The data to get. Possible values are: 'dir', 'basedir' & 'baseurl'
    33  *                       Leave empty to get all datas.
    34  * @return string|array  The needed Upload dir data.
     28 * Get the Attachments Uploads dir data.
     29 *
     30 * @since 2.4.0
     31 *
     32 * @param string $data The data to get. Possible values are: 'dir', 'basedir' & 'baseurl'.
     33 *                     Leave empty to get all datas.
     34 * @return string|array The needed Upload dir data.
    3535 */
    3636function bp_attachments_uploads_dir_get( $data = '' ) {
     
    4343        $upload_data = bp_upload_dir();
    4444
    45         // Build the Upload data array for BuddyPress attachments
     45        // Build the Upload data array for BuddyPress attachments.
    4646        foreach ( $upload_data as $key => $value ) {
    4747            if ( 'basedir' === $key || 'baseurl' === $key ) {
     
    5252        }
    5353
    54         // Add the dir to the array
     54        // Add the dir to the array.
    5555        $upload_data['dir'] = $attachments_dir;
    5656
     
    6565     * Filter here to edit the Attachments upload dir data.
    6666     *
    67      * @since  2.4.0
    68      *
    69      * @param  string|array $retval      The needed Upload dir data or the full array of data
    70      * @param  string       $data        The data requested
     67     * @since 2.4.0
     68     *
     69     * @param string|array $retval The needed Upload dir data or the full array of data
     70     * @param string       $data   The data requested
    7171     */
    7272    return apply_filters( 'bp_attachments_uploads_dir_get', $retval, $data );
     
    7474
    7575/**
    76  * Get the max upload file size for any attachment
    77  *
    78  * @since  2.4.0
    79  *
    80  * @param  string $type A string to inform about the type of attachment
    81  *                      we wish to get the max upload file size for
    82  * @return int    max upload file size for any attachment
     76 * Get the max upload file size for any attachment.
     77 *
     78 * @since 2.4.0
     79 *
     80 * @param string $type A string to inform about the type of attachment
     81 *                     we wish to get the max upload file size for.
     82 * @return int Max upload file size for any attachment.
    8383 */
    8484function bp_attachments_get_max_upload_file_size( $type = '' ) {
     
    9494     * Filter here to edit the max upload file size.
    9595     *
    96      * @since  2.4.0
    97      *
    98      * @param  int    $fileupload_maxk Max upload file size for any attachment
    99      * @param  string $type            The attachment type (eg: 'avatar' or 'cover_image')
     96     * @since 2.4.0
     97     *
     98     * @param int    $fileupload_maxk Max upload file size for any attachment.
     99     * @param string $type            The attachment type (eg: 'avatar' or 'cover_image').
    100100     */
    101101    return apply_filters( 'bp_attachments_get_max_upload_file_size', $fileupload_maxk, $type );
     
    103103
    104104/**
    105  * Get allowed types for any attachment
    106  *
    107  * @since  2.4.0
    108  *
    109  * @param  string $type The extension types to get.
    110  *                       Default: 'avatar'
    111  * @return array         The list of allowed extensions for attachments
     105 * Get allowed types for any attachment.
     106 *
     107 * @since 2.4.0
     108 *
     109 * @param string $type The extension types to get.
     110 *                     Default: 'avatar'.
     111 * @return array The list of allowed extensions for attachments.
    112112 */
    113113function bp_attachments_get_allowed_types( $type = 'avatar' ) {
    114     // Defaults to BuddyPress supported image extensions
     114    // Defaults to BuddyPress supported image extensions.
    115115    $exts = array( 'jpeg', 'gif', 'png' );
    116116
    117117    /**
    118118     * It's not a BuddyPress feature, get the allowed extensions
    119      * matching the $type requested
     119     * matching the $type requested.
    120120     */
    121121    if ( 'avatar' !== $type && 'cover_image' !== $type ) {
    122         // Reset the default exts
     122        // Reset the default exts.
    123123        $exts = array();
    124124
     
    136136
    137137                /**
    138                  * Search for allowed mimes matching the type
     138                 * Search for allowed mimes matching the type.
    139139                 *
    140                  * eg: using 'application/vnd.oasis' as the $type
     140                 * Eg: using 'application/vnd.oasis' as the $type
    141141                 * parameter will get all OpenOffice extensions supported
    142142                 * by WordPress and allowed for the current user.
     
    148148                $allowed_types = array_keys( $allowed_mimes );
    149149
    150                 // Loop to explode keys using '|'
     150                // Loop to explode keys using '|'.
    151151                foreach ( $allowed_types as $allowed_type ) {
    152152                    $t = explode( '|', $allowed_type );
     
    160160     * Filter here to edit the allowed extensions by attachment type.
    161161     *
    162      * @since  2.4.0
    163      *
    164      * @param  array  $exts List of allowed extensions
    165      * @param  string $type The requested file type
     162     * @since 2.4.0
     163     *
     164     * @param array  $exts List of allowed extensions.
     165     * @param string $type The requested file type.
    166166     */
    167167    return apply_filters( 'bp_attachments_get_allowed_types', $exts, $type );
     
    173173 * @since 2.4.0
    174174 *
    175  * @param  string $type         The extension types to get (Optional).
    176  * @param  array $allowed_types List of allowed extensions
    177  * @return array                List of allowed mime types
     175 * @param string $type          The extension types to get (Optional).
     176 * @param array  $allowed_types List of allowed extensions.
     177 * @return array List of allowed mime types.
    178178 */
    179179function bp_attachments_get_allowed_mimes( $type = '', $allowed_types = array() ) {
     
    196196
    197197/**
    198  * Check the uploaded attachment type is allowed
    199  *
    200  * @since  2.4.0
    201  *
    202  * @param  string $file          Full path to the file.
    203  * @param  string $filename      The name of the file (may differ from $file due to $file being
    204  *                               in a tmp directory).
    205  * @param  array  $allowed_mimes The attachment allowed mimes (Required)
    206  * @return bool                  True if the attachment type is allowed. False otherwise
     198 * Check the uploaded attachment type is allowed.
     199 *
     200 * @since 2.4.0
     201 *
     202 * @param string $file          Full path to the file.
     203 * @param string $filename      The name of the file (may differ from $file due to $file being
     204 *                              in a tmp directory).
     205 * @param array  $allowed_mimes The attachment allowed mimes (Required).
     206 * @return bool True if the attachment type is allowed. False otherwise
    207207 */
    208208function bp_attachments_check_filetype( $file, $filename, $allowed_mimes ) {
     
    221221 * @since 2.4.0
    222222 *
    223  * @param  string $type        The attachment type to create (avatar or cover_image). Default: avatar.
    224  * @param  array  $args {
     223 * @param string $type The attachment type to create (avatar or cover_image). Default: avatar.
     224 * @param array  $args {
    225225 *     @type int    $item_id   The ID of the object (Required). Default: 0.
    226226 *     @type string $object    The object type (eg: group, user, blog) (Required). Default: 'user'.
     
    232232 *     @type int    $crop_y    The vertical starting point of the crop. Default: 0.
    233233 * }
    234  * @return bool  True on success, false otherwise.
     234 * @return bool True on success, false otherwise.
    235235 */
    236236function bp_attachments_create_item_type( $type = 'avatar', $args = array() ) {
     
    254254    }
    255255
    256     // Make sure the file path is safe
     256    // Make sure the file path is safe.
    257257    if ( 0 !== validate_file( $r['image'] ) ) {
    258258        return false;
    259259    }
    260260
    261     // Set the component if not already done
     261    // Set the component if not already done.
    262262    if ( empty( $r['component'] ) ) {
    263263        if ( 'user' === $r['object'] ) {
     
    277277    }
    278278
    279     // Init the Attachment data
     279    // Init the Attachment data.
    280280    $attachment_data = array();
    281281
    282282    if ( 'avatar' === $type ) {
    283         // Set crop width for the avatar if not given
     283        // Set crop width for the avatar if not given.
    284284        if ( empty( $r['crop_w'] ) ) {
    285285            $r['crop_w'] = bp_core_avatar_full_width();
    286286        }
    287287
    288         // Set crop height for the avatar if not given
     288        // Set crop height for the avatar if not given.
    289289        if ( empty( $r['crop_h'] ) ) {
    290290            $r['crop_h'] = bp_core_avatar_full_height();
     
    294294            $dir_args = array( $r['item_id'] );
    295295
    296             // In case  of xprofile, we need an extra argument
     296            // In case  of xprofile, we need an extra argument.
    297297            if ( 'xprofile' === $r['component'] ) {
    298298                $dir_args = array( false, $r['item_id'] );
     
    304304        $attachment_data = bp_attachments_uploads_dir_get();
    305305
    306         // Default to members for xProfile
     306        // Default to members for xProfile.
    307307        $object_subdir = 'members';
    308308
     
    311311        }
    312312
    313         // Set Subdir
     313        // Set Subdir.
    314314        $attachment_data['subdir'] = $object_subdir . '/' . $r['item_id'] . '/cover-image';
    315315
    316         // Set Path
     316        // Set Path.
    317317        $attachment_data['path'] = trailingslashit( $attachment_data['basedir'] ) . $attachment_data['subdir'];
    318318    }
     
    322322    }
    323323
    324     // It's not a regular upload, we may need to create some folders
     324    // It's not a regular upload, we may need to create some folders.
    325325    if ( ! is_dir( $attachment_data['path'] ) ) {
    326326        if ( ! wp_mkdir_p( $attachment_data['path'] ) ) {
     
    329329    }
    330330
    331     // Set the image name and path
     331    // Set the image name and path.
    332332    $image_file_name = wp_unique_filename( $attachment_data['path'], basename( $r['image'] ) );
    333333    $image_file_path = $attachment_data['path'] . '/' . $image_file_name;
    334334
    335     // Copy the image file into the avatar dir
     335    // Copy the image file into the avatar dir.
    336336    if ( ! copy( $r['image'], $image_file_path ) ) {
    337337        return false;
    338338    }
    339339
    340     // Init the response
     340    // Init the response.
    341341    $created = false;
    342342
     
    354354        ) );
    355355
    356     // It's a cover image we need to fit it to feature's dimensions
     356    // It's a cover image we need to fit it to feature's dimensions.
    357357    } elseif ( 'cover_image' === $type ) {
    358358        $cover_image = bp_attachments_cover_image_generate_file( array(
     
    365365    }
    366366
    367     // Remove copied file if it fails
     367    // Remove copied file if it fails.
    368368    if ( ! $created ) {
    369369        @unlink( $image_file_path );
    370370    }
    371371
    372     // Return the response
     372    // Return the response.
    373373    return $created;
    374374}
    375375
    376376/**
    377  * Get the url or the path for a type of attachment
    378  *
    379  * @since  2.4.0
    380  *
    381  * @param  string $data whether to get the url or the path
    382  * @param  array  $args {
     377 * Get the url or the path for a type of attachment.
     378 *
     379 * @since 2.4.0
     380 *
     381 * @param string $data whether to get the url or the path.
     382 * @param array  $args {
    383383 *     @type string $object_dir  The object dir (eg: members/groups). Defaults to members.
    384384 *     @type int    $item_id     The object id (eg: a user or a group id). Defaults to current user.
     
    387387 *     @type string $file        The name of the file.
    388388 * }
    389  * @return string|bool the url or the path to the attachment, false otherwise
     389 * @return string|bool The url or the path to the attachment, false otherwise
    390390 */
    391391function bp_attachments_get_attachment( $data = 'url', $args = array() ) {
    392     // Default value
     392    // Default value.
    393393    $attachment_data = false;
    394394
     
    400400    ), 'attachments_get_attachment_src' );
    401401
    402     // Get BuddyPress Attachments Uploads Dir datas
     402    // Get BuddyPress Attachments Uploads Dir datas.
    403403    $bp_attachments_uploads_dir = bp_attachments_uploads_dir_get();
    404404
     
    424424        $file = false;
    425425
    426         // Open the directory and get the first file
     426        // Open the directory and get the first file.
    427427        if ( $att_dir = opendir( $type_dir ) ) {
    428428
    429429            while ( false !== ( $attachment_file = readdir( $att_dir ) ) ) {
    430                 // Look for the first file having the type in its name
     430                // Look for the first file having the type in its name.
    431431                if ( false !== strpos( $attachment_file, $r['type'] ) && empty( $file ) ) {
    432432                    $file = $attachment_file;
     
    453453 * Delete an attachment for the given arguments
    454454 *
    455  * @since  2.4.0
    456  *
    457  * @param  array $args
    458  * @see    bp_attachments_get_attachment() For more information on accepted arguments.
    459  * @return bool True if the attachment was deleted, false otherwise
     455 * @since 2.4.0
     456 *
     457 * @see bp_attachments_get_attachment() For more information on accepted arguments.
     458 *
     459 * @param array $args Array of arguments for the attachment deletion.
     460 * @return bool True if the attachment was deleted, false otherwise.
    460461 */
    461462function bp_attachments_delete_file( $args = array() ) {
     
    473474 * Get the BuddyPress Plupload settings.
    474475 *
    475  * @since  2.3.0
    476  *
    477  * @return array list of BuddyPress Plupload settings.
     476 * @since 2.3.0
     477 *
     478 * @return array List of BuddyPress Plupload settings.
    478479 */
    479480function bp_attachments_get_plupload_default_settings() {
     
    523524     * @since 2.3.0
    524525     *
    525      * @param array $params Default Plupload parameters array.
     526     * @param array $settings Default Plupload parameters array.
    526527     */
    527528    return apply_filters( 'bp_attachments_get_plupload_default_settings', $settings );
     
    531532 * Builds localization strings for the BuddyPress Uploader scripts.
    532533 *
    533  * @since  2.3.0
     534 * @since 2.3.0
    534535 *
    535536 * @return array Plupload default localization strings.
    536537 */
    537538function bp_attachments_get_plupload_l10n() {
    538     // Localization strings
     539    // Localization strings.
    539540    return apply_filters( 'bp_attachments_get_plupload_l10n', array(
    540541            'queue_limit_exceeded'      => __( 'You have attempted to queue too many files.', 'buddypress' ),
     
    567568 * Enqueues the script needed for the Uploader UI.
    568569 *
    569  * @see  BP_Attachment::script_data() && BP_Attachment_Avatar::script_data() for examples showing how
     570 * @see BP_Attachment::script_data() && BP_Attachment_Avatar::script_data() for examples showing how
    570571 * to set specific script data.
    571572 *
    572  * @since  2.3.0
    573  *
    574  * @param  string $class name of the class extending BP_Attachment (eg: BP_Attachment_Avatar).
    575  *
     573 * @since 2.3.0
     574 *
     575 * @param string $class Name of the class extending BP_Attachment (eg: BP_Attachment_Avatar).
    576576 * @return null|WP_Error
    577577 */
     
    586586    }
    587587
    588     // Get an instance of the class and get the script data
     588    // Get an instance of the class and get the script data.
    589589    $attachment = new $class;
    590590    $script_data  = $attachment->script_data();
     
    607607    }
    608608
    609     // Get the BuddyPress uploader strings
     609    // Get the BuddyPress uploader strings.
    610610    $strings = bp_attachments_get_plupload_l10n();
    611611
    612     // Get the BuddyPress uploader settings
     612    // Get the BuddyPress uploader settings.
    613613    $settings = bp_attachments_get_plupload_default_settings();
    614614
    615     // Set feedback messages
     615    // Set feedback messages.
    616616    if ( ! empty( $args['feedback_messages'] ) ) {
    617617        $strings['feedback_messages'] = $args['feedback_messages'];
    618618    }
    619619
    620     // Use a temporary var to ease manipulation
     620    // Use a temporary var to ease manipulation.
    621621    $defaults = $settings['defaults'];
    622622
    623     // Set the upload action
     623    // Set the upload action.
    624624    $defaults['multipart_params']['action'] = $args['action'];
    625625
    626     // Set BuddyPress upload parameters if provided
     626    // Set BuddyPress upload parameters if provided.
    627627    if ( ! empty( $args['bp_params'] ) ) {
    628628        $defaults['multipart_params']['bp_params'] = $args['bp_params'];
    629629    }
    630630
    631     // Merge other arguments
     631    // Merge other arguments.
    632632    $ui_args = array_intersect_key( $args, array(
    633633        'file_data_name' => true,
     
    643643    }
    644644
    645     // Specific to BuddyPress Avatars
     645    // Specific to BuddyPress Avatars.
    646646    if ( 'bp_avatar_upload' === $defaults['multipart_params']['action'] ) {
    647647
    648         // Include the cropping informations for avatars
     648        // Include the cropping informations for avatars.
    649649        $settings['crop'] = array(
    650650            'full_h'  => bp_core_avatar_full_height(),
     
    655655        $defaults['multi_selection'] = false;
    656656
    657         // Does the object already has an avatar set
     657        // Does the object already has an avatar set.
    658658        $has_avatar = $defaults['multipart_params']['bp_params']['has_avatar'];
    659659
    660         // What is the object the avatar belongs to
     660        // What is the object the avatar belongs to.
    661661        $object = $defaults['multipart_params']['bp_params']['object'];
    662662
    663         // Init the Avatar nav
     663        // Init the Avatar nav.
    664664        $avatar_nav = array(
    665665            'upload' => array( 'id' => 'upload', 'caption' => __( 'Upload', 'buddypress' ), 'order' => 0  ),
    666666
    667             // The delete view will only show if the object has an avatar
     667            // The delete view will only show if the object has an avatar.
    668668            'delete' => array( 'id' => 'delete', 'caption' => __( 'Delete', 'buddypress' ), 'order' => 100, 'hide' => (int) ! $has_avatar ),
    669669        );
    670670
    671         // Create the Camera Nav if the WebCam capture feature is enabled
     671        // Create the Camera Nav if the WebCam capture feature is enabled.
    672672        if ( bp_avatar_use_webcam() && 'user' === $object ) {
    673673            $avatar_nav['camera'] = array( 'id' => 'camera', 'caption' => __( 'Take Photo', 'buddypress' ), 'order' => 10 );
    674674
    675             // Set warning messages
     675            // Set warning messages.
    676676            $strings['camera_warnings'] = array(
    677677                'requesting'  => __( 'Please allow us to access to your camera.', 'buddypress'),
     
    691691         * @since 2.3.0
    692692         *
    693          * @param array $avatar_nav An associative array of available nav items where each item is an array organized this way:
    694          * $avatar_nav[ $nav_item_id ] {
     693         * @param array  $avatar_nav {
     694         *     An associative array of available nav items where each item is an array organized this way:
     695         *     $avatar_nav[ $nav_item_id ].
    695696         *     @type string $nav_item_id The nav item id in lower case without special characters or space.
    696697         *     @type string $caption     The name of the item nav that will be displayed in the nav.
     
    700701         *                               (only used for the delete nav item).
    701702         * }
    702          * @param string $object the object the avatar belongs to (eg: user or group)
     703         * @param string $object The object the avatar belongs to (eg: user or group).
    703704         */
    704705        $settings['nav'] = bp_sort_by_key( apply_filters( 'bp_attachments_avatar_nav', $avatar_nav, $object ), 'order', 'num' );
    705706
    706     // Specific to BuddyPress cover images
     707    // Specific to BuddyPress cover images.
    707708    } elseif ( 'bp_cover_image_upload' === $defaults['multipart_params']['action'] ) {
    708709
     
    710711        $defaults['multi_selection'] = false;
    711712
    712         // Default cover component is xprofile
     713        // Default cover component is xprofile.
    713714        $cover_component = 'xprofile';
    714715
    715         // Get the object we're editing the cover image of
     716        // Get the object we're editing the cover image of.
    716717        $object = $defaults['multipart_params']['bp_params']['object'];
    717718
    718         // Set the cover component according to the object
     719        // Set the cover component according to the object.
    719720        if ( 'group' === $object ) {
    720721            $cover_component = 'groups';
     
    722723            $cover_component = apply_filters( 'bp_attachments_cover_image_ui_component', $cover_component );
    723724        }
    724         // Get cover image advised dimensions
     725        // Get cover image advised dimensions.
    725726        $cover_dimensions = bp_attachments_get_cover_image_dimensions( $cover_component );
    726727
    727         // Set warning messages
     728        // Set warning messages.
    728729        $strings['cover_image_warnings'] = apply_filters( 'bp_attachments_cover_image_ui_warnings', array(
    729730            'dimensions'  => sprintf(
     
    735736    }
    736737
    737     // Set Plupload settings
     738    // Set Plupload settings.
    738739    $settings['defaults'] = $defaults;
    739740
     
    783784 * Check the current user's capability to edit an avatar for a given object.
    784785 *
    785  * @since  2.3.0
    786  *
    787  * @param  string $capability The capability to check.
    788  * @param  array  $args       An array containing the item_id and the object to check.
    789  *
     786 * @since 2.3.0
     787 *
     788 * @param string $capability The capability to check.
     789 * @param array  $args       An array containing the item_id and the object to check.
    790790 * @return bool
    791791 */
     
    798798         */
    799799        if ( isset( $args['item_id'] ) && isset( $args['object'] ) ) {
    800             // Group profile photo
     800            // Group profile photo.
    801801            if ( bp_is_active( 'groups' ) && 'group' === $args['object'] ) {
    802802                if ( bp_is_group_create() ) {
     
    805805                    $can = (bool) groups_is_user_admin( bp_loggedin_user_id(), $args['item_id'] ) || bp_current_user_can( 'bp_moderate' );
    806806                }
    807             // User profile photo
     807            // User profile photo.
    808808            } elseif ( bp_is_active( 'xprofile' ) && 'user' === $args['object'] ) {
    809809                $can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can( 'bp_moderate' );
     
    828828 * Send a JSON response back to an Ajax upload request.
    829829 *
    830  * @since  2.3.0
    831  *
    832  * @param  bool  $success  True for a success, false otherwise.
    833  * @param  bool  $is_html4 True if the Plupload runtime used is html4, false otherwise.
    834  * @param  mixed $data     Data to encode as JSON, then print and die.
     830 * @since 2.3.0
     831 *
     832 * @param bool  $success  True for a success, false otherwise.
     833 * @param bool  $is_html4 True if the Plupload runtime used is html4, false otherwise.
     834 * @param mixed $data     Data to encode as JSON, then print and die.
    835835 */
    836836function bp_attachments_json_response( $success, $is_html4 = false, $data = null ) {
     
    841841    }
    842842
    843     // Send regular json response
     843    // Send regular json response.
    844844    if ( ! $is_html4 ) {
    845845        wp_send_json( $response );
     
    863863 *
    864864 * @param string $slug Template part slug. eg 'uploader' for 'uploader.php'.
    865  *
    866865 * @return bool
    867866 */
     
    892891 * Get the cover image settings
    893892 *
    894  * @since  2.4.0
    895  *
    896  * @param  string $component the component to get the settings for ("xprofile" for user or "groups")
    897  * @return array            the cover image settings
     893 * @since 2.4.0
     894 *
     895 * @param string $component The component to get the settings for ("xprofile" for user or "groups").
     896 * @return array The cover image settings.
    898897 */
    899898function bp_attachments_get_cover_image_settings( $component = 'xprofile' ) {
    900     // Default parameters
     899    // Default parameters.
    901900    $args = array();
    902901
    903     // First look in BP Theme Compat
     902    // First look in BP Theme Compat.
    904903    $cover_image = bp_get_theme_compat_feature( 'cover_image' );
    905904
     
    911910     * Then let people override/set the feature using this dynamic filter
    912911     *
    913      * eg: for the user's profile cover image use :
     912     * Eg: for the user's profile cover image use:
    914913     * add_filter( 'bp_before_xprofile_cover_image_settings_parse_args', 'your_filter', 10, 1 );
    915914     *
    916915     * @since  2.4.0
    917916     *
    918      * @param array $settings the cover image settings
     917     * @param array $settings The cover image settings
    919918     */
    920919    $settings = bp_parse_args( $args, array(
     
    931930    }
    932931
    933     // Current component is not supported
     932    // Current component is not supported.
    934933    if ( ! in_array( $component, $settings['components'] ) ) {
    935934        return false;
    936935    }
    937936
    938     // Finally return the settings
     937    // Finally return the settings.
    939938    return $settings;
    940939}
     
    943942 * Get cover image Width and Height
    944943 *
    945  * @since  2.4.0
    946  *
    947  * @param  string $component the BuddyPress component concerned ("xprofile" for user or "groups")
    948  * @return array             an associative array containing the advised width and height for the cover image
     944 * @since 2.4.0
     945 *
     946 * @param string $component The BuddyPress component concerned ("xprofile" for user or "groups").
     947 * @return array An associative array containing the advised width and height for the cover image.
    949948 */
    950949function bp_attachments_get_cover_image_dimensions( $component = 'xprofile' ) {
    951     // Let's prevent notices when setting the warning strings
     950    // Let's prevent notices when setting the warning strings.
    952951    $default = array( 'width' => 0, 'height' => 0 );
    953952
     
    958957    }
    959958
    960     // Get width and height
     959    // Get width and height.
    961960    $wh = array_intersect_key( $settings, $default );
    962961
     
    964963     * Filter here to edit the cover image dimensions if needed.
    965964     *
    966      * @since  2.4.0
    967      *
    968      * @param  array  $wh        an associative array containing the width and height values
    969      * @param  array  $settings  an associative array containing all the feature settings
    970      * @param  string $compnent  the requested component
     965     * @since 2.4.0
     966     *
     967     * @param array  $wh       An associative array containing the width and height values.
     968     * @param array  $settings An associative array containing all the feature settings.
     969     * @param string $compnent The requested component.
    971970     */
    972971    return apply_filters( 'bp_attachments_get_cover_image_dimensions', $wh, $settings, $component );
     
    974973
    975974/**
    976  * Are we on a page to edit a cover image ?
    977  *
    978  * @since  2.4.0
    979  *
    980  * @return bool True if on a page to edit a cover image, false otherwise
     975 * Are we on a page to edit a cover image?
     976 *
     977 * @since 2.4.0
     978 *
     979 * @return bool True if on a page to edit a cover image, false otherwise.
    981980 */
    982981function bp_attachments_cover_image_is_edit() {
     
    10051004
    10061005/**
    1007  * Does the user has a cover image ?
    1008  *
    1009  * @since  2.4.0
    1010  *
    1011  * @param  int $user_id
    1012  * @return bool True if the user has a cover image, false otherwise
     1006 * Does the user has a cover image?
     1007 *
     1008 * @since 2.4.0
     1009 *
     1010 * @param int $user_id User ID to retrieve cover image for.
     1011 * @return bool True if the user has a cover image, false otherwise.
    10131012 */
    10141013function bp_attachments_get_user_has_cover_image( $user_id = 0 ) {
     
    10251024
    10261025/**
    1027  * Does the group has a cover image ?
    1028  *
    1029  * @since  2.4.0
    1030  *
    1031  * @param  int $group_id
    1032  * @return bool True if the group has a cover image, false otherwise
     1026 * Does the group has a cover image?
     1027 *
     1028 * @since 2.4.0
     1029 *
     1030 * @param int $group_id Group ID to check cover image existence for.
     1031 * @return bool True if the group has a cover image, false otherwise.
    10331032 */
    10341033function bp_attachments_get_group_has_cover_image( $group_id = 0 ) {
     
    10501049 * @since 2.4.0
    10511050 *
    1052  * @param  array  $args {
     1051 * @param array                     $args {
    10531052 *     @type string $file            The absolute path to the image. Required.
    10541053 *     @type string $component       The component for the object (eg: groups, xprofile). Required.
    10551054 *     @type string $cover_image_dir The Cover image dir to write the image into. Required.
    10561055 * }
    1057  * @param  BP_Attachment_Cover_Image $cover_image_class The class to use to fit the cover image.
    1058  * @return bool|array          An array containing cover image data on success, false otherwise.
     1056 * @param BP_Attachment_Cover_Image $cover_image_class The class to use to fit the cover image.
     1057 * @return bool|array An array containing cover image data on success, false otherwise.
    10591058 */
    10601059function bp_attachments_cover_image_generate_file( $args = array(), $cover_image_class = null ) {
    1061     // Bail if an argument is missing
     1060    // Bail if an argument is missing.
    10621061    if ( empty( $args['file'] ) || empty( $args['component'] ) || empty( $args['cover_image_dir'] ) ) {
    10631062        return false;
    10641063    }
    10651064
    1066     // Get advised dimensions for the cover image
     1065    // Get advised dimensions for the cover image.
    10671066    $dimensions = bp_attachments_get_cover_image_dimensions( $args['component'] );
    10681067
     
    10811080    }
    10821081
    1083     // Resize the image so that it fit with the cover image dimensions
     1082    // Resize the image so that it fit with the cover image dimensions.
    10841083    $cover_image  = $cover_image_class->fit( $args['file'], $dimensions );
    10851084    $is_too_small = false;
    10861085
    1087     // Image is too small in width and height
     1086    // Image is too small in width and height.
    10881087    if ( empty( $cover_image ) ) {
    10891088        $cover_file = $cover_image_class->generate_filename( $args['file'] );
     
    10951094        $cover_file = $cover_image['path'];
    10961095
    1097         // Image is too small in width or height
     1096        // Image is too small in width or height.
    10981097        if ( $cover_image['width'] < $dimensions['width'] || $cover_image['height'] < $dimensions['height'] ) {
    10991098            $is_too_small = true;
     
    11111110    if ( $att_dir = opendir( $args['cover_image_dir'] ) ) {
    11121111        while ( false !== ( $attachment_file = readdir( $att_dir ) ) ) {
    1113             // skip directories and the new cover image
     1112            // Skip directories and the new cover image.
    11141113            if ( 2 < strlen( $attachment_file ) && 0 !== strpos( $attachment_file, '.' ) && $cover_basename !== $attachment_file ) {
    11151114                @unlink( $args['cover_image_dir'] . '/' . $attachment_file );
     
    11291128 * Ajax Upload and set a cover image
    11301129 *
    1131  * @since  2.4.0
    1132  *
    1133  * @return  string|null A json object containing success data if the upload succeeded
    1134  *                      error message otherwise.
     1130 * @since 2.4.0
     1131 *
     1132 * @return string|null A json object containing success data if the upload succeeded
     1133 *                     error message otherwise.
    11351134 */
    11361135function bp_attachments_cover_image_ajax_upload() {
    1137     // Bail if not a POST action
     1136    // Bail if not a POST action.
    11381137    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
    11391138        wp_die();
     
    11491148    }
    11501149
    1151     // Check the nonce
     1150    // Check the nonce.
    11521151    check_admin_referer( 'bp-uploader' );
    11531152
    1154     // Init the BuddyPress parameters
     1153    // Init the BuddyPress parameters.
    11551154    $bp_params = array();
    11561155
    1157     // We need it to carry on
     1156    // We need it to carry on.
    11581157    if ( ! empty( $_POST['bp_params'] ) ) {
    11591158        $bp_params = bp_parse_args( $_POST['bp_params'], array(
     
    11651164    }
    11661165
    1167     // We need the object to set the uploads dir filter
     1166    // We need the object to set the uploads dir filter.
    11681167    if ( empty( $bp_params['object'] ) ) {
    11691168        bp_attachments_json_response( false, $is_html4 );
    11701169    }
    11711170
    1172     // Capability check
     1171    // Capability check.
    11731172    if ( ! bp_attachments_current_user_can( 'edit_cover_image', $bp_params ) ) {
    11741173        bp_attachments_json_response( false, $is_html4 );
     
    11781177    $needs_reset = array();
    11791178
    1180     // Member's cover image
     1179    // Member's cover image.
    11811180    if ( 'user' === $bp_params['object'] ) {
    11821181        $object_data = array( 'dir' => 'members', 'component' => 'xprofile' );
     
    11871186        }
    11881187
    1189     // Group's cover image
     1188    // Group's cover image.
    11901189    } elseif ( 'group' === $bp_params['object'] ) {
    11911190        $object_data = array( 'dir' => 'groups', 'component' => 'groups' );
     
    11991198        }
    12001199
    1201     // Other object's cover image
     1200    // Other object's cover image.
    12021201    } else {
    12031202        $object_data = apply_filters( 'bp_attachments_cover_image_object_dir', array(), $bp_params['object'] );
    12041203    }
    12051204
    1206     // Stop here in case of a missing parameter for the object
     1205    // Stop here in case of a missing parameter for the object.
    12071206    if ( empty( $object_data['dir'] ) || empty( $object_data['component'] ) ) {
    12081207        bp_attachments_json_response( false, $is_html4 );
     
    12121211    $uploaded = $cover_image_attachment->upload( $_FILES );
    12131212
    1214     // Reset objects
     1213    // Reset objects.
    12151214    if ( ! empty( $needs_reset ) ) {
    12161215        if ( ! empty( $needs_reset['component'] ) ) {
     
    12221221
    12231222    if ( ! empty( $uploaded['error'] ) ) {
    1224         // Upload error response
     1223        // Upload error response.
    12251224        bp_attachments_json_response( false, $is_html4, array(
    12261225            'type'    => 'upload_error',
     
    12291228    }
    12301229
    1231     // Default error message
     1230    // Default error message.
    12321231    $error_message = __( 'There was a problem uploading the cover image.', 'buddypress' );
    12331232
    1234     // Get BuddyPress Attachments Uploads Dir datas
     1233    // Get BuddyPress Attachments Uploads Dir datas.
    12351234    $bp_attachments_uploads_dir = bp_attachments_uploads_dir_get();
    12361235
     
    12391238
    12401239    if ( ! is_dir( $cover_dir ) ) {
    1241         // Upload error response
     1240        // Upload error response.
    12421241        bp_attachments_json_response( false, $is_html4, array(
    12431242            'type'    => 'upload_error',
     
    12601259
    12611260    if ( ! $cover ) {
    1262         // Upload error response
     1261        // Upload error response.
    12631262        bp_attachments_json_response( false, $is_html4, array(
    12641263            'type'    => 'upload_error',
     
    12671266    }
    12681267
    1269     // Build the url to the file
     1268    // Build the url to the file.
    12701269    $cover_url = trailingslashit( $bp_attachments_uploads_dir['baseurl'] ) . $cover_subdir . '/' . $cover['cover_basename'];
    12711270
    1272     // Init Feedback code, 1 is success
     1271    // Init Feedback code, 1 is success.
    12731272    $feedback_code = 1;
    12741273
    1275     // 0 is the size warning
     1274    // 0 is the size warning.
    12761275    if ( $cover['is_too_small'] ) {
    12771276        $feedback_code = 0;
    12781277    }
    12791278
    1280     // Set the name of the file
     1279    // Set the name of the file.
    12811280    $name = $_FILES['file']['name'];
    12821281    $name_parts = pathinfo( $name );
     
    12971296    do_action( $object_data['component'] . '_cover_image_uploaded', (int) $bp_params['item_id'] );
    12981297
    1299     // Finally return the cover image url to the UI
     1298    // Finally return the cover image url to the UI.
    13001299    bp_attachments_json_response( true, $is_html4, array(
    13011300        'name'          => $name,
     
    13261325    }
    13271326
    1328     // Check the nonce
     1327    // Check the nonce.
    13291328    check_admin_referer( 'bp_delete_cover_image', 'nonce' );
    13301329
    1331     // Capability check
     1330    // Capability check.
    13321331    if ( ! bp_attachments_current_user_can( 'edit_cover_image', $cover_image_data ) ) {
    13331332        wp_send_json_error();
    13341333    }
    13351334
    1336     // Set object for the user's case
     1335    // Set object for the user's case.
    13371336    if ( 'user' === $cover_image_data['object'] ) {
    13381337        $component = 'xprofile';
    13391338        $dir       = 'members';
    13401339
    1341     // Set it for any other cases
     1340    // Set it for any other cases.
    13421341    } else {
    13431342        $component = $cover_image_data['object'] . 's';
     
    13451344    }
    13461345
    1347     // Handle delete
     1346    // Handle delete.
    13481347    if ( bp_attachments_delete_file( array( 'item_id' => $cover_image_data['item_id'], 'object_dir' => $dir, 'type' => 'cover-image' ) ) ) {
    13491348
    1350         // Defaults no cover image
     1349        // Defaults no cover image.
    13511350        $response = array(
    13521351            'reset_url'     => '',
     
    13541353        );
    13551354
    1356         // Get cover image settings in case there's a default header
     1355        // Get cover image settings in case there's a default header.
    13571356        $cover_params = bp_attachments_get_cover_image_settings( $component );
    13581357
    1359         // Check if there's a default cover
     1358        // Check if there's a default cover.
    13601359        if ( ! empty( $cover_params['default_cover'] ) ) {
    13611360            $response['reset_url'] = $cover_params['default_cover'];
    13621361        }
    13631362
    1364         // Finally send the reset url
     1363        // Finally send the reset url.
    13651364        wp_send_json_success( $response );
    13661365
  • trunk/src/bp-core/bp-core-avatars.php

    r10287 r10356  
    5454    $bp->avatar->full  = new stdClass;
    5555
    56     // Dimensions
     56    // Dimensions.
    5757    $bp->avatar->thumb->width  = BP_AVATAR_THUMB_WIDTH;
    5858    $bp->avatar->thumb->height = BP_AVATAR_THUMB_HEIGHT;
     
    6060    $bp->avatar->full->height  = BP_AVATAR_FULL_HEIGHT;
    6161
    62     // Upload maximums
     62    // Upload maximums.
    6363    $bp->avatar->original_max_width    = BP_AVATAR_ORIGINAL_MAX_WIDTH;
    6464    $bp->avatar->original_max_filesize = BP_AVATAR_ORIGINAL_MAX_FILESIZE;
    6565
    66     // Defaults
     66    // Defaults.
    6767    $bp->avatar->thumb->default = bp_core_avatar_default_thumb();
    6868    $bp->avatar->full->default  = bp_core_avatar_default();
    6969
    70     // These have to be set on page load in order to avoid infinite filter loops at runtime
     70    // These have to be set on page load in order to avoid infinite filter loops at runtime.
    7171    $bp->avatar->upload_path = bp_core_avatar_upload_path();
    7272    $bp->avatar->url = bp_core_avatar_url();
    7373
    7474    // Cache the root blog's show_avatars setting, to avoid unnecessary
    75     // calls to switch_to_blog()
     75    // calls to switch_to_blog().
    7676    $bp->avatar->show_avatars = (bool) BP_SHOW_AVATARS;
    7777
    78     // Backpat for pre-1.5
     78    // Backpat for pre-1.5.
    7979    if ( ! defined( 'BP_AVATAR_UPLOAD_PATH' ) )
    8080        define( 'BP_AVATAR_UPLOAD_PATH', $bp->avatar->upload_path );
    8181
    82     // Backpat for pre-1.5
     82    // Backpat for pre-1.5.
    8383    if ( ! defined( 'BP_AVATAR_URL' ) )
    8484        define( 'BP_AVATAR_URL', $bp->avatar->url );
     
    184184 *                                     image regardless if the Gravatar exists. Default: false.
    185185 * }
    186  *
    187186 * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg.
    188187 */
     
    190189    $bp = buddypress();
    191190
    192     // If avatars are disabled for the root site, obey that request and bail
     191    // If avatars are disabled for the root site, obey that request and bail.
    193192    if ( ! $bp->avatar->show_avatars ) {
    194193        return;
     
    218217    ) );
    219218
    220     /** Set item_id ***********************************************************/
     219    /* Set item_id ***********************************************************/
    221220
    222221    if ( empty( $params['item_id'] ) ) {
     
    259258    }
    260259
    261     /** Set avatar_dir ********************************************************/
     260    /* Set avatar_dir ********************************************************/
    262261
    263262    if ( empty( $params['avatar_dir'] ) ) {
     
    300299    }
    301300
    302     /** <img> alt *************************************************************/
     301    /* <img> alt *************************************************************/
    303302
    304303    if ( false !== strpos( $params['alt'], '%s' ) || false !== strpos( $params['alt'], '%1$s' ) ) {
     
    334333    }
    335334
    336     /** Sanity Checks *********************************************************/
     335    /* Sanity Checks *********************************************************/
    337336
    338337    // Get a fallback for the 'alt' parameter, create html output.
     
    361360    }
    362361
    363     // Extra attributes
     362    // Extra attributes.
    364363    $extra_attr = ! empty( $args['extra_attr'] ) ? ' ' . $args['extra_attr'] : '';
    365364
     
    383382    }
    384383
    385     // Set image width
     384    // Set image width.
    386385    if ( false !== $params['width'] ) {
    387386        // Width has been specified. No modification necessary.
     
    393392    $html_width = ' width="' . $params['width'] . '"';
    394393
    395     // Set image height
     394    // Set image height.
    396395    if ( false !== $params['height'] ) {
    397396        // Height has been specified. No modification necessary.
     
    415414    $params['class'] = apply_filters( 'bp_core_avatar_class', $params['class'], $params['item_id'], $params['object'], $params );
    416415
    417     // Use an alias to leave the param unchanged
     416    // Use an alias to leave the param unchanged.
    418417    $avatar_classes = $params['class'];
    419418    if ( ! is_array( $avatar_classes ) ) {
     
    421420    }
    422421
    423     // merge classes
     422    // Merge classes.
    424423    $avatar_classes = array_merge( $avatar_classes, array(
    425424        $params['object'] . '-' . $params['item_id'] . '-avatar',
     
    427426    ) );
    428427
    429     // Sanitize each class
     428    // Sanitize each class.
    430429    $avatar_classes = array_map( 'sanitize_html_class', $avatar_classes );
    431430
    432     // populate the class attribute
     431    // Populate the class attribute.
    433432    $html_class = ' class="' . join( ' ', $avatar_classes ) . ' photo"';
    434433
    435     // Set img URL and DIR based on prepopulated constants
     434    // Set img URL and DIR based on prepopulated constants.
    436435    $avatar_loc        = new stdClass();
    437436    $avatar_loc->path  = trailingslashit( bp_core_avatar_upload_path() );
     
    473472    $legacy_group_avatar_name = ( 'full' == $params['type'] ) ? '-groupavatar-full' : '-groupavatar-thumb';
    474473
    475     // Check for directory
     474    // Check for directory.
    476475    if ( file_exists( $avatar_folder_dir ) ) {
    477476
    478         // Open directory
     477        // Open directory.
    479478        if ( $av_dir = opendir( $avatar_folder_dir ) ) {
    480479
    481             // Stash files in an array once to check for one that matches
     480            // Stash files in an array once to check for one that matches.
    482481            $avatar_files = array();
    483482            while ( false !== ( $avatar_file = readdir( $av_dir ) ) ) {
    484                 // Only add files to the array (skip directories)
     483                // Only add files to the array (skip directories).
    485484                if ( 2 < strlen( $avatar_file ) ) {
    486485                    $avatar_files[] = $avatar_file;
     
    488487            }
    489488
    490             // Check for array
     489            // Check for array.
    491490            if ( 0 < count( $avatar_files ) ) {
    492491
    493                 // Check for current avatar
     492                // Check for current avatar.
    494493                foreach( $avatar_files as $key => $value ) {
    495494                    if ( strpos ( $value, $avatar_size )!== false ) {
     
    498497                }
    499498
    500                 // Legacy avatar check
     499                // Legacy avatar check.
    501500                if ( !isset( $avatar_url ) ) {
    502501                    foreach( $avatar_files as $key => $value ) {
     
    506505                    }
    507506
    508                     // Legacy group avatar check
     507                    // Legacy group avatar check.
    509508                    if ( !isset( $avatar_url ) ) {
    510509                        foreach( $avatar_files as $key => $value ) {
     
    518517        }
    519518
    520         // Close the avatar directory
     519        // Close the avatar directory.
    521520        closedir( $av_dir );
    522521
    523         // If we found a locally uploaded avatar
     522        // If we found a locally uploaded avatar.
    524523        if ( isset( $avatar_url ) ) {
    525             // Support custom scheme
     524            // Support custom scheme.
    526525            $avatar_url = set_url_scheme( $avatar_url, $params['scheme'] );
    527526
    528             // Return it wrapped in an <img> element
     527            // Return it wrapped in an <img> element.
    529528            if ( true === $params['html'] ) {
    530529
     
    572571    if ( ! apply_filters( 'bp_core_fetch_avatar_no_grav', $params['no_grav'], $params ) ) {
    573572
    574         // Set gravatar type
     573        // Set gravatar type.
    575574        if ( empty( $bp->grav_default->{$params['object']} ) ) {
    576575            $default_grav = 'wavatar';
     
    590589        }
    591590
    592         // Set gravatar object
     591        // Set gravatar object.
    593592        if ( empty( $params['email'] ) ) {
    594593            if ( 'user' == $params['object'] ) {
     
    619618        $gravatar = apply_filters( 'bp_gravatar_url', '//www.gravatar.com/avatar/' );
    620619
    621         // Append email hash to Gravatar
     620        // Append email hash to Gravatar.
    622621        $gravatar .=  md5( strtolower( $params['email'] ) );
    623622
    624         // Main Gravatar URL args
     623        // Main Gravatar URL args.
    625624        $url_args = array(
    626625            'd' => $default_grav,
     
    628627        );
    629628
    630         // Custom Gravatar URL args
     629        // Custom Gravatar URL args.
    631630        if ( ! empty( $params['force_default'] ) ) {
    632631            $url_args['f'] = 'y';
     
    636635        }
    637636
    638         // Set up the Gravatar URL
     637        // Set up the Gravatar URL.
    639638        $gravatar = esc_url( add_query_arg(
    640639            rawurlencode_deep( array_filter( $url_args ) ),
     
    689688    $defaults = array(
    690689        'item_id'    => false,
    691         'object'     => 'user', // user OR group OR blog OR custom type (if you use filters)
     690        'object'     => 'user', // User OR group OR blog OR custom type (if you use filters).
    692691        'avatar_dir' => false
    693692    );
     
    777776    }
    778777
    779     // Check the nonce
     778    // Check the nonce.
    780779    check_admin_referer( $nonce, 'nonce' );
    781780
    782     // Capability check
     781    // Capability check.
    783782    if ( ! bp_attachments_current_user_can( 'edit_avatar', $avatar_data ) ) {
    784783        wp_send_json_error();
    785784    }
    786785
    787     // Handle delete
     786    // Handle delete.
    788787    if ( bp_core_delete_existing_avatar( array( 'item_id' => $avatar_data['item_id'], 'object' => $avatar_data['object'] ) ) ) {
    789788        $return = array(
     
    821820 * @param array  $file              The appropriate entry the from $_FILES superglobal.
    822821 * @param string $upload_dir_filter A filter to be applied to 'upload_dir'.
    823  *
    824822 * @return bool True on success, false on failure.
    825823 */
     
    855853    }
    856854
    857     // The Avatar UI available width
     855    // The Avatar UI available width.
    858856    $ui_available_width = 0;
    859857
    860     // Try to set the ui_available_width using the avatar_admin global
     858    // Try to set the ui_available_width using the avatar_admin global.
    861859    if ( isset( $bp->avatar_admin->ui_available_width ) ) {
    862860        $ui_available_width = $bp->avatar_admin->ui_available_width;
     
    903901 */
    904902function bp_avatar_ajax_upload() {
    905     // Bail if not a POST action
     903    // Bail if not a POST action.
    906904    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
    907905        wp_die();
     
    917915    }
    918916
    919     // Check the nonce
     917    // Check the nonce.
    920918    check_admin_referer( 'bp-uploader' );
    921919
    922     // Init the BuddyPress parameters
     920    // Init the BuddyPress parameters.
    923921    $bp_params = array();
    924922
    925     // We need it to carry on
     923    // We need it to carry on.
    926924    if ( ! empty( $_POST['bp_params' ] ) ) {
    927925        $bp_params = $_POST['bp_params' ];
     
    930928    }
    931929
    932     // We need the object to set the uploads dir filter
     930    // We need the object to set the uploads dir filter.
    933931    if ( empty( $bp_params['object'] ) ) {
    934932        bp_attachments_json_response( false, $is_html4 );
    935933    }
    936934
    937     // Capability check
     935    // Capability check.
    938936    if ( ! bp_attachments_current_user_can( 'edit_avatar', $bp_params ) ) {
    939937        bp_attachments_json_response( false, $is_html4 );
     
    984982    }
    985983
    986     // Upload the avatar
     984    // Upload the avatar.
    987985    $avatar = bp_core_avatar_handle_upload( $_FILES, $bp_params['upload_dir_filter'] );
    988986
    989     // Reset objects
     987    // Reset objects.
    990988    if ( ! empty( $needs_reset ) ) {
    991989        if ( ! empty( $needs_reset['component'] ) ) {
     
    996994    }
    997995
    998     // Init the feedback message
     996    // Init the feedback message.
    999997    $feedback_message = false;
    1000998
     
    10101008
    10111009    if ( empty( $avatar ) ) {
    1012         // Default upload error
     1010        // Default upload error.
    10131011        $message = __( 'Upload failed.', 'buddypress' );
    10141012
    1015         // Use the template message if set
     1013        // Use the template message if set.
    10161014        if ( ! empty( $feedback_message ) ) {
    10171015            $message = $feedback_message;
    10181016        }
    10191017
    1020         // Upload error reply
     1018        // Upload error reply.
    10211019        bp_attachments_json_response( false, $is_html4, array(
    10221020            'type'    => 'upload_error',
     
    10311029    $uploaded_image = @getimagesize( $bp->avatar_admin->image->file );
    10321030
    1033     // Set the name of the file
     1031    // Set the name of the file.
    10341032    $name = $_FILES['file']['name'];
    10351033    $name_parts = pathinfo( $name );
    10361034    $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
    10371035
    1038     // Finally return the avatar to the editor
     1036    // Finally return the avatar to the editor.
    10391037    bp_attachments_json_response( true, $is_html4, array(
    10401038        'name'      => $name,
     
    10541052  * @param string $data    Base64 encoded image.
    10551053  * @param int    $item_id Item to associate.
    1056   *
    10571054  * @return bool True on success, false on failure.
    10581055  */
     
    10951092        $avatar_to_crop = str_replace( bp_core_avatar_upload_path(), '', $original_file );
    10961093
    1097         // Crop to default values
     1094        // Crop to default values.
    10981095        $crop_args = array( 'item_id' => $item_id, 'original_file' => $avatar_to_crop, 'crop_x' => 0, 'crop_y' => 0 );
    10991096
     
    11341131 *     @type int         $crop_y        The vertical starting point of the crop. Default: 0.
    11351132 * }
    1136  *
    11371133 * @return bool True on success, false on failure.
    11381134 */
     
    11641160    }
    11651161
    1166     // Crop the file
     1162    // Crop the file.
    11671163    $avatar_attachment = new BP_Attachment_Avatar();
    11681164    $cropped           = $avatar_attachment->crop( $r );
    11691165
    1170     // Check for errors
     1166    // Check for errors.
    11711167    if ( empty( $cropped['full'] ) || empty( $cropped['thumb'] ) || is_wp_error( $cropped['full'] ) || is_wp_error( $cropped['thumb'] ) ) {
    11721168        return false;
     
    11851181 */
    11861182function bp_avatar_ajax_set() {
    1187     // Bail if not a POST action
     1183    // Bail if not a POST action.
    11881184    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
    11891185        wp_send_json_error();
    11901186    }
    11911187
    1192     // Check the nonce
     1188    // Check the nonce.
    11931189    check_admin_referer( 'bp_avatar_cropstore', 'nonce' );
    11941190
     
    12041200    }
    12051201
    1206     // Capability check
     1202    // Capability check.
    12071203    if ( ! bp_attachments_current_user_can( 'edit_avatar', $avatar_data ) ) {
    12081204        wp_send_json_error();
     
    12551251    $original_file = str_replace( bp_core_avatar_url(), '', $avatar_data['original_file'] );
    12561252
    1257     // Set avatars dir & feedback part
     1253    // Set avatars dir & feedback part.
    12581254    if ( 'user' === $avatar_data['object'] ) {
    12591255        $avatar_dir = 'avatars';
    12601256
    1261     // Defaults to object-avatars dir
     1257    // Defaults to object-avatars dir.
    12621258    } else {
    12631259        $avatar_dir = sanitize_key( $avatar_data['object'] ) . '-avatars';
    12641260    }
    12651261
    1266     // Crop args
     1262    // Crop args.
    12671263    $r = array(
    12681264        'item_id'       => $avatar_data['item_id'],
     
    12761272    );
    12771273
    1278     // Handle crop
     1274    // Handle crop.
    12791275    if ( bp_core_avatar_handle_crop( $r ) ) {
    12801276        $return = array(
     
    13261322 * @param string            $alt     Alternate text to use in image tag. Default: ''.
    13271323 * @param array             $args    Arguments passed to get_avatar_data(), after processing.
    1328  *
    13291324 * @return string BP avatar path, if found; else the original avatar path.
    13301325 */
     
    13321327    global $pagenow;
    13331328
    1334     // Do not filter if inside WordPress options page
     1329    // Do not filter if inside WordPress options page.
    13351330    if ( 'options-discussion.php' == $pagenow )
    13361331        return $avatar;
    13371332
    1338     // If passed an object, assume $user->user_id
     1333    // If passed an object, assume $user->user_id.
    13391334    if ( is_object( $user ) ) {
    13401335        if ( isset( $user->user_id ) ) {
     
    13441339        }
    13451340
    1346     // If passed a number, assume it was a $user_id
     1341    // If passed a number, assume it was a $user_id.
    13471342    } elseif ( is_numeric( $user ) ) {
    13481343        $id = $user;
    13491344
    1350     // If passed a string and that string returns a user, get the $id
     1345    // If passed a string and that string returns a user, get the $id.
    13511346    } elseif ( is_string( $user ) && ( $user_by_email = get_user_by( 'email', $user ) ) ) {
    13521347        $id = $user_by_email->ID;
    13531348    }
    13541349
    1355     // If somehow $id hasn't been assigned, return the result of get_avatar
     1350    // If somehow $id hasn't been assigned, return the result of get_avatar.
    13561351    if ( empty( $id ) ) {
    13571352        return !empty( $avatar ) ? $avatar : $default;
    13581353    }
    13591354
    1360     // Image alt tag
     1355    // Image alt tag.
    13611356    if ( empty( $alt ) ) {
    13621357        $alt = sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $id ) );
     
    13781373    );
    13791374
    1380     // Support new arguments as of WordPress 4.2.0
     1375    // Support new arguments as of WordPress 4.2.0.
    13811376    if ( ! empty( $args['width'] ) ) {
    13821377        $avatar_args['width'] = $args['width'];
     
    14041399    }
    14051400
    1406     // Let BuddyPress handle the fetching of the avatar
     1401    // Let BuddyPress handle the fetching of the avatar.
    14071402    $bp_avatar = bp_core_fetch_avatar( $avatar_args );
    14081403
    1409     // If BuddyPress found an avatar, use it. If not, use the result of get_avatar
     1404    // If BuddyPress found an avatar, use it. If not, use the result of get_avatar.
    14101405    return ( !$bp_avatar ) ? $avatar : $bp_avatar;
    14111406}
     
    14161411 *
    14171412 * @param array $file The $_FILES array.
    1418  *
    14191413 * @return bool True if no errors are found. False if there are errors.
    14201414 */
     
    14301424 *
    14311425 * @param array $file The $_FILES array.
    1432  *
    14331426 * @return bool True if the avatar is under the size limit, otherwise false.
    14341427 */
     
    14831476 *
    14841477 * @param array $file The $_FILES array.
    1485  *
    14861478 * @return bool True if the file extension is permitted, otherwise false.
    14871479 */
     
    14971489 * @param string $type The variable we want to return from the $bp->avatars object.
    14981490 *                     Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
    1499  *
    15001491 * @return string The avatar upload directory path.
    15011492 */
     
    16121603 *
    16131604 * @param int $user_id ID of the user whose avatar is being checked.
    1614  *
    16151605 * @return bool True if the user has uploaded a local avatar. Otherwise false.
    16161606 */
     
    16441634 * @param string $h_or_w Which dimension is being fetched. 'height' or 'width'.
    16451635 *                       Default: 'height'.
    1646  *
    16471636 * @return int|bool $dim The dimension.
    16481637 */
     
    17851774 *                     of the mystery-person, 'gravatar' if the fallback should be
    17861775 *                     Gravatar's version. Default: 'gravatar'.
    1787  *
    17881776 * @return string The URL of the default avatar.
    17891777 */
    17901778function bp_core_avatar_default( $type = 'gravatar' ) {
    1791     // Local override
     1779    // Local override.
    17921780    if ( defined( 'BP_AVATAR_DEFAULT' ) ) {
    17931781        $avatar = BP_AVATAR_DEFAULT;
    17941782
    1795     // Use the local default image
     1783    // Use the local default image.
    17961784    } elseif ( 'local' === $type ) {
    17971785        $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man.jpg';
    17981786
    1799     // Use Gravatar's mystery person as fallback
     1787    // Use Gravatar's mystery person as fallback.
    18001788    } else {
    18011789        $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_full_width();
     
    18231811 *                     of the mystery-person, 'gravatar' if the fallback should be
    18241812 *                     Gravatar's version. Default: 'gravatar'.
    1825  *
    18261813 * @return string The URL of the default avatar thumb.
    18271814 */
    18281815function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
    1829     // Local override
     1816    // Local override.
    18301817    if ( defined( 'BP_AVATAR_DEFAULT_THUMB' ) ) {
    18311818        $avatar = BP_AVATAR_DEFAULT_THUMB;
    18321819
    1833     // Use the local default image
     1820    // Use the local default image.
    18341821    } elseif ( 'local' === $type ) {
    18351822        $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man-50.jpg';
    18361823
    1837     // Use Gravatar's mystery person as fallback
     1824    // Use Gravatar's mystery person as fallback.
    18381825    } else {
    18391826        $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_thumb_width();
     
    18701857    $reset_w = false;
    18711858
    1872     // Group's avatar edit screen
     1859    // Group's avatar edit screen.
    18731860    if ( bp_is_group_admin_page() ) {
    18741861        $reset_w = bp_is_group_admin_screen( 'group-avatar' );
    18751862
    1876     // Group's avatar create screen
     1863    // Group's avatar create screen.
    18771864    } elseif ( bp_is_group_create() ) {
    18781865        /**
    1879          * we can't use bp_get_groups_current_create_step()
     1866         * We can't use bp_get_groups_current_create_step().
    18801867         * as it's not set yet
    18811868         */
    18821869        $reset_w = 'group-avatar' === bp_action_variable( 1 );
    18831870
    1884     // User's change avatar screen
     1871    // User's change avatar screen.
    18851872    } else {
    18861873        $reset_w = bp_is_user_change_avatar();
    18871874    }
    18881875
    1889     // A user or a group is cropping an avatar
     1876    // A user or a group is cropping an avatar.
    18901877    if ( true === $reset_w && isset( $_POST['avatar-crop-submit'] ) ) {
    18911878        $posts_query->set( 'w', 0 );
     
    19141901
    19151902    if ( bp_is_active( 'groups' ) ) {
    1916         // Group creation
     1903        // Group creation.
    19171904        if ( bp_is_group_create() && bp_is_group_creation_step( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) {
    19181905            $retval = ! bp_disable_group_avatar_uploads();
    19191906
    1920         // Group Manage
     1907        // Group Manage.
    19211908        } elseif ( bp_is_group_admin_page() && bp_is_group_admin_screen( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) {
    19221909            $retval = ! bp_disable_group_avatar_uploads();
     
    19311918     * @since  2.3.0
    19321919     *
    1933      * @param bool whether to load the Avatar UI.
     1920     * @param bool $retval Whether or not to load the Avatar UI.
    19341921     */
    19351922    return apply_filters( 'bp_avatar_is_front_edit', $retval );
     
    19711958     * @since 2.3.0
    19721959     *
    1973      * @param bool whether to load Webcam Avatar UI part.
     1960     * @param bool $value Whether or not to load Webcam Avatar UI part.
    19741961     */
    19751962    return apply_filters( 'bp_avatar_use_webcam', true );
  • trunk/src/bp-core/bp-core-buddybar.php

    r10326 r10356  
    3434
    3535    $defaults = array(
    36         'name'                    => false, // Display name for the nav item
    37         'slug'                    => false, // URL slug for the nav item
    38         'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item
     36        'name'                    => false, // Display name for the nav item.
     37        'slug'                    => false, // URL slug for the nav item.
     38        'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item.
    3939        'show_for_displayed_user' => true,  // When viewing another user does this nav item show up?
    4040        'site_admin_only'         => false, // Can only site admins see this nav item?
    41         'position'                => 99,    // Index of where this nav item should be positioned
    42         'screen_function'         => false, // The name of the function to run when clicked
    43         'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked
     41        'position'                => 99,    // Index of where this nav item should be positioned.
     42        'screen_function'         => false, // The name of the function to run when clicked.
     43        'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked.
    4444    );
    4545
     
    103103
    104104    $defaults = array(
    105         'name'                    => false, // Display name for the nav item
    106         'slug'                    => false, // URL slug for the nav item
    107         'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item
     105        'name'                    => false, // Display name for the nav item.
     106        'slug'                    => false, // URL slug for the nav item.
     107        'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item.
    108108        'show_for_displayed_user' => true,  // When viewing another user does this nav item show up?
    109109        'site_admin_only'         => false, // Can only site admins see this nav item?
    110         'position'                => 99,    // Index of where this nav item should be positioned
    111         'screen_function'         => false, // The name of the function to run when clicked
    112         'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked
     110        'position'                => 99,    // Index of where this nav item should be positioned.
     111        'screen_function'         => false, // The name of the function to run when clicked.
     112        'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked.
    113113    );
    114114
     
    178178
    179179    $defaults = array(
    180         'name'                    => false, // Display name for the nav item
    181         'slug'                    => false, // URL slug for the nav item
    182         'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item
     180        'name'                    => false, // Display name for the nav item.
     181        'slug'                    => false, // URL slug for the nav item.
     182        'item_css_id'             => false, // The CSS ID to apply to the HTML of the nav item.
    183183        'show_for_displayed_user' => true,  // When viewing another user does this nav item show up?
    184184        'site_admin_only'         => false, // Can only site admins see this nav item?
    185         'position'                => 99,    // Index of where this nav item should be positioned
    186         'screen_function'         => false, // The name of the function to run when clicked
    187         'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked
     185        'position'                => 99,    // Index of where this nav item should be positioned.
     186        'screen_function'         => false, // The name of the function to run when clicked.
     187        'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked.
    188188    );
    189189
     
    221221    }
    222222
    223     // Look for current component
     223    // Look for current component.
    224224    if ( bp_is_current_component( $r['slug'] ) || bp_is_current_item( $r['slug'] ) ) {
    225225
     
    231231        } elseif ( ! bp_current_action() ) {
    232232
    233             // Add our screen hook if screen function is callable
     233            // Add our screen hook if screen function is callable.
    234234            if ( is_callable( $r['screen_function'] ) ) {
    235235                add_action( 'bp_screens', $r['screen_function'], 3 );
     
    278278
    279279    $defaults = array(
    280         'parent_slug'     => false, // Slug of the parent
    281         'screen_function' => false, // The name of the function to run when clicked
    282         'subnav_slug'     => false  // The slug of the subnav item to select when clicked
     280        'parent_slug'     => false, // Slug of the parent.
     281        'screen_function' => false, // The name of the function to run when clicked.
     282        'subnav_slug'     => false  // The slug of the subnav item to select when clicked.
    283283    );
    284284
     
    286286
    287287    if ( $function = $bp->bp_nav[$r['parent_slug']]['screen_function'] ) {
    288         // Remove our screen hook if screen function is callable
     288        // Remove our screen hook if screen function is callable.
    289289        if ( is_callable( $function ) ) {
    290290            remove_action( 'bp_screens', $function, 3 );
     
    297297
    298298        // The only way to tell whether to set the subnav is to peek at the unfiltered_uri
    299         // Find the component
     299        // Find the component.
    300300        $component_uri_key = array_search( $r['parent_slug'], $bp->unfiltered_uri );
    301301
     
    306306        }
    307307
    308         // No subnav item has been requested in the URL, so set a new nav default
     308        // No subnav item has been requested in the URL, so set a new nav default.
    309309        if ( empty( $unfiltered_action ) ) {
    310310            if ( ! bp_is_current_action( $r['subnav_slug'] ) ) {
     
    318318
    319319        // The URL is explicitly requesting the new subnav item, but should be
    320         // directed to the canonical URL
     320        // directed to the canonical URL.
    321321        } elseif ( $unfiltered_action == $r['subnav_slug'] ) {
    322322            unset( $bp->canonical_stack['action'] );
     
    324324        // In all other cases (including the case where the original subnav item
    325325        // is explicitly called in the URL), the canonical URL will contain the
    326         // subnav slug
     326        // subnav slug.
    327327        } else {
    328328            $bp->canonical_stack['action'] = bp_current_action();
     
    354354            $temp[$nav_item['position']] = $nav_item;
    355355        } else {
    356             // increase numbers here to fit new items in.
     356            // Increase numbers here to fit new items in.
    357357            do {
    358358                $nav_item['position']++;
     
    444444 *                                          Default: false.
    445445 * }
    446  *
    447446 * @return bool|null Returns false on failure.
    448447 */
     
    451450
    452451    $r = wp_parse_args( $args, array(
    453         'name'              => false, // Display name for the nav item
    454         'slug'              => false, // URL slug for the nav item
    455         'parent_slug'       => false, // URL slug of the parent nav item
    456         'parent_url'        => false, // URL of the parent item
    457         'item_css_id'       => false, // The CSS ID to apply to the HTML of the nav item
     452        'name'              => false, // Display name for the nav item.
     453        'slug'              => false, // URL slug for the nav item.
     454        'parent_slug'       => false, // URL slug of the parent nav item.
     455        'parent_url'        => false, // URL of the parent item.
     456        'item_css_id'       => false, // The CSS ID to apply to the HTML of the nav item.
    458457        'user_has_access'   => true,  // Can the logged in user see this nav item?
    459458        'no_access_url'     => '',
    460459        'site_admin_only'   => false, // Can only site admins see this nav item?
    461         'position'          => 90,    // Index of where this nav item should be positioned
    462         'screen_function'   => false, // The name of the function to run when clicked
     460        'position'          => 90,    // Index of where this nav item should be positioned.
     461        'screen_function'   => false, // The name of the function to run when clicked.
    463462        'link'              => '',    // The link for the subnav item; optional, not usually required.
    464         'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu
     463        'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu.
    465464    ) );
    466465
    467     // If we don't have the required info we need, don't create this subnav item
     466    // If we don't have the required info we need, don't create this subnav item.
    468467    if ( empty( $r['name'] ) || empty( $r['slug'] ) || empty( $r['parent_slug'] ) || empty( $r['parent_url'] ) || empty( $r['screen_function'] ) )
    469468        return false;
    470469
    471     // Link was not forced, so create one
     470    // Link was not forced, so create one.
    472471    if ( empty( $r['link'] ) ) {
    473472        $r['link'] = trailingslashit( $r['parent_url'] . $r['slug'] );
    474473
    475         // If this sub item is the default for its parent, skip the slug
     474        // If this sub item is the default for its parent, skip the slug.
    476475        if ( ! empty( $bp->bp_nav[$r['parent_slug']]['default_subnav_slug'] ) && $r['slug'] == $bp->bp_nav[$r['parent_slug']]['default_subnav_slug'] ) {
    477476            $r['link'] = trailingslashit( $r['parent_url'] );
     
    479478    }
    480479
    481     // If this is for site admins only and the user is not one, don't create the subnav item
     480    // If this is for site admins only and the user is not one, don't create the subnav item.
    482481    if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
    483482        return false;
     
    529528 *                                       Default: false.
    530529 * }
    531  *
    532530 * @return bool|null Returns false on failure.
    533531 */
     
    536534
    537535    $r = wp_parse_args( $args, array(
    538         'slug'              => false, // URL slug for the screen
    539         'parent_slug'       => false, // URL slug of the parent screen
     536        'slug'              => false, // URL slug for the screen.
     537        'parent_slug'       => false, // URL slug of the parent screen.
    540538        'user_has_access'   => true,  // Can the user visit this screen?
    541539        'no_access_url'     => '',
    542540        'site_admin_only'   => false, // Can only site admins visit this screen?
    543         'screen_function'   => false, // The name of the function to run when clicked
     541        'screen_function'   => false, // The name of the function to run when clicked.
    544542    ) );
    545543
     
    550548     * checking the following two conditions:
    551549     *   (1) Either:
    552      *       (a) the parent slug matches the current_component, or
    553      *       (b) the parent slug matches the current_item
     550     *       (a) the parent slug matches the current_component, or
     551     *       (b) the parent slug matches the current_item
    554552     *   (2) And either:
    555      *       (a) the current_action matches $slug, or
     553     *       (a) the current_action matches $slug, or
    556554     *       (b) there is no current_action (ie, this is the default subnav for the parent nav)
    557      *       and this subnav item is the default for the parent item (which we check by
    558      *       comparing this subnav item's screen function with the screen function of the
    559      *       parent nav item in $bp->bp_nav). This condition only arises when viewing a
    560      *       user, since groups should always have an action set.
     555     *       and this subnav item is the default for the parent item (which we check by
     556     *       comparing this subnav item's screen function with the screen function of the
     557     *       parent nav item in $bp->bp_nav). This condition only arises when viewing a
     558     *       user, since groups should always have an action set.
    561559     */
    562560
    563     // If we *don't* meet condition (1), return
     561    // If we *don't* meet condition (1), return.
    564562    if ( ! bp_is_current_component( $r['parent_slug'] ) && ! bp_is_current_item( $r['parent_slug'] ) ) {
    565563        return;
    566564    }
    567565
    568     // If we *do* meet condition (2), then the added subnav item is currently being requested
     566    // If we *do* meet condition (2), then the added subnav item is currently being requested.
    569567    if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ( $r['screen_function'] == $bp->bp_nav[$r['parent_slug']]['screen_function'] ) ) ) {
    570568
    571         // If this is for site admins only and the user is not one, don't create the subnav item
     569        // If this is for site admins only and the user is not one, don't create the subnav item.
    572570        if ( ! empty( $r['site_admin_only'] ) && ! bp_current_user_can( 'bp_moderate' ) ) {
    573571            return false;
     
    576574        $hooked = bp_core_maybe_hook_new_subnav_screen_function( $r );
    577575
    578         // If redirect args have been returned, perform the redirect now
     576        // If redirect args have been returned, perform the redirect now.
    579577        if ( ! empty( $hooked['status'] ) && 'failure' === $hooked['status'] && isset( $hooked['redirect_args'] ) ) {
    580578            bp_core_no_access( $hooked['redirect_args'] );
     
    589587 *
    590588 * @param array $subnav_item The subnav array added to bp_options_nav in `bp_core_new_subnav_item()`.
    591  *
    592589 * @return array
    593590 */
     
    603600    }
    604601
    605     // User has access, so let's try to hook the display callback
     602    // User has access, so let's try to hook the display callback.
    606603    if ( ! empty( $subnav_item['user_has_access'] ) && ! $site_admin_restricted ) {
    607604
    608         // Screen function is invalid
     605        // Screen function is invalid.
    609606        if ( ! is_callable( $subnav_item['screen_function'] ) ) {
    610607            $retval['status'] = 'failure';
    611608
    612         // Success - hook to bp_screens
     609        // Success - hook to bp_screens.
    613610        } else {
    614611            add_action( 'bp_screens', $subnav_item['screen_function'], 3 );
     
    617614
    618615    // User doesn't have access. Determine redirect arguments based on
    619     // user status
     616    // user status.
    620617    } else {
    621618        $retval['status'] = 'failure';
     
    626623
    627624            // If a redirect URL has been passed to the subnav
    628             // item, respect it
     625            // item, respect it.
    629626            if ( ! empty( $subnav_item['no_access_url'] ) ) {
    630627                $message     = __( 'You do not have access to this page.', 'buddypress' );
     
    632629
    633630            // In the case of a user page, we try to assume a
    634             // redirect URL
     631            // redirect URL.
    635632            } elseif ( bp_is_user() ) {
    636633
     
    646643                // know will be accessible.
    647644                } else {
    648                     // Try 'activity' first
     645                    // Try 'activity' first.
    649646                    if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
    650647                        $redirect_to = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() );
    651                     // Then try 'profile'
     648                    // Then try 'profile'.
    652649                    } else {
    653650                        $redirect_to = trailingslashit( bp_displayed_user_domain() . ( 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id ) );
     
    657654                }
    658655
    659             // Fall back to the home page
     656            // Fall back to the home page.
    660657            } else {
    661658                $message     = __( 'You do not have access to this page.', 'buddypress' );
     
    672669            // When the user is logged out, pass an empty array
    673670            // This indicates that the default arguments should be
    674             // used in bp_core_no_access()
     671            // used in bp_core_no_access().
    675672            $retval['redirect_args'] = array();
    676673        }
     
    699696                $temp[$subnav_item['position']] = $subnav_item;
    700697            else {
    701                 // increase numbers here to fit new items in.
     698                // Increase numbers here to fit new items in.
    702699                do {
    703700                    $subnav_item['position']++;
     
    722719 * @param string $nav_item The slug of the top-level nav item whose subnav items you're checking.
    723720 *                         Default: the current component slug.
    724  *
    725721 * @return bool $has_subnav True if the nav item is found and has subnav items; false otherwise.
    726722 */
     
    748744 *
    749745 * @param int $parent_id The slug of the parent navigation item.
    750  *
    751746 * @return bool Returns false on failure, ie if the nav item can't be found.
    752747 */
     
    754749    $bp = buddypress();
    755750
    756     // Unset subnav items for this nav item
     751    // Unset subnav items for this nav item.
    757752    if ( isset( $bp->bp_options_nav[$parent_id] ) && is_array( $bp->bp_options_nav[$parent_id] ) ) {
    758753        foreach( (array) $bp->bp_options_nav[$parent_id] as $subnav_item ) {
     
    765760
    766761    if ( $function = $bp->bp_nav[$parent_id]['screen_function'] ) {
    767         // Remove our screen hook if screen function is callable
     762        // Remove our screen hook if screen function is callable.
    768763        if ( is_callable( $function ) ) {
    769764            remove_action( 'bp_screens', $function, 3 );
     
    788783
    789784    if ( ! empty( $screen_function ) ) {
    790         // Remove our screen hook if screen function is callable
     785        // Remove our screen hook if screen function is callable.
    791786        if ( is_callable( $screen_function ) ) {
    792787            remove_action( 'bp_screens', $screen_function, 3 );
     
    823818 * @param string $context Context of this preference check. 'admin' or 'front'.
    824819 * @param int    $user    Optional. ID of the user to check. Default: 0 (which falls back to the logged-in user's ID).
    825  *
    826820 * @return bool True if the toolbar should be showing for this user.
    827821 */
  • trunk/src/bp-core/bp-core-cache.php

    r10108 r10356  
    134134 * @param array  $item_ids    ID list.
    135135 * @param string $cache_group The cache group to check against.
    136  *
    137136 * @return array
    138137 */
     
    175174 *                                          cache key names. Default: the value of $meta_table.
    176175 * }
    177  *
    178176 * @return array|bool Metadata cache for the specified objects, or false on failure.
    179177 */
     
    182180
    183181    $defaults = array(
    184         'object_ids'       => array(), // Comma-separated list or array of item ids
    185         'object_type'      => '',      // Canonical component id: groups, members, etc
    186         'cache_group'      => '',      // Cache group
    187         'meta_table'       => '',      // Name of the table containing the metadata
    188         'object_column'    => '',      // DB column for the object ids (group_id, etc)
    189         'cache_key_prefix' => ''       // Prefix to use when creating cache key names. Eg 'bp_groups_groupmeta'
     182        'object_ids'       => array(), // Comma-separated list or array of item ids.
     183        'object_type'      => '',      // Canonical component id: groups, members, etc.
     184        'cache_group'      => '',      // Cache group.
     185        'meta_table'       => '',      // Name of the table containing the metadata.
     186        'object_column'    => '',      // DB column for the object ids (group_id, etc).
     187        'cache_key_prefix' => ''       // Prefix to use when creating cache key names. Eg 'bp_groups_groupmeta'.
    190188    );
    191189    $r = wp_parse_args( $args, $defaults );
     
    213211    $cache = array();
    214212
    215     // Get meta info
     213    // Get meta info.
    216214    if ( ! empty( $uncached_ids ) ) {
    217215        $id_list   = join( ',', wp_parse_id_list( $uncached_ids ) );
     
    224222                $mval = $metarow['meta_value'];
    225223
    226                 // Force subkeys to be array type:
     224                // Force subkeys to be array type.
    227225                if ( !isset( $cache[$mpid] ) || !is_array( $cache[$mpid] ) )
    228226                    $cache[$mpid] = array();
     
    230228                    $cache[$mpid][$mkey] = array();
    231229
    232                 // Add a value to the current pid/key:
     230                // Add a value to the current pid/key.
    233231                $cache[$mpid][$mkey][] = $mval;
    234232            }
     
    236234
    237235        foreach ( $uncached_ids as $uncached_id ) {
    238             // Cache empty values as well
     236            // Cache empty values as well.
    239237            if ( ! isset( $cache[ $uncached_id ] ) ) {
    240238                $cache[ $uncached_id ] = array();
  • trunk/src/bp-core/bp-core-caps.php

    r10108 r10356  
    2525    global $wp_roles;
    2626
    27     // Sanity check on roles global variable
     27    // Sanity check on roles global variable.
    2828    $roles = isset( $wp_roles->roles )
    2929        ? $wp_roles->roles
     
    6464    global $wp_roles;
    6565
    66     // Load roles if not set
     66    // Load roles if not set.
    6767    if ( ! isset( $wp_roles ) ) {
    6868        $wp_roles = new WP_Roles();
    6969    }
    7070
    71     // Loop through available roles and add them
     71    // Loop through available roles and add them.
    7272    foreach( $wp_roles->role_objects as $role ) {
    7373        foreach ( bp_get_caps_for_role( $role->name ) as $cap ) {
     
    100100    global $wp_roles;
    101101
    102     // Load roles if not set
     102    // Load roles if not set.
    103103    if ( ! isset( $wp_roles ) ) {
    104104        $wp_roles = new WP_Roles();
    105105    }
    106106
    107     // Loop through available roles and remove them
     107    // Loop through available roles and remove them.
    108108    foreach( $wp_roles->role_objects as $role ) {
    109109        foreach ( bp_get_caps_for_role( $role->name ) as $cap ) {
     
    136136 * @param int    $user_id See {@link WP_User::has_cap()}.
    137137 * @param mixed  $args    See {@link WP_User::has_cap()}.
    138  *
    139138 * @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}.
    140139 */
     
    165164function bp_get_community_caps() {
    166165
    167     // Forum meta caps
     166    // Forum meta caps.
    168167    $caps = array();
    169168
     
    186185 *
    187186 * @param string $role The role for which you're loading caps.
    188  *
    189187 * @return array Capabilities for $role.
    190188 */
     
    194192    switch ( $role ) {
    195193
    196         // Administrator
     194        // Administrator.
    197195        case 'administrator' :
    198196            $caps = array(
    199                 // Misc
     197                // Misc.
    200198                'bp_moderate',
    201199            );
     
    203201            break;
    204202
    205         // All other default WordPress blog roles
     203        // All other default WordPress blog roles.
    206204        case 'editor'      :
    207205        case 'author'      :
     
    243241function bp_set_current_user_default_role() {
    244242
    245     // Bail if not multisite or not root blog
     243    // Bail if not multisite or not root blog.
    246244    if ( ! is_multisite() || ! bp_is_root_blog() ) {
    247245        return;
    248246    }
    249247
    250     // Bail if user is not logged in or already a member
     248    // Bail if user is not logged in or already a member.
    251249    if ( ! is_user_logged_in() || is_user_member_of_blog() ) {
    252250        return;
    253251    }
    254252
    255     // Bail if user is not active
     253    // Bail if user is not active.
    256254    if ( bp_is_user_inactive() ) {
    257255        return;
    258256    }
    259257
    260     // Set the current users default role
     258    // Set the current users default role.
    261259    buddypress()->current_user->set_role( bp_get_option( 'default_role', 'subscriber' ) );
    262260}
     
    274272 *     @type mixed $a,...   Optional. Extra arguments applicable to the capability check.
    275273 * }
    276  *
    277274 * @return bool True if the user has the cap for the given parameters.
    278275 */
     
    292289    }
    293290
    294     // Use root blog if no ID passed
     291    // Use root blog if no ID passed.
    295292    if ( empty( $blog_id ) ) {
    296293        $blog_id = bp_get_root_blog_id();
     
    341338 * @param int    $user_id ID of the user being checked against.
    342339 * @param array  $args    Miscellaneous arguments passed to the user_has_cap filter.
    343  *
    344340 * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
    345341 */
    346342function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
    347343
    348     // Bail if not checking the 'bp_moderate' cap
     344    // Bail if not checking the 'bp_moderate' cap.
    349345    if ( 'bp_moderate' !== $cap ) {
    350346        return $caps;
    351347    }
    352348
    353     // Bail if BuddyPress is not network activated
     349    // Bail if BuddyPress is not network activated.
    354350    if ( bp_is_network_activated() ) {
    355351        return $caps;
    356352    }
    357353
    358     // Never trust inactive users
     354    // Never trust inactive users.
    359355    if ( bp_is_user_inactive( $user_id ) ) {
    360356        return $caps;
    361357    }
    362358
    363     // Only users that can 'manage_options' on this site can 'bp_moderate'
     359    // Only users that can 'manage_options' on this site can 'bp_moderate'.
    364360    return array( 'manage_options' );
    365361}
  • trunk/src/bp-core/bp-core-catchuri.php

    r10212 r10356  
    3535    global $current_blog, $wp_rewrite;
    3636
    37     // Don't catch URIs on non-root blogs unless multiblog mode is on
     37    // Don't catch URIs on non-root blogs unless multiblog mode is on.
    3838    if ( !bp_is_root_blog() && !bp_is_multiblog_mode() )
    3939        return false;
     
    4141    $bp = buddypress();
    4242
    43     // Define local variables
     43    // Define local variables.
    4444    $root_profile = $match   = false;
    4545    $key_slugs    = $matches = $uri_chunks = array();
    4646
    47     // Fetch all the WP page names for each component
     47    // Fetch all the WP page names for each component.
    4848    if ( empty( $bp->pages ) )
    4949        $bp->pages = bp_core_get_directory_pages();
     
    6464    $path = apply_filters( 'bp_uri', $path );
    6565
    66     // Take GET variables off the URL to avoid problems
     66    // Take GET variables off the URL to avoid problems.
    6767    $path = strtok( $path, '?' );
    6868
    69     // Fetch current URI and explode each part separated by '/' into an array
     69    // Fetch current URI and explode each part separated by '/' into an array.
    7070    $bp_uri = explode( '/', $path );
    7171
    72     // Loop and remove empties
     72    // Loop and remove empties.
    7373    foreach ( (array) $bp_uri as $key => $uri_chunk ) {
    7474        if ( empty( $bp_uri[$key] ) ) {
     
    8080    // removed from $bp_uri. This includes two cases:
    8181    //
    82     //    1. when WP is installed in a subdirectory,
    83     //    2. when BP is running on secondary blog of a subdirectory
    84     //       multisite installation. Phew!
     82    // 1. when WP is installed in a subdirectory,
     83    // 2. when BP is running on secondary blog of a subdirectory
     84    // multisite installation. Phew!
    8585    if ( is_multisite() && !is_subdomain_install() && ( bp_is_multiblog_mode() || 1 != bp_get_root_blog_id() ) ) {
    8686
    87         // Blow chunks
     87        // Blow chunks.
    8888        $chunks = explode( '/', $current_blog->path );
    8989
     
    105105    }
    106106
    107     // Get site path items
     107    // Get site path items.
    108108    $paths = explode( '/', bp_core_get_site_path() );
    109109
    110     // Take empties off the end of path
     110    // Take empties off the end of path.
    111111    if ( empty( $paths[count( $paths ) - 1] ) )
    112112        array_pop( $paths );
    113113
    114     // Take empties off the start of path
     114    // Take empties off the start of path.
    115115    if ( empty( $paths[0] ) )
    116116        array_shift( $paths );
    117117
    118     // Reset indexes
     118    // Reset indexes.
    119119    $bp_uri = array_values( $bp_uri );
    120120    $paths  = array_values( $paths );
    121121
    122     // Unset URI indices if they intersect with the paths
     122    // Unset URI indices if they intersect with the paths.
    123123    foreach ( (array) $bp_uri as $key => $uri_chunk ) {
    124124        if ( isset( $paths[$key] ) && $uri_chunk == $paths[$key] ) {
     
    127127    }
    128128
    129     // Reset the keys by merging with an empty array
     129    // Reset the keys by merging with an empty array.
    130130    $bp_uri = array_merge( array(), $bp_uri );
    131131
    132132    // If a component is set to the front page, force its name into $bp_uri
    133133    // so that $current_component is populated (unless a specific WP post is being requested
    134     // via a URL parameter, usually signifying Preview mode)
     134    // via a URL parameter, usually signifying Preview mode).
    135135    if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && empty( $bp_uri ) && empty( $_GET['p'] ) && empty( $_GET['page_id'] ) ) {
    136136        $post = get_post( get_option( 'page_on_front' ) );
     
    140140    }
    141141
    142     // Keep the unfiltered URI safe
     142    // Keep the unfiltered URI safe.
    143143    $bp->unfiltered_uri = $bp_uri;
    144144
     
    146146    $GLOBALS['bp_unfiltered_uri'] = &$bp->unfiltered_uri;
    147147
    148     // Get slugs of pages into array
     148    // Get slugs of pages into array.
    149149    foreach ( (array) $bp->pages as $page_key => $bp_page )
    150150        $key_slugs[$page_key] = trailingslashit( '/' . $bp_page->slug );
    151151
    152     // Bail if keyslugs are empty, as BP is not setup correct
     152    // Bail if keyslugs are empty, as BP is not setup correct.
    153153    if ( empty( $key_slugs ) )
    154154        return;
    155155
    156     // Loop through page slugs and look for exact match to path
     156    // Loop through page slugs and look for exact match to path.
    157157    foreach ( $key_slugs as $key => $slug ) {
    158158        if ( $slug == $path ) {
     
    164164    }
    165165
    166     // No exact match, so look for partials
     166    // No exact match, so look for partials.
    167167    if ( empty( $match ) ) {
    168168
    169         // Loop through each page in the $bp->pages global
     169        // Loop through each page in the $bp->pages global.
    170170        foreach ( (array) $bp->pages as $page_key => $bp_page ) {
    171171
    172             // Look for a match (check members first)
     172            // Look for a match (check members first).
    173173            if ( in_array( $bp_page->name, (array) $bp_uri ) ) {
    174174
     
    176176                $uri_chunks = explode( '/', $bp_page->slug );
    177177
    178                 // Loop through uri_chunks
     178                // Loop through uri_chunks.
    179179                foreach ( (array) $uri_chunks as $key => $uri_chunk ) {
    180180
    181                     // Make sure chunk is in the correct position
     181                    // Make sure chunk is in the correct position.
    182182                    if ( !empty( $bp_uri[$key] ) && ( $bp_uri[$key] == $uri_chunk ) ) {
    183183                        $matches[] = 1;
    184184
    185                     // No match
     185                    // No match.
    186186                    } else {
    187187                        $matches[] = 0;
     
    189189                }
    190190
    191                 // Have a match
     191                // Have a match.
    192192                if ( !in_array( 0, (array) $matches ) ) {
    193193                    $match      = $bp_page;
     
    196196                };
    197197
    198                 // Unset matches
     198                // Unset matches.
    199199                unset( $matches );
    200200            }
    201201
    202             // Unset uri chunks
     202            // Unset uri chunks.
    203203            unset( $uri_chunks );
    204204        }
    205205    }
    206206
    207     // URLs with BP_ENABLE_ROOT_PROFILES enabled won't be caught above
     207    // URLs with BP_ENABLE_ROOT_PROFILES enabled won't be caught above.
    208208    if ( empty( $matches ) && bp_core_enable_root_profiles() ) {
    209209
    210         // Switch field based on compat
     210        // Switch field based on compat.
    211211        $field = bp_is_username_compatibility_mode() ? 'login' : 'slug';
    212212
    213         // Make sure there's a user corresponding to $bp_uri[0]
     213        // Make sure there's a user corresponding to $bp_uri[0].
    214214        if ( !empty( $bp->pages->members ) && !empty( $bp_uri[0] ) && $root_profile = get_user_by( $field, $bp_uri[0] ) ) {
    215215
    216             // Force BP to recognize that this is a members page
     216            // Force BP to recognize that this is a members page.
    217217            $matches[]  = 1;
    218218            $match      = $bp->pages->members;
     
    221221    }
    222222
    223     // Search doesn't have an associated page, so we check for it separately
     223    // Search doesn't have an associated page, so we check for it separately.
    224224    if ( !empty( $bp_uri[0] ) && ( bp_get_search_slug() == $bp_uri[0] ) ) {
    225225        $matches[]   = 1;
     
    235235    $wp_rewrite->use_verbose_page_rules = false;
    236236
    237     // Find the offset. With $root_profile set, we fudge the offset down so later parsing works
     237    // Find the offset. With $root_profile set, we fudge the offset down so later parsing works.
    238238    $slug       = !empty ( $match ) ? explode( '/', $match->slug ) : '';
    239239    $uri_offset = empty( $root_profile ) ? 0 : -1;
    240240
    241     // Rejig the offset
     241    // Rejig the offset.
    242242    if ( !empty( $slug ) && ( 1 < count( $slug ) ) ) {
    243243        // Only offset if not on a root profile. Fixes issue when Members page is nested.
     
    249249
    250250    // Global the unfiltered offset to use in bp_core_load_template().
    251     // To avoid PHP warnings in bp_core_load_template(), it must always be >= 0
     251    // To avoid PHP warnings in bp_core_load_template(), it must always be >= 0.
    252252    $bp->unfiltered_uri_offset = $uri_offset >= 0 ? $uri_offset : 0;
    253253
    254     // We have an exact match
     254    // We have an exact match.
    255255    if ( isset( $match->key ) ) {
    256256
    257         // Set current component to matched key
     257        // Set current component to matched key.
    258258        $bp->current_component = $match->key;
    259259
    260         // If members component, do more work to find the actual component
     260        // If members component, do more work to find the actual component.
    261261        if ( 'members' == $match->key ) {
    262262
     
    268268            // Are we viewing a specific user?
    269269            if ( $after_member_slug ) {
    270                 // If root profile, we've already queried for the user
     270                // If root profile, we've already queried for the user.
    271271                if ( $root_profile instanceof WP_User ) {
    272272                    $bp->displayed_user->id = $root_profile->ID;
    273273
    274                 // Switch the displayed_user based on compatibility mode
     274                // Switch the displayed_user based on compatibility mode.
    275275                } elseif ( bp_is_username_compatibility_mode() ) {
    276276                    $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $after_member_slug ) );
     
    302302            }
    303303
    304             // If the displayed user is marked as a spammer, 404 (unless logged-in user is a super admin)
     304            // If the displayed user is marked as a spammer, 404 (unless logged-in user is a super admin).
    305305            if ( bp_displayed_user_id() && bp_is_user_spammer( bp_displayed_user_id() ) ) {
    306306                if ( bp_current_user_can( 'bp_moderate' ) ) {
     
    318318                    $bp->current_component = $bp_uri[0];
    319319
    320                 // No component, so default will be picked later
     320                // No component, so default will be picked later.
    321321                } else {
    322322                    $bp_uri                = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
     
    324324                }
    325325
    326                 // Reset the offset
     326                // Reset the offset.
    327327                $uri_offset = 0;
    328328            }
     
    347347    $bp->current_action = $current_action;
    348348
    349     // Slice the rest of the $bp_uri array and reset offset
     349    // Slice the rest of the $bp_uri array and reset offset.
    350350    $bp_uri      = array_slice( $bp_uri, $uri_offset + 2 );
    351351    $uri_offset  = 0;
    352352
    353     // Set the entire URI as the action variables, we will unset the current_component and action in a second
     353    // Set the entire URI as the action variables, we will unset the current_component and action in a second.
    354354    $bp->action_variables = $bp_uri;
    355355
    356     // Reset the keys by merging with an empty array
     356    // Reset the keys by merging with an empty array.
    357357    $bp->action_variables = array_merge( array(), $bp->action_variables );
    358358}
     
    391391 *
    392392 * @param array $templates Array of templates to attempt to load.
    393  *
    394  * @return bool|null Returns false on failure.
    395393 */
    396394function bp_core_load_template( $templates ) {
    397395    global $wp_query;
    398396
    399     // Reset the post
     397    // Reset the post.
    400398    bp_theme_compat_reset_post( array(
    401399        'ID'          => 0,
     
    405403
    406404    // Set theme compat to false since the reset post function automatically sets
    407     // theme compat to true
     405    // theme compat to true.
    408406    bp_set_theme_compat_active( false );
    409407
    410     // Fetch each template and add the php suffix
     408    // Fetch each template and add the php suffix.
    411409    $filtered_templates = array();
    412410    foreach ( (array) $templates as $template ) {
     
    414412    }
    415413
    416     // Only perform template lookup for bp-default themes
     414    // Only perform template lookup for bp-default themes.
    417415    if ( ! bp_use_theme_compat_with_current_theme() ) {
    418416        $template = locate_template( (array) $filtered_templates, false );
    419417
    420     // Theme compat doesn't require a template lookup
     418    // Theme compat doesn't require a template lookup.
    421419    } else {
    422420        $template = '';
     
    471469        exit();
    472470
    473     // No template found, so setup theme compatibility
    474     // @todo Some other 404 handling if theme compat doesn't kick in
     471    // No template found, so setup theme compatibility.
     472    // @todo Some other 404 handling if theme compat doesn't kick in.
    475473    } else {
    476474
     
    554552function bp_core_no_access( $args = '' ) {
    555553
    556     // Build the redirect URL
     554    // Build the redirect URL.
    557555    $redirect_url  = is_ssl() ? 'https://' : 'http://';
    558556    $redirect_url .= $_SERVER['HTTP_HOST'];
     
    578576    extract( $r, EXTR_SKIP );
    579577
    580     /**
     578    /*
    581579     * @ignore Ignore these filters and use 'bp_core_no_access' above
    582580     */
     
    590588
    591589        // Option to redirect to wp-login.php
    592         // Error message is displayed with bp_core_no_access_wp_login_error()
     590        // Error message is displayed with bp_core_no_access_wp_login_error().
    593591        case 2 :
    594592            if ( !empty( $redirect ) ) {
     
    601599
    602600        // Redirect to root with "redirect_to" parameter
    603         // Error message is displayed with bp_core_add_message()
     601        // Error message is displayed with bp_core_add_message().
    604602        case 1 :
    605603        default :
     
    642640    $error = apply_filters( 'bp_wp_login_error', __( 'You must log in to access the page you requested.', 'buddypress' ), $_REQUEST['redirect_to'] );
    643641
    644     // shake shake shake!
     642    // Shake shake shake!.
    645643    add_action( 'login_head', 'wp_shake_js', 12 );
    646644}
     
    682680        }
    683681
    684         // build the URL in the address bar
     682        // Build the URL in the address bar.
    685683        $requested_url  = bp_get_requested_url();
    686684
    687         // Stash query args
     685        // Stash query args.
    688686        $url_stack      = explode( '?', $requested_url );
    689687        $req_url_clean  = $url_stack[0];
     
    692690        $canonical_url  = bp_get_canonical_url();
    693691
    694         // Only redirect if we've assembled a URL different from the request
     692        // Only redirect if we've assembled a URL different from the request.
    695693        if ( $canonical_url !== $req_url_clean ) {
    696694
     
    698696
    699697            // Template messages have been deleted from the cookie by this point, so
    700             // they must be readded before redirecting
     698            // they must be readded before redirecting.
    701699            if ( isset( $bp->template_message ) ) {
    702700                $message      = stripslashes( $bp->template_message );
     
    723721    $canonical_url = bp_get_canonical_url();
    724722
    725     // Output rel=canonical tag
     723    // Output rel=canonical tag.
    726724    echo "<link rel='canonical' href='" . esc_attr( $canonical_url ) . "' />\n";
    727725}
     
    739737 *                                    in the canonical URL returned from the function.
    740738 * }
    741  *
    742739 * @return string Canonical URL for the current page.
    743740 */
    744741function bp_get_canonical_url( $args = array() ) {
    745742
    746     // For non-BP content, return the requested url, and let WP do the work
     743    // For non-BP content, return the requested url, and let WP do the work.
    747744    if ( bp_is_blog_page() ) {
    748745        return bp_get_requested_url();
     
    752749
    753750    $defaults = array(
    754         'include_query_args' => false // Include URL arguments, eg ?foo=bar&foo2=bar2
     751        'include_query_args' => false // Include URL arguments, eg ?foo=bar&foo2=bar2.
    755752    );
    756753    $r = wp_parse_args( $args, $defaults );
     
    766763        // URL is the front page. We detect whether we're detecting a
    767764        // component *directory* by checking that bp_current_action()
    768         // is empty - ie, this not a single item or a feed
     765        // is empty - ie, this not a single item or a feed.
    769766        if ( false !== $front_page_component && bp_is_current_component( $front_page_component ) && ! bp_current_action() ) {
    770767            $bp->canonical_stack['canonical_url'] = trailingslashit( bp_get_root_domain() );
     
    772769        // Except when the front page is set to the registration page
    773770        // and the current user is logged in. In this case we send to
    774         // the members directory to avoid redirect loops
     771        // the members directory to avoid redirect loops.
    775772        } elseif ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
    776773
     
    787784
    788785    if ( empty( $bp->canonical_stack['canonical_url'] ) ) {
    789         // Build the URL in the address bar
     786        // Build the URL in the address bar.
    790787        $requested_url  = bp_get_requested_url();
    791788
    792         // Stash query args
     789        // Stash query args.
    793790        $url_stack      = explode( '?', $requested_url );
    794791
    795         // Build the canonical URL out of the redirect stack
     792        // Build the canonical URL out of the redirect stack.
    796793        if ( isset( $bp->canonical_stack['base_url'] ) )
    797794            $url_stack[0] = $bp->canonical_stack['base_url'];
     
    809806        }
    810807
    811         // Add trailing slash
     808        // Add trailing slash.
    812809        $url_stack[0] = trailingslashit( $url_stack[0] );
    813810
    814         // Stash in the $bp global
     811        // Stash in the $bp global.
    815812        $bp->canonical_stack['canonical_url'] = implode( '?', $url_stack );
    816813    }
  • trunk/src/bp-core/bp-core-component.php

    r10110 r10356  
    1919 * internally by BuddyPress to create the bundled components, but can be
    2020 * extended to create other really neat things.
    21  *
    22  * @package BuddyPress
    23  * @subpackage Component
    2421 *
    2522 * @since 1.5.0
     
    161158    public function start( $id = '', $name = '', $path = '', $params = array() ) {
    162159
    163         // Internal identifier of component
     160        // Internal identifier of component.
    164161        $this->id   = $id;
    165162
    166         // Internal component name
     163        // Internal component name.
    167164        $this->name = $name;
    168165
    169         // Path for includes
     166        // Path for includes.
    170167        $this->path = $path;
    171168
    172         // Miscellaneous component parameters that need to be set early on
     169        // Miscellaneous component parameters that need to be set early on.
    173170        if ( ! empty( $params ) ) {
    174             // Sets the position for our menu under the WP Toolbar's "My Account" menu
     171            // Sets the position for our menu under the WP Toolbar's "My Account" menu.
    175172            if ( ! empty( $params['adminbar_myaccount_order'] ) ) {
    176173                $this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order'];
    177174            }
    178175
    179             // Register features
     176            // Register features.
    180177            if ( ! empty( $params['features'] ) ) {
    181178                $this->features = array_map( 'sanitize_title', (array) $params['features'] );
     
    186183            }
    187184
    188         // Set defaults if not passed
     185        // Set defaults if not passed.
    189186        } else {
    190             // new component menus are added before the settings menu if not set
     187            // New component menus are added before the settings menu if not set.
    191188            $this->adminbar_myaccount_order = 90;
    192189        }
    193190
    194         // Move on to the next step
     191        // Move on to the next step.
    195192        $this->setup_actions();
    196193    }
     
    222219    public function setup_globals( $args = array() ) {
    223220
    224         /** Slugs *************************************************************/
     221        /** Slugs ************************************************************
     222         */
    225223
    226224        // If a WP directory page exists for the component, it should
     
    293291        $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
    294292
    295         // Set the global table names, if applicable
     293        // Set the global table names, if applicable.
    296294        if ( ! empty( $r['global_tables'] ) ) {
    297295            $this->register_global_tables( $r['global_tables'] );
    298296        }
    299297
    300         // Set the metadata table, if applicable
     298        // Set the metadata table, if applicable.
    301299        if ( ! empty( $r['meta_tables'] ) ) {
    302300            $this->register_meta_tables( $r['meta_tables'] );
    303301        }
    304302
    305         /** BuddyPress ********************************************************/
    306 
    307         // Register this component in the loaded components array
     303        /** BuddyPress *******************************************************
     304         */
     305
     306        // Register this component in the loaded components array.
    308307        buddypress()->loaded_components[$this->slug] = $this->id;
    309308
     
    350349    public function includes( $includes = array() ) {
    351350
    352         // Bail if no files to include
     351        // Bail if no files to include.
    353352        if ( ! empty( $includes ) ) {
    354353            $slashed_path = trailingslashit( $this->path );
    355354
    356             // Loop through files to be included
     355            // Loop through files to be included.
    357356            foreach ( (array) $includes as $file ) {
    358357
    359358                $paths = array(
    360359
    361                     // Passed with no extension
     360                    // Passed with no extension.
    362361                    'bp-' . $this->id . '/bp-' . $this->id . '-' . $file  . '.php',
    363362                    'bp-' . $this->id . '-' . $file . '.php',
    364363                    'bp-' . $this->id . '/' . $file . '.php',
    365364
    366                     // Passed with extension
     365                    // Passed with extension.
    367366                    $file,
    368367                    'bp-' . $this->id . '-' . $file,
     
    399398    public function setup_actions() {
    400399
    401         // Setup globals
     400        // Setup globals.
    402401        add_action( 'bp_setup_globals',          array( $this, 'setup_globals'          ), 10 );
    403402
    404         // Set up canonical stack
     403        // Set up canonical stack.
    405404        add_action( 'bp_setup_canonical_stack',  array( $this, 'setup_canonical_stack'  ), 10 );
    406405
     
    412411        add_action( 'bp_include',                array( $this, 'includes'               ), 8 );
    413412
    414         // Setup navigation
     413        // Setup navigation.
    415414        add_action( 'bp_setup_nav',              array( $this, 'setup_nav'              ), 10 );
    416415
    417         // Setup WP Toolbar menus
     416        // Setup WP Toolbar menus.
    418417        add_action( 'bp_setup_admin_bar',        array( $this, 'setup_admin_bar'        ), $this->adminbar_myaccount_order );
    419418
    420         // Setup component title
     419        // Setup component title.
    421420        add_action( 'bp_setup_title',            array( $this, 'setup_title'            ), 10 );
    422421
    423         // Setup cache groups
     422        // Setup cache groups.
    424423        add_action( 'bp_setup_cache_groups',     array( $this, 'setup_cache_groups'     ), 10 );
    425424
    426         // Register post types
     425        // Register post types.
    427426        add_action( 'bp_register_post_types',    array( $this, 'register_post_types'    ), 10 );
    428427
    429         // Register taxonomies
     428        // Register taxonomies.
    430429        add_action( 'bp_register_taxonomies',    array( $this, 'register_taxonomies'    ), 10 );
    431430
    432         // Add the rewrite tags
     431        // Add the rewrite tags.
    433432        add_action( 'bp_add_rewrite_tags',       array( $this, 'add_rewrite_tags'       ), 10 );
    434433
    435         // Add the rewrite rules
     434        // Add the rewrite rules.
    436435        add_action( 'bp_add_rewrite_rules',      array( $this, 'add_rewrite_rules'      ), 10 );
    437436
    438         // Add the permalink structure
     437        // Add the permalink structure.
    439438        add_action( 'bp_add_permastructs',       array( $this, 'add_permastructs'       ), 10 );
    440439
    441         // Allow components to parse the main query
     440        // Allow components to parse the main query.
    442441        add_action( 'bp_parse_query',            array( $this, 'parse_query'            ), 10 );
    443442
    444         // Generate rewrite rules
     443        // Generate rewrite rules.
    445444        add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
    446445
     
    478477    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    479478
    480         // No sub nav items without a main nav item
     479        // No sub nav items without a main nav item.
    481480        if ( !empty( $main_nav ) ) {
    482481            bp_core_new_nav_item( $main_nav );
    483482
    484             // Sub nav items are not required
     483            // Sub nav items are not required.
    485484            if ( !empty( $sub_nav ) ) {
    486485                foreach( (array) $sub_nav as $nav ) {
     
    514513    public function setup_admin_bar( $wp_admin_nav = array() ) {
    515514
    516         // Bail if this is an ajax request
     515        // Bail if this is an ajax request.
    517516        if ( defined( 'DOING_AJAX' ) ) {
    518517            return;
    519518        }
    520519
    521         // Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false
     520        // Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false.
    522521        if ( ! bp_use_wp_admin_bar() ) {
    523522            return;
     
    538537        if ( !empty( $wp_admin_nav ) ) {
    539538
    540             // Set this objects menus
     539            // Set this objects menus.
    541540            $this->admin_menu = $wp_admin_nav;
    542541
    543             // Define the WordPress global
     542            // Define the WordPress global.
    544543            global $wp_admin_bar;
    545544
    546             // Add each admin menu
     545            // Add each admin menu.
    547546            foreach( $this->admin_menu as $admin_menu ) {
    548547                $wp_admin_bar->add_menu( $admin_menu );
     
    618617        $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
    619618
    620         // Add to the BuddyPress global object
     619        // Add to the BuddyPress global object.
    621620        if ( !empty( $tables ) && is_array( $tables ) ) {
    622621            foreach ( $tables as $global_name => $table_name ) {
     
    624623            }
    625624
    626             // Keep a record of the metadata tables in the component
     625            // Keep a record of the metadata tables in the component.
    627626            $this->global_tables = $tables;
    628627        }
     
    671670            }
    672671
    673             // Keep a record of the metadata tables in the component
     672            // Keep a record of the metadata tables in the component.
    674673            $this->meta_tables = $tables;
    675674        }
  • trunk/src/bp-core/bp-core-cssjs.php

    r10155 r10356  
    2828    $scripts = apply_filters( 'bp_core_register_common_scripts', array(
    2929
    30         // Legacy
     30        // Legacy.
    3131        'bp-confirm'        => array( 'file' => "{$url}confirm{$min}.js",        'dependencies' => array( 'jquery' ), 'footer' => false ),
    3232        'bp-widget-members' => array( 'file' => "{$url}widget-members{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => false ),
     
    133133    }
    134134
    135     // Enqueue the Attachments scripts for the Avatar UI
     135    // Enqueue the Attachments scripts for the Avatar UI.
    136136    bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' );
    137137
    138     // Add Some actions for Theme backcompat
     138    // Add Some actions for Theme backcompat.
    139139    add_action( 'bp_after_profile_avatar_upload_content', 'bp_avatar_template_check' );
    140140    add_action( 'bp_after_group_admin_content',           'bp_avatar_template_check' );
     
    153153    }
    154154
    155     // Enqueue the Attachments scripts for the Cover Image UI
     155    // Enqueue the Attachments scripts for the Cover Image UI.
    156156    bp_attachments_enqueue_scripts( 'BP_Attachment_Cover_Image' );
    157157}
     
    185185    }
    186186
    187     // Get avatar full width and height
     187    // Get avatar full width and height.
    188188    $full_height = bp_core_avatar_full_height();
    189189    $full_width  = bp_core_avatar_full_width();
    190190
    191     // Calculate Aspect Ratio
     191    // Calculate Aspect Ratio.
    192192    if ( !empty( $full_height ) && ( $full_width != $full_height ) ) {
    193193        $aspect_ratio = $full_width / $full_height;
     
    196196    }
    197197
    198     // Default cropper coordinates
    199 
    200     // Smaller than full-width: cropper defaults to entire image
     198    // Default cropper coordinates.
     199    // Smaller than full-width: cropper defaults to entire image.
    201200    if ( $image[0] < $full_width ) {
    202201        $crop_left  = 0;
    203202        $crop_right = $image[0];
    204203
    205     // Less than 2x full-width: cropper defaults to full-width
     204    // Less than 2x full-width: cropper defaults to full-width.
    206205    } elseif ( $image[0] < ( $full_width * 2 ) ) {
    207206        $padding_w  = round( ( $image[0] - $full_width ) / 2 );
     
    209208        $crop_right = $image[0] - $padding_w;
    210209
    211     // Larger than 2x full-width: cropper defaults to 1/2 image width
     210    // Larger than 2x full-width: cropper defaults to 1/2 image width.
    212211    } else {
    213212        $crop_left  = round( $image[0] / 4 );
     
    215214    }
    216215
    217     // Smaller than full-height: cropper defaults to entire image
     216    // Smaller than full-height: cropper defaults to entire image.
    218217    if ( $image[1] < $full_height ) {
    219218        $crop_top    = 0;
    220219        $crop_bottom = $image[1];
    221220
    222     // Less than double full-height: cropper defaults to full-height
     221    // Less than double full-height: cropper defaults to full-height.
    223222    } elseif ( $image[1] < ( $full_height * 2 ) ) {
    224223        $padding_h   = round( ( $image[1] - $full_height ) / 2 );
     
    226225        $crop_bottom = $image[1] - $padding_h;
    227226
    228     // Larger than 2x full-height: cropper defaults to 1/2 image height
     227    // Larger than 2x full-height: cropper defaults to 1/2 image height.
    229228    } else {
    230229        $crop_top    = round( $image[1] / 4 );
     
    273272/**
    274273 * Output the inline CSS for the BP image cropper.
    275  *
    276  * @package BuddyPress Core
    277274 */
    278275function bp_core_add_cropper_inline_css() {
     
    362359 * @since 2.4.0
    363360 *
    364  * @param  bool $return true to get the inline css
     361 * @param  bool $return True to get the inline css.
    365362 * @return string|array the inline css or an associative array containing
    366363 *                      the css rules and the style handle
     
    369366    $bp = buddypress();
    370367
    371     // Find the component of the current item
     368    // Find the component of the current item.
    372369    if ( bp_is_user() ) {
    373370
    374371        // User is not allowed to upload cover images
    375         // no need to carry on
     372        // no need to carry on.
    376373        if ( bp_disable_cover_image_uploads() ) {
    377374            return;
     
    385382
    386383        // Users are not allowed to upload cover images for their groups
    387         // no need to carry on
     384        // no need to carry on.
    388385        if ( bp_disable_group_cover_image_uploads() ) {
    389386            return;
     
    403400    }
    404401
    405     // Get the settings of the cover image feature for the current component
     402    // Get the settings of the cover image feature for the current component.
    406403    $params = bp_attachments_get_cover_image_settings( $cover_image_object['component'] );
    407404
     
    411408    }
    412409
    413     // Try to call the callback
     410    // Try to call the callback.
    414411    if ( is_callable( $params['callback'] ) ) {
    415412
     
    439436        ) ) );
    440437
    441         // Finally add the inline css to the handle
     438        // Finally add the inline css to the handle.
    442439        if ( ! empty( $inline_css ) ) {
    443440
    444             // Used to get the css when Ajax setting the cover image
     441            // Used to get the css when Ajax setting the cover image.
    445442            if ( true === $return ) {
    446443                return array(
  • trunk/src/bp-core/bp-core-dependency.php

    r10108 r10356  
    490490 *
    491491 * @param array $query_vars See {@link WP::parse_request()}.
    492  *
    493492 * @return array $query_vars See {@link WP::parse_request()}.
    494493 */
     
    512511 * @param string $redirect_to     See 'login_redirect'.
    513512 * @param string $redirect_to_raw See 'login_redirect'.
    514  *
    515  * @param bool   $user See 'login_redirect'.
    516  *
     513 * @param bool   $user            See 'login_redirect'.
    517514 * @return string
    518515 */
     
    541538 *
    542539 * @param string $template See 'template_include'.
    543  *
    544540 * @return string Template file to use.
    545541 */
     
    586582 * @uses apply_filters() Calls 'bp_allowed_themes' with the allowed themes list.
    587583 *
    588  * @param array $themes
    589  *
     584 * @param array $themes The path of the template to include.
    590585 * @return array
    591586 */
     
    608603 *
    609604 * @since 1.9.0
     605 *
    610606 * @uses do_action()
    611607 */
    612608function bp_post_request() {
    613609
    614     // Bail if not a POST action
     610    // Bail if not a POST action.
    615611    if ( ! bp_is_post_request() ) {
    616612        return;
    617613    }
    618614
    619     // Bail if no action
     615    // Bail if no action.
    620616    if ( empty( $_POST['action'] ) ) {
    621617        return;
    622618    }
    623619
    624     // Sanitize the POST action
     620    // Sanitize the POST action.
    625621    $action = sanitize_key( $_POST['action'] );
    626622
     
    651647 *
    652648 * @since 1.9.0
     649 *
    653650 * @uses do_action()
    654651 */
    655652function bp_get_request() {
    656653
    657     // Bail if not a POST action
     654    // Bail if not a POST action.
    658655    if ( ! bp_is_get_request() ) {
    659656        return;
    660657    }
    661658
    662     // Bail if no action
     659    // Bail if no action.
    663660    if ( empty( $_GET['action'] ) ) {
    664661        return;
    665662    }
    666663
    667     // Sanitize the GET action
     664    // Sanitize the GET action.
    668665    $action = sanitize_key( $_GET['action'] );
    669666
  • trunk/src/bp-core/bp-core-filters.php

    r10276 r10356  
    4444add_filter( 'map_meta_cap',            'bp_map_meta_caps',       10, 4 );
    4545
    46 // Add some filters to feedback messages
     46// Add some filters to feedback messages.
    4747add_filter( 'bp_core_render_message_content', 'wptexturize'       );
    4848add_filter( 'bp_core_render_message_content', 'convert_smilies'   );
     
    6262add_filter( 'bp_template_include',   'bp_template_include_theme_compat',   4, 2 );
    6363
    64 // Filter BuddyPress template locations
     64// Filter BuddyPress template locations.
    6565add_filter( 'bp_get_template_stack', 'bp_add_template_stack_locations' );
    6666
    67 // Turn comments off for BuddyPress pages
     67// Turn comments off for BuddyPress pages.
    6868add_filter( 'comments_open', 'bp_comments_open', 10, 2 );
    6969
     
    7575 * @param array $pages List of excluded page IDs, as passed to the
    7676 *                     'wp_list_pages_excludes' filter.
    77  *
    7877 * @return array The exclude list, with BP's pages added.
    7978 */
    8079function bp_core_exclude_pages( $pages = array() ) {
    8180
    82     // Bail if not the root blog
     81    // Bail if not the root blog.
    8382    if ( ! bp_is_root_blog() )
    8483        return $pages;
     
    115114 *
    116115 * @param object|null $object The post type object used in the meta box.
    117  *
    118116 * @return object|null The $object, with a query argument to remove register and activate pages id.
    119117 */
    120118function bp_core_exclude_pages_from_nav_menu_admin( $object = null ) {
    121119
    122     // Bail if not the root blog
     120    // Bail if not the root blog.
    123121    if ( ! bp_is_root_blog() ) {
    124122        return $object;
     
    160158 * @param array   $retval CSS classes for the current menu page in the menu.
    161159 * @param WP_Post $page   The page properties for the current menu item.
    162  *
    163160 * @return array
    164161 */
     
    170167    $page_id = false;
    171168
    172     // loop against all BP component pages
     169    // Loop against all BP component pages.
    173170    foreach ( (array) buddypress()->pages as $component => $bp_page ) {
    174         // handles the majority of components
     171        // Handles the majority of components.
    175172        if ( bp_is_current_component( $component ) ) {
    176173                    $page_id = (int) $bp_page->id;
    177174        }
    178175
    179         // stop if not on a user page
     176        // Stop if not on a user page.
    180177        if ( ! bp_is_user() && ! empty( $page_id ) ) {
    181178            break;
    182179        }
    183180
    184         // members component requires an explicit check due to overlapping components
     181        // Members component requires an explicit check due to overlapping components.
    185182        if ( bp_is_user() && 'members' === $component ) {
    186183            $page_id = (int) $bp_page->id;
     
    189186    }
    190187
    191     // duplicate some logic from Walker_Page::start_el() to highlight menu items
     188    // Duplicate some logic from Walker_Page::start_el() to highlight menu items.
    192189    if ( ! empty( $page_id ) ) {
    193190        $_bp_page = get_post( $page_id );
     
    218215 * @param array   $retval CSS classes for the current nav menu item in the menu.
    219216 * @param WP_Post $item   The properties for the current nav menu item.
    220  *
    221217 * @return array
    222218 */
     
    227223    }
    228224
    229     // get the WP page
     225    // Get the WP page.
    230226    $page   = get_post( $item->object_id );
    231227
    232     // see if we should add our highlight CSS classes for the page
     228    // See if we should add our highlight CSS classes for the page.
    233229    $retval = bp_core_menu_highlight_parent_page( $retval, $page );
    234230
     
    262258 * @param array $comments The array of comments supplied to the comments template.
    263259 * @param int   $post_id  The post ID.
    264  *
    265260 * @return array $comments The modified comment array.
    266261 */
     
    305300 * @param WP_User $user            The WP_User object corresponding to a successfully
    306301 *                                 logged-in user. Otherwise a WP_Error object.
    307  *
    308302 * @return string The redirect URL.
    309303 */
    310304function bp_core_login_redirect( $redirect_to, $redirect_to_raw, $user ) {
    311305
    312     // Only modify the redirect if we're on the main BP blog
     306    // Only modify the redirect if we're on the main BP blog.
    313307    if ( !bp_is_root_blog() ) {
    314308        return $redirect_to;
    315309    }
    316310
    317     // Only modify the redirect once the user is logged in
     311    // Only modify the redirect once the user is logged in.
    318312    if ( !is_a( $user, 'WP_User' ) ) {
    319313        return $redirect_to;
     
    340334    // If a 'redirect_to' parameter has been passed that contains 'wp-admin', verify that the
    341335    // logged-in user has any business to conduct in the Dashboard before allowing the
    342     // redirect to go through
     336    // redirect to go through.
    343337    if ( !empty( $redirect_to ) && ( false === strpos( $redirect_to, 'wp-admin' ) || user_can( $user, 'edit_posts' ) ) ) {
    344338        return $redirect_to;
     
    370364 *
    371365 * @param string $welcome_email Complete email passed through WordPress.
    372  *
    373366 * @return string Filtered $welcome_email with the password replaced
    374367 *                by '[User Set]'.
     
    376369function bp_core_filter_user_welcome_email( $welcome_email ) {
    377370
    378     // Don't touch the email when a user is registered by the site admin
     371    // Don't touch the email when a user is registered by the site admin.
    379372    if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {
    380373        return $welcome_email;
     
    385378    }
    386379
    387     // Don't touch the email if we don't have a custom registration template
     380    // Don't touch the email if we don't have a custom registration template.
    388381    if ( ! bp_has_custom_signup_page() ) {
    389382        return $welcome_email;
     
    408401 * @param int    $user_id       ID of the user joining.
    409402 * @param string $password      Password of user.
    410  *
    411403 * @return string Filtered $welcome_email with $password replaced by '[User Set]'.
    412404 */
    413405function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
    414406
    415     // Don't touch the email when a user is registered by the site admin
     407    // Don't touch the email when a user is registered by the site admin.
    416408    if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {
    417409        return $welcome_email;
    418410    }
    419411
    420     // Don't touch the email if we don't have a custom registration template
     412    // Don't touch the email if we don't have a custom registration template.
    421413    if ( ! bp_has_custom_signup_page() )
    422414        return $welcome_email;
     
    440432 * @param string $user       The user's login name.
    441433 * @param string $user_email The user's email address.
    442  * @param string $key        The activation key created in wpmu_signup_blog()
     434 * @param string $key        The activation key created in wpmu_signup_blog().
    443435 * @param array  $meta       By default, contains the requested privacy setting and
    444436 *                           lang_id.
    445  *
    446437 * @return bool True on success, false on failure.
    447438 */
    448439function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
    449440
    450     // Set up activation link
     441    // Set up activation link.
    451442    $activate_url = bp_get_activation_page() ."?key=$key";
    452443    $activate_url = esc_url( $activate_url );
    453444
    454     // Email contents
     445    // Email contents.
    455446    $message = sprintf( __( "%1\$s,\n\n\n\nThanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%2\$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%3\$s", 'buddypress' ), $user, $activate_url, esc_url( "http://{$domain}{$path}" ) );
    456447    $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Activate %s', 'buddypress' ), 'http://' . $domain . $path ) ) );
     
    504495    $message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message, $domain, $path, $title, $user, $user_email, $key, $meta );
    505496
    506     // Send the email
     497    // Send the email.
    507498    wp_mail( $to, $subject, $message );
    508499
    509     // Set up the $admin_email to pass to the filter
     500    // Set up the $admin_email to pass to the filter.
    510501    $admin_email = bp_get_option( 'admin_email' );
    511502
     
    528519    do_action( 'bp_core_sent_blog_signup_email', $admin_email, $subject, $message, $domain, $path, $title, $user, $user_email, $key, $meta );
    529520
    530     // Return false to stop the original WPMU function from continuing
     521    // Return false to stop the original WPMU function from continuing.
    531522    return false;
    532523}
     
    540531 * @param string $user       The user's login name.
    541532 * @param string $user_email The user's email address.
    542  * @param string $key        The activation key created in wpmu_signup_user()
     533 * @param string $key        The activation key created in wpmu_signup_user().
    543534 * @param array  $meta       By default, an empty array.
    544  *
    545535 * @return bool|string True on success, false on failure.
    546536 */
     
    548538
    549539    if ( is_admin() ) {
    550         // If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications
     540        // If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications.
    551541        if( in_array( get_current_screen()->id, array( 'user', 'user-network' ) ) ) {
    552             // If the Super Admin want to skip confirmation email
     542            // If the Super Admin want to skip confirmation email.
    553543            if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
    554544                return false;
    555545
    556             // WordPress will manage the signup process
     546            // WordPress will manage the signup process.
    557547            } else {
    558548                return $user;
     
    562552         * There can be a case where the user was created without the skip confirmation
    563553         * And the super admin goes in pending accounts to resend it. In this case, as the
    564          * meta['password'] is not set, the activation url must be WordPress one
     554         * meta['password'] is not set, the activation url must be WordPress one.
    565555         */
    566556        } elseif ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
     
    573563    }
    574564
    575     // Set up activation link
     565    // Set up activation link.
    576566    $activate_url = bp_get_activation_page() . "?key=$key";
    577567    $activate_url = esc_url( $activate_url );
    578568
    579     // Email contents
     569    // Email contents.
    580570    $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
    581571    $subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );
     
    620610    $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta );
    621611
    622     // Send the email
     612    // Send the email.
    623613    wp_mail( $to, $subject, $message );
    624614
    625     // Set up the $admin_email to pass to the filter
     615    // Set up the $admin_email to pass to the filter.
    626616    $admin_email = bp_get_option( 'admin_email' );
    627617
     
    641631    do_action( 'bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta );
    642632
    643     // Return false to stop the original WPMU function from continuing
     633    // Return false to stop the original WPMU function from continuing.
    644634    return false;
    645635}
     
    657647 * @param  string $sep         How to separate the various items within the page title.
    658648 * @param  string $seplocation Direction to display title.
    659  *
    660649 * @return string              New page title.
    661650 */
     
    663652    global $bp, $paged, $page, $_wp_theme_features;
    664653
    665     // If this is not a BP page, just return the title produced by WP
     654    // If this is not a BP page, just return the title produced by WP.
    666655    if ( bp_is_blog_page() ) {
    667656        return $title;
    668657    }
    669658
    670     // If this is a 404, let WordPress handle it
     659    // If this is a 404, let WordPress handle it.
    671660    if ( is_404() ) {
    672661        return $title;
    673662    }
    674663
    675     // If this is the front page of the site, return WP's title
     664    // If this is the front page of the site, return WP's title.
    676665    if ( is_front_page() || is_home() ) {
    677666        return $title;
    678667    }
    679668
    680     // Return WP's title if not a BuddyPress page
     669    // Return WP's title if not a BuddyPress page.
    681670    if ( ! is_buddypress() ) {
    682671        return $title;
    683672    }
    684673
    685     // Setup an empty title parts array
     674    // Setup an empty title parts array.
    686675    $title_parts = array();
    687676
     
    689678    $displayed_user_name = bp_get_displayed_user_fullname();
    690679
    691     // Displayed user
     680    // Displayed user.
    692681    if ( ! empty( $displayed_user_name ) && ! is_404() ) {
    693682
    694         // Get the component's ID to try and get its name
     683        // Get the component's ID to try and get its name.
    695684        $component_id = $component_name = bp_current_component();
    696685
    697         // Set empty subnav name
     686        // Set empty subnav name.
    698687        $component_subnav_name = '';
    699688
    700         // Use the component nav name
     689        // Use the component nav name.
    701690        if ( ! empty( $bp->bp_nav[$component_id] ) ) {
    702691            $component_name = _bp_strip_spans_from_title( $bp->bp_nav[ $component_id ]['name'] );
    703692
    704         // Fall back on the component ID
     693        // Fall back on the component ID.
    705694        } elseif ( ! empty( $bp->{$component_id}->id ) ) {
    706695            $component_name = ucwords( $bp->{$component_id}->id );
    707696        }
    708697
    709         // Append action name if we're on a member component sub-page
     698        // Append action name if we're on a member component sub-page.
    710699        if ( ! empty( $bp->bp_options_nav[ $component_id ] ) && ! empty( $bp->canonical_stack['action'] ) ) {
    711700            $component_subnav_name = wp_filter_object_list( $bp->bp_options_nav[ $component_id ], array( 'slug' => bp_current_action() ), 'and', 'name' );
     
    716705        }
    717706
    718         // If on the user profile's landing page, just use the fullname
     707        // If on the user profile's landing page, just use the fullname.
    719708        if ( bp_is_current_component( $bp->default_component ) && ( bp_get_requested_url() === bp_displayed_user_domain() ) ) {
    720709            $title_parts[] = $displayed_user_name;
    721710
    722         // Use component name on member pages
     711        // Use component name on member pages.
    723712        } else {
    724713            $title_parts = array_merge( $title_parts, array_map( 'strip_tags', array(
     
    727716            ) ) );
    728717
    729             // If we have a subnav name, add it separately for localization
     718            // If we have a subnav name, add it separately for localization.
    730719            if ( ! empty( $component_subnav_name ) ) {
    731720                $title_parts[] = strip_tags( $component_subnav_name );
     
    733722        }
    734723
    735     // A single group
     724    // A single group.
    736725    } elseif ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) && ! empty( $bp->bp_options_nav[ $bp->groups->current_group->slug ] ) ) {
    737726        $subnav      = isset( $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] ) ? $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] : '';
    738727        $title_parts = array( $bp->bp_options_title, $subnav );
    739728
    740     // A single item from a component other than groups
     729    // A single item from a component other than groups.
    741730    } elseif ( bp_is_single_item() ) {
    742731        $title_parts = array( $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'] );
    743732
    744     // An index or directory
     733    // An index or directory.
    745734    } elseif ( bp_is_directory() ) {
    746735        $current_component = bp_current_component();
    747736
    748         // No current component (when does this happen?)
     737        // No current component (when does this happen?).
    749738        $title_parts = array( _x( 'Directory', 'component directory title', 'buddypress' ) );
    750739
     
    753742        }
    754743
    755     // Sign up page
     744    // Sign up page.
    756745    } elseif ( bp_is_register_page() ) {
    757746        $title_parts = array( __( 'Create an Account', 'buddypress' ) );
    758747
    759     // Activation page
     748    // Activation page.
    760749    } elseif ( bp_is_activation_page() ) {
    761750        $title_parts = array( __( 'Activate Your Account', 'buddypress' ) );
    762751
    763     // Group creation page
     752    // Group creation page.
    764753    } elseif ( bp_is_group_create() ) {
    765754        $title_parts = array( __( 'Create a Group', 'buddypress' ) );
    766755
    767     // Blog creation page
     756    // Blog creation page.
    768757    } elseif ( bp_is_create_blog() ) {
    769758        $title_parts = array( __( 'Create a Site', 'buddypress' ) );
    770759    }
    771760
    772     // Strip spans
     761    // Strip spans.
    773762    $title_parts = array_map( '_bp_strip_spans_from_title', $title_parts );
    774763
    775     // sep on right, so reverse the order
     764    // Sep on right, so reverse the order.
    776765    if ( 'right' == $seplocation ) {
    777766        $title_parts = array_reverse( $title_parts );
    778767    }
    779768
    780     // Get the blog name, so we can check if the original $title included it
     769    // Get the blog name, so we can check if the original $title included it.
    781770    $blogname = get_bloginfo( 'name', 'display' );
    782771
     
    789778    $title_tag_compatibility = (bool) ( ! empty( $_wp_theme_features['title-tag'] ) || strstr( $title, $blogname ) );
    790779
    791     // Append the site title to title parts if theme supports title tag
     780    // Append the site title to title parts if theme supports title tag.
    792781    if ( true === $title_tag_compatibility ) {
    793782        $title_parts[] = $blogname;
     
    798787    }
    799788
    800     // Pad the separator with 1 space on each side
     789    // Pad the separator with 1 space on each side.
    801790    $prefix = str_pad( $sep, strlen( $sep ) + 2, ' ', STR_PAD_BOTH );
    802791
    803     // Join the parts together
     792    // Join the parts together.
    804793    $new_title = join( $prefix, array_filter( $title_parts ) );
    805794
    806     // Append the prefix for pre `title-tag` compatibility
     795    // Append the prefix for pre `title-tag` compatibility.
    807796    if ( false === $title_tag_compatibility ) {
    808797        $new_title = $new_title . $prefix;
     
    832821 * less than 4.0, and should be removed at a later date.
    833822 *
    834  * @param  string $title_part
    835  *
     823 * @param string $title_part Title part to clean up.
    836824 * @return string
    837825 */
     
    851839 *
    852840 * @param WP_Post $menu_item The menu item.
    853  *
    854841 * @return WP_Post The modified WP_Post object.
    855842 */
     
    859846    }
    860847
    861     // Prevent a notice error when using the customizer
     848    // Prevent a notice error when using the customizer.
    862849    $menu_classes = $menu_item->classes;
    863850
     
    867854
    868855    // We use information stored in the CSS class to determine what kind of
    869     // menu item this is, and how it should be treated
     856    // menu item this is, and how it should be treated.
    870857    preg_match( '/\sbp-(.*)-nav/', $menu_classes, $matches );
    871858
    872     // If this isn't a BP menu item, we can stop here
     859    // If this isn't a BP menu item, we can stop here.
    873860    if ( empty( $matches[1] ) ) {
    874861        return $menu_item;
     
    894881            break;
    895882
    896         // Don't show the Register link to logged-in users
     883        // Don't show the Register link to logged-in users.
    897884        case 'register' :
    898885            if ( is_user_logged_in() ) {
     
    903890
    904891        // All other BP nav items are specific to the logged-in user,
    905         // and so are not relevant to logged-out users
     892        // and so are not relevant to logged-out users.
    906893        default:
    907894            if ( is_user_logged_in() ) {
     
    914901    }
    915902
    916     // If component is deactivated, make sure menu item doesn't render
     903    // If component is deactivated, make sure menu item doesn't render.
    917904    if ( empty( $menu_item->url ) ) {
    918905        $menu_item->_invalid = true;
    919906
    920     // Highlight the current page
     907    // Highlight the current page.
    921908    } else {
    922909        $current = bp_get_requested_url();
     
    936923
    937924/**
    938  * Populate BuddyPress user nav items for the customizer
     925 * Populate BuddyPress user nav items for the customizer.
    939926 *
    940927 * @since  2.3.3
    941928 *
    942  * @param  array   $items  The array of menu items
    943  * @param  string  $type   The requested type
    944  * @param  string  $object The requested object name
    945  * @param  integer $page   The page num being requested
     929 * @param  array   $items  The array of menu items.
     930 * @param  string  $type   The requested type.
     931 * @param  string  $object The requested object name.
     932 * @param  integer $page   The page num being requested.
    946933 * @return array           The paginated BuddyPress user nav items.
    947934 */
     
    973960
    974961/**
    975  * Set BuddyPress item navs for the customizer
     962 * Set BuddyPress item navs for the customizer.
    976963 *
    977964 * @since  2.3.3
     
    1012999 *
    10131000 * @param string $q SQL query.
    1014  *
    10151001 * @return string
    10161002 */
     
    10441030 * @param  string $edit_link The edit link.
    10451031 * @param  int    $post_id   Post ID.
    1046  *
    10471032 * @return bool|string Will be a boolean (false) if $post_id is 0. Will be a string (the unchanged edit link)
    10481033 *                     otherwise
     
    10641049 * @param bool $load_mentions    True to load mentions assets, false otherwise.
    10651050 * @param bool $mentions_enabled True if mentions are enabled.
    1066  *
    10671051 * @return bool True if mentions scripts should be loaded.
    10681052 */
  • trunk/src/bp-core/bp-core-functions.php

    r10110 r10356  
    4747     *
    4848     * @since 1.6.0
     49     *
    4950     * @return string The BuddyPress database version.
    5051     */
     
    109110 * @since 2.2.0
    110111 *
    111  * @param  array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
    112  * @param  string|int $key   The array index or property name to sort by.
    113  * @param  string     $type  Sort type. 'alpha' for alphabetical, 'num' for numeric. Default: 'alpha'.
    114  * @return array      $items The sorted array.
     112 * @param array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
     113 * @param string|int $key   The array index or property name to sort by.
     114 * @param string     $type  Sort type. 'alpha' for alphabetical, 'num' for numeric. Default: 'alpha'.
     115 * @return array $items The sorted array.
    115116 */
    116117function bp_sort_by_key( $items, $key, $type = 'alpha' ) {
     
    158159 * @since 1.9.0
    159160 *
    160  * @param  array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
    161  * @param  string|int $key   The array index or property name to sort by.
    162  * @return array      $items The sorted array.
     161 * @param array      $items The items to be sorted. Its constituent items can be either associative arrays or objects.
     162 * @param string|int $key   The array index or property name to sort by.
     163 * @return array $items The sorted array.
    163164 */
    164165function bp_alpha_sort_by_key( $items, $key ) {
     
    171172 * @param int  $number   The number to be formatted.
    172173 * @param bool $decimals Whether to use decimals. See {@link number_format_i18n()}.
    173  *
    174174 * @return string The formatted number.
    175175 */
    176176function bp_core_number_format( $number = 0, $decimals = false ) {
    177177
    178     // Force number to 0 if needed
     178    // Force number to 0 if needed.
    179179    if ( ! is_numeric( $number ) ) {
    180180        $number = 0;
     
    227227 * @param array $old_args_keys Old argument indexs, keyed to their positions.
    228228 * @param array $func_args     The parameters passed to the originating function.
    229  *
    230229 * @return array $new_args The parsed arguments.
    231230 */
     
    256255 * @param array        $defaults   Array that serves as the defaults.
    257256 * @param string       $filter_key String to key the filters from.
    258  *
    259257 * @return array Merged user defined values with defaults.
    260258 */
    261259function bp_parse_args( $args, $defaults = array(), $filter_key = '' ) {
    262260
    263     // Setup a temporary array from $args
     261    // Setup a temporary array from $args.
    264262    if ( is_object( $args ) ) {
    265263        $r = get_object_vars( $args );
     
    270268    }
    271269
    272     // Passively filter the args before the parse
     270    // Passively filter the args before the parse.
    273271    if ( !empty( $filter_key ) ) {
    274272
     
    285283    }
    286284
    287     // Parse
     285    // Parse.
    288286    if ( is_array( $defaults ) && !empty( $defaults ) ) {
    289287        $r = array_merge( $defaults, $r );
    290288    }
    291289
    292     // Aggressively filter the args after the parse
     290    // Aggressively filter the args after the parse.
    293291    if ( !empty( $filter_key ) ) {
    294292
     
    305303    }
    306304
    307     // Return the parsed results
     305    // Return the parsed results.
    308306    return $r;
    309307}
     
    316314 * @since 2.2.0
    317315 *
    318  * @param  string $page_arg The $_REQUEST argument to look for.
    319  * @param  int    $page     The original page value to fall back to.
    320  *
    321  * @return int              A sanitized integer value, good for pagination.
     316 * @param string $page_arg The $_REQUEST argument to look for.
     317 * @param int    $page     The original page value to fall back to.
     318 * @return int A sanitized integer value, good for pagination.
    322319 */
    323320function bp_sanitize_pagination_arg( $page_arg = '', $page = 1 ) {
    324321
    325     // Check if request overrides exist
     322    // Check if request overrides exist.
    326323    if ( isset( $_REQUEST[ $page_arg ] ) ) {
    327324
    328         // Get the absolute integer value of the override
     325        // Get the absolute integer value of the override.
    329326        $int = absint( $_REQUEST[ $page_arg ] );
    330327
    331328        // If override is 0, do not use it. This prevents unlimited result sets.
    332         // @see https://buddypress.trac.wordpress.org/ticket/5796
     329        // @see https://buddypress.trac.wordpress.org/ticket/5796.
    333330        if ( $int ) {
    334331            $page = $int;
     
    348345 *
    349346 * @param string $order The 'order' string, as passed to the SQL constructor.
    350  *
    351347 * @return string The sanitized value 'DESC' or 'ASC'.
    352348 */
     
    369365 *
    370366 * @param string $text The raw text to be escaped.
    371  *
    372367 * @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
    373368 *                wpdb::prepare() before use.
     
    420415function bp_use_wp_admin_bar() {
    421416
    422     // Default to true (to avoid loading deprecated BuddyBar code)
     417    // Default to true (to avoid loading deprecated BuddyBar code).
    423418    $use_admin_bar = true;
    424419
     
    464459    );
    465460
    466     // only add legacy forums if it is enabled
    467     // prevents conflicts with bbPress, which also uses the same 'forums' id
     461    // Only add legacy forums if it is enabled
     462    // prevents conflicts with bbPress, which also uses the same 'forums' id.
    468463    if ( class_exists( 'BP_Forums_Component' ) ) {
    469464        $components[] = 'forums';
     
    481476 *                       pages. When running save routines, use 'all' to avoid removing data related to inactive
    482477 *                       components. Default: 'active'.
    483  *
    484478 * @return array|string An array of page IDs, keyed by component names, or an
    485479 *                      empty string if the list is not found.
     
    488482    $page_ids = bp_get_option( 'bp-pages' );
    489483
    490     // Ensure that empty indexes are unset. Should only matter in edge cases
     484    // Ensure that empty indexes are unset. Should only matter in edge cases.
    491485    if ( !empty( $page_ids ) && is_array( $page_ids ) ) {
    492486        foreach( (array) $page_ids as $component_name => $page_id ) {
     
    526520 * Store the list of BP directory pages in the appropriate meta table.
    527521 *
    528  * bp-pages data is stored in site_options (falls back to options on non-MS),
     522 * The bp-pages data is stored in site_options (falls back to options on non-MS),
    529523 * in an array keyed by blog_id. This allows you to change your
    530524 * bp_get_root_blog_id() and go through the setup process again.
     
    549543    global $wpdb;
    550544
    551     // Look in cache first
     545    // Look in cache first.
    552546    $pages = wp_cache_get( 'directory_pages', 'bp' );
    553547
    554548    if ( false === $pages ) {
    555549
    556         // Set pages as standard class
     550        // Set pages as standard class.
    557551        $pages = new stdClass;
    558552
    559         // Get pages and IDs
     553        // Get pages and IDs.
    560554        $page_ids = bp_core_get_directory_page_ids();
    561555        if ( !empty( $page_ids ) ) {
    562556
    563557            // Always get page data from the root blog, except on multiblog mode, when it comes
    564             // from the current blog
     558            // from the current blog.
    565559            $posts_table_name = bp_is_multiblog_mode() ? $wpdb->posts : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'posts';
    566560            $page_ids_sql     = implode( ',', wp_parse_id_list( $page_ids ) );
     
    579573                        $slug[]                        = $page_name->post_name;
    580574
    581                         // Get the slug
     575                        // Get the slug.
    582576                        while ( $page_name->post_parent != 0 ) {
    583577                            $parent                 = $wpdb->get_results( $wpdb->prepare( "SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d", $page_name->post_parent ) );
     
    635629    $pages = bp_core_get_directory_page_ids( 'all' );
    636630
    637     // Delete any existing pages
     631    // Delete any existing pages.
    638632    if ( 'delete' === $existing ) {
    639633        foreach ( (array) $pages as $page_id ) {
     
    661655
    662656    // Register and Activate are not components, but need pages when
    663     // registration is enabled
     657    // registration is enabled.
    664658    if ( bp_get_signup_allowed() ) {
    665659        foreach ( array( 'register', 'activate' ) as $slug ) {
     
    670664    }
    671665
    672     // No need for a Sites directory unless we're on multisite
     666    // No need for a Sites directory unless we're on multisite.
    673667    if ( ! is_multisite() && isset( $pages_to_create['sites'] ) ) {
    674668        unset( $pages_to_create['sites'] );
    675669    }
    676670
    677     // Members must always have a page, no matter what
     671    // Members must always have a page, no matter what.
    678672    if ( ! isset( $pages['members'] ) && ! isset( $pages_to_create['members'] ) ) {
    679673        $pages_to_create['members'] = $page_titles['members'];
    680674    }
    681675
    682     // Create the pages
     676    // Create the pages.
    683677    foreach ( $pages_to_create as $component_name => $page_name ) {
    684678        $exists = get_page_by_path( $component_name );
    685679
    686         // If page already exists, use it
     680        // If page already exists, use it.
    687681        if ( ! empty( $exists ) ) {
    688682            $pages[ $component_name ] = $exists->ID;
     
    698692    }
    699693
    700     // Save the page mapping
     694    // Save the page mapping.
    701695    bp_update_option( 'bp-pages', $pages );
    702696
     
    711705 *
    712706 * Bails early on multisite installations when not viewing the root site.
     707 *
    713708 * @link https://buddypress.trac.wordpress.org/ticket/6226
    714709 *
     
    719714function bp_core_on_directory_page_delete( $post_id ) {
    720715
    721     // Stop if we are not on the main BP root blog
     716    // Stop if we are not on the main BP root blog.
    722717    if ( ! bp_is_root_blog() ) {
    723718        return;
     
    756751 *
    757752 * @param string $root_slug The root slug, which comes from $bp->pages->[component]->slug.
    758  *
    759753 * @return string The short slug for use in the middle of URLs.
    760754 */
     
    793787    $match = false;
    794788
    795     // Check if the slug is registered in the $bp->pages global
     789    // Check if the slug is registered in the $bp->pages global.
    796790    foreach ( (array) $bp->pages as $key => $page ) {
    797791        if ( $key == $slug || $page->slug == $slug ) {
     
    800794    }
    801795
    802     // Maybe create the add_root array
     796    // Maybe create the add_root array.
    803797    if ( empty( $bp->add_root ) ) {
    804798        $bp->add_root = array();
    805799    }
    806800
    807     // If there was no match, add a page for this root component
     801    // If there was no match, add a page for this root component.
    808802    if ( empty( $match ) ) {
    809803        $add_root_items   = $bp->add_root();
     
    812806    }
    813807
    814     // Make sure that this component is registered as requiring a top-level directory
     808    // Make sure that this component is registered as requiring a top-level directory.
    815809    if ( isset( $bp->{$slug} ) ) {
    816810        $bp->loaded_components[$bp->{$slug}->slug] = $bp->{$slug}->id;
     
    824818function bp_core_create_root_component_page() {
    825819
    826     // Get BuddyPress
     820    // Get BuddyPress.
    827821    $bp = buddypress();
    828822
     
    890884    // This ensures that the version of bp-default in the regular themes
    891885    // directory will always take precedence, as part of a migration away
    892     // from the version packaged with BuddyPress
     886    // from the version packaged with BuddyPress.
    893887    foreach ( array_values( (array) $GLOBALS['wp_theme_directories'] ) as $directory ) {
    894888        if ( is_dir( $directory . '/bp-default' ) ) {
     
    898892
    899893    // If the current theme is bp-default (or a bp-default child), BP
    900     // should register its directory
     894    // should register its directory.
    901895    $register = 'bp-default' === get_stylesheet() || 'bp-default' === get_template();
    902896
    903     // Legacy sites continue to have the theme registered
     897    // Legacy sites continue to have the theme registered.
    904898    if ( empty( $register ) && ( 1 == get_site_option( '_bp_retain_bp_default' ) ) ) {
    905899        $register = true;
     
    921915 * Return the domain for the root blog.
    922916 *
    923  * eg: http://example.com OR https://example.com
     917 * Eg: http://example.com OR https://example.com
    924918 *
    925919 * @uses get_blog_option() WordPress function to fetch blog meta.
     
    10091003            $site_path = '/';
    10101004        } else {
    1011             // Unset the first three segments (http(s)://example.com part)
     1005            // Unset the first three segments (http(s)://example.com part).
    10121006            unset( $site_path[0] );
    10131007            unset( $site_path[1] );
     
    10421036 * @param string $type See the 'type' parameter in {@link current_time()}.
    10431037 *                     Default: 'mysql'.
    1044  *
    10451038 * @return string Current time in 'Y-m-d h:i:s' format.
    10461039 */
     
    10801073 * @param int|bool   $newer_date Optional. Unix timestamp of date to compare older
    10811074 *                               date to. Default: false (current time).
    1082  *
    10831075 * @return string String representing the time since the older date, eg
    10841076 *         "2 hours and 50 minutes".
     
    11271119    $ago_text       = apply_filters( 'bp_core_time_since_ago_text',       __( '%s ago',    'buddypress' ) );
    11281120
    1129     // array of time period chunks
     1121    // Array of time period chunks.
    11301122    $chunks = array(
    11311123        YEAR_IN_SECONDS,
     
    11511143    $newer_date = ( !$newer_date ) ? bp_core_current_time( true, 'timestamp' ) : $newer_date;
    11521144
    1153     // Difference in seconds
     1145    // Difference in seconds.
    11541146    $since = $newer_date - $older_date;
    11551147
     
    11661158    } else {
    11671159
    1168         // Step one: the first chunk
     1160        // Step one: the first chunk.
    11691161        for ( $i = 0, $j = count( $chunks ); $i < $j; ++$i ) {
    11701162            $seconds = $chunks[$i];
    11711163
    1172             // Finding the biggest chunk (if the chunk fits, break)
     1164            // Finding the biggest chunk (if the chunk fits, break).
    11731165            $count = floor( $since / $seconds );
    11741166            if ( 0 != $count ) {
     
    11771169        }
    11781170
    1179         // If $i iterates all the way to $j, then the event happened 0 seconds ago
     1171        // If $i iterates all the way to $j, then the event happened 0 seconds ago.
    11801172        if ( !isset( $chunks[$i] ) ) {
    11811173            $output = $right_now_text;
     
    11831175        } else {
    11841176
    1185             // Set output var
     1177            // Set output var.
    11861178            switch ( $seconds ) {
    11871179                case YEAR_IN_SECONDS :
     
    12121204            // We've left the quirk in place, since fractions of a
    12131205            // minute are not a useful piece of information for our
    1214             // purposes
     1206            // purposes.
    12151207            if ( $i + 2 < $j ) {
    12161208                $seconds2 = $chunks[$i + 1];
    12171209                $count2   = floor( ( $since - ( $seconds * $count ) ) / $seconds2 );
    12181210
    1219                 // Add to output var
     1211                // Add to output var.
    12201212                if ( 0 != $count2 ) {
    12211213                    $output .= _x( ',', 'Separator in time since', 'buddypress' ) . ' ';
     
    12431235            }
    12441236
    1245             // No output, so happened right now
     1237            // No output, so happened right now.
    12461238            if ( ! (int) trim( $output ) ) {
    12471239                $output = $right_now_text;
     
    12501242    }
    12511243
    1252     // Append 'ago' to the end of time-since if not 'right now'
     1244    // Append 'ago' to the end of time-since if not 'right now'.
    12531245    if ( $output != $right_now_text ) {
    12541246        $output = sprintf( $ago_text, $output );
     
    12781270function bp_core_add_message( $message, $type = '' ) {
    12791271
    1280     // Success is the default
     1272    // Success is the default.
    12811273    if ( empty( $type ) ) {
    12821274        $type = 'success';
    12831275    }
    12841276
    1285     // Send the values to the cookie for page reload display
     1277    // Send the values to the cookie for page reload display.
    12861278    @setcookie( 'bp-message',      $message, time() + 60 * 60 * 24, COOKIEPATH );
    12871279    @setcookie( 'bp-message-type', $type,    time() + 60 * 60 * 24, COOKIEPATH );
    12881280
    1289     // Get BuddyPress
     1281    // Get BuddyPress.
    12901282    $bp = buddypress();
    12911283
    1292     /***
     1284    /**
    12931285     * Send the values to the $bp global so we can still output messages
    12941286     * without a page reload
     
    13121304function bp_core_setup_message() {
    13131305
    1314     // Get BuddyPress
     1306    // Get BuddyPress.
    13151307    $bp = buddypress();
    13161308
     
    13431335function bp_core_render_message() {
    13441336
    1345     // Get BuddyPress
     1337    // Get BuddyPress.
    13461338    $bp = buddypress();
    13471339
     
    13951387function bp_core_record_activity() {
    13961388
    1397     // Bail if user is not logged in
     1389    // Bail if user is not logged in.
    13981390    if ( ! is_user_logged_in() ) {
    13991391        return false;
    14001392    }
    14011393
    1402     // Get the user ID
     1394    // Get the user ID.
    14031395    $user_id = bp_loggedin_user_id();
    14041396
    1405     // Bail if user is not active
     1397    // Bail if user is not active.
    14061398    if ( bp_is_user_inactive( $user_id ) ) {
    14071399        return false;
    14081400    }
    14091401
    1410     // Get the user's last activity
     1402    // Get the user's last activity.
    14111403    $activity = bp_get_user_last_activity( $user_id );
    14121404
    1413     // Make sure it's numeric
     1405    // Make sure it's numeric.
    14141406    if ( ! is_numeric( $activity ) ) {
    14151407        $activity = strtotime( $activity );
    14161408    }
    14171409
    1418     // Get current time
     1410    // Get current time.
    14191411    $current_time = bp_core_current_time();
    14201412
    1421     // Use this action to detect the very first activity for a given member
     1413    // Use this action to detect the very first activity for a given member.
    14221414    if ( empty( $activity ) ) {
    14231415
     
    14341426    }
    14351427
    1436     // If it's been more than 5 minutes, record a newer last-activity time
     1428    // If it's been more than 5 minutes, record a newer last-activity time.
    14371429    if ( empty( $activity ) || ( strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) ) ) {
    14381430        bp_update_user_last_activity( $user_id, $current_time );
     
    14491441 * @param int|string $last_activity_date The date of last activity.
    14501442 * @param string     $string             A sprintf()-able statement of the form 'active %s'.
    1451  *
    14521443 * @return string $last_active A string of the form '3 years ago'.
    14531444 */
    14541445function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {
    14551446
    1456     // Setup a default string if none was passed
     1447    // Setup a default string if none was passed.
    14571448    $string = empty( $string )
    1458         ? '%s'     // Gettext placeholder
     1449        ? '%s'     // Gettext placeholder.
    14591450        : $string;
    14601451
    1461     // Use the string if a last activity date was passed
     1452    // Use the string if a last activity date was passed.
    14621453    $last_active = empty( $last_activity_date )
    14631454        ? __( 'Not recently active', 'buddypress' )
     
    14991490 *
    15001491 * @param string|bool $key The usermeta meta_key.
    1501  *
    15021492 * @return string $key The usermeta meta_key.
    15031493 */
     
    15291519 * @param string $key     The meta key to retrieve.
    15301520 * @param bool   $single  Whether to return a single value.
    1531  *
    15321521 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
    1533  *         is true.
     1522 *               is true.
    15341523 */
    15351524function bp_get_user_meta( $user_id, $key, $single = false ) {
     
    15531542 * @param mixed  $value      Metadata value.
    15541543 * @param mixed  $prev_value Optional. Previous value to check before removing.
    1555  *
    15561544 * @return bool False on failure, true on success.
    15571545 */
     
    15751563 * @param string $key     The meta key to delete.
    15761564 * @param mixed  $value   Optional. Metadata value.
    1577  *
    15781565 * @return bool False for failure. True for success.
    15791566 */
     
    15911578function bp_embed_init() {
    15921579
    1593     // Get BuddyPress
     1580    // Get BuddyPress.
    15941581    $bp = buddypress();
    15951582
     
    17091696     *                       obeys {@link force_ssl_admin()} and {@link is_ssl()}. 'http'
    17101697     *                       or 'https' can be passed to force those schemes.
    1711      *
    17121698     * @return string Admin url link with optional path appended.
    17131699     */
    17141700    function bp_get_admin_url( $path = '', $scheme = 'admin' ) {
    17151701
    1716         // Links belong in network admin
     1702        // Links belong in network admin.
    17171703        if ( bp_core_do_network_admin() ) {
    17181704            $url = network_admin_url( $path, $scheme );
    17191705
    1720         // Links belong in site admin
     1706        // Links belong in site admin.
    17211707        } else {
    17221708            $url = admin_url( $path, $scheme );
     
    17431729function bp_core_do_network_admin() {
    17441730
    1745     // Default
     1731    // Default.
    17461732    $retval = bp_is_network_activated();
    17471733
     
    17931779 *
    17941780 * @param int $blog_id Optional. Default: the ID of the current blog.
    1795  *
    17961781 * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
    17971782 */
    17981783function bp_is_root_blog( $blog_id = 0 ) {
    17991784
    1800     // Assume false
     1785    // Assume false.
    18011786    $is_root_blog = false;
    18021787
    1803     // Use current blog if no ID is passed
     1788    // Use current blog if no ID is passed.
    18041789    if ( empty( $blog_id ) || ! is_int( $blog_id ) ) {
    18051790        $blog_id = get_current_blog_id();
    18061791    }
    18071792
    1808     // Compare to root blog ID
     1793    // Compare to root blog ID.
    18091794    if ( bp_get_root_blog_id() === $blog_id ) {
    18101795        $is_root_blog = true;
     
    18761861function bp_is_multiblog_mode() {
    18771862
    1878     // Setup some default values
     1863    // Setup some default values.
    18791864    $retval         = false;
    18801865    $is_multisite   = is_multisite();
     
    18821867    $is_multiblog   = defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG;
    18831868
    1884     // Multisite, Network Activated, and Specifically Multiblog
     1869    // Multisite, Network Activated, and Specifically Multiblog.
    18851870    if ( $is_multisite && $network_active && $is_multiblog ) {
    18861871        $retval = true;
    18871872
    1888     // Multisite, but not network activated
     1873    // Multisite, but not network activated.
    18891874    } elseif ( $is_multisite && ! $network_active ) {
    18901875        $retval = true;
     
    19151900function bp_is_network_activated() {
    19161901
    1917     // Default to is_multisite()
     1902    // Default to is_multisite().
    19181903    $retval  = is_multisite();
    19191904
    1920     // Check the sitewide plugins array
     1905    // Check the sitewide plugins array.
    19211906    $base    = buddypress()->basename;
    19221907    $plugins = get_site_option( 'active_sitewide_plugins' );
    19231908
    1924     // Override is_multisite() if not network activated
     1909    // Override is_multisite() if not network activated.
    19251910    if ( ! is_array( $plugins ) || ! isset( $plugins[ $base ] ) ) {
    19261911        $retval = false;
     
    20562041 * @param string $action    Action nonce.
    20572042 * @param string $query_arg Where to look for nonce in $_REQUEST.
    2058  *
    20592043 * @return bool True if the nonce is verified, otherwise false.
    20602044 */
    20612045function bp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) {
    20622046
    2063     /** Home URL **************************************************************/
     2047    /* Home URL **************************************************************/
    20642048
    20652049    // Parse home_url() into pieces to remove query-strings, strange characters,
     
    20672051    $parsed_home = parse_url( home_url( '/', ( is_ssl() ? 'https' : 'http' ) ) );
    20682052
    2069     // Maybe include the port, if it's included in home_url()
     2053    // Maybe include the port, if it's included in home_url().
    20702054    if ( isset( $parsed_home['port'] ) ) {
    20712055        $parsed_host = $parsed_home['host'] . ':' . $parsed_home['port'];
     
    20742058    }
    20752059
    2076     // Set the home URL for use in comparisons
     2060    // Set the home URL for use in comparisons.
    20772061    $home_url = trim( strtolower( $parsed_home['scheme'] . '://' . $parsed_host . $parsed_home['path'] ), '/' );
    20782062
    2079     /** Requested URL *********************************************************/
    2080 
    2081     // Maybe include the port, if it's included in home_url()
     2063    /* Requested URL *********************************************************/
     2064
     2065    // Maybe include the port, if it's included in home_url().
    20822066    if ( isset( $parsed_home['port'] ) && false === strpos( $_SERVER['HTTP_HOST'], ':' ) ) {
    20832067        $request_host = $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'];
     
    20862070    }
    20872071
    2088     // Build the currently requested URL
     2072    // Build the currently requested URL.
    20892073    $scheme        = is_ssl() ? 'https://' : 'http://';
    20902074    $requested_url = strtolower( $scheme . $request_host . $_SERVER['REQUEST_URI'] );
    20912075
    2092     /** Look for match ********************************************************/
     2076    /* Look for match ********************************************************/
    20932077
    20942078    /**
     
    21032087    $matched_url = apply_filters( 'bp_verify_nonce_request_url', $requested_url );
    21042088
    2105     // Check the nonce
     2089    // Check the nonce.
    21062090    $result = isset( $_REQUEST[$query_arg] ) ? wp_verify_nonce( $_REQUEST[$query_arg], $action ) : false;
    21072091
    2108     // Nonce check failed
     2092    // Nonce check failed.
    21092093    if ( empty( $result ) || empty( $action ) || ( strpos( $matched_url, $home_url ) !== 0 ) ) {
    21102094        $result = false;
     
    21302114 *
    21312115 * @since 1.9.0
     2116 *
    21322117 * @return bool
    21332118 */
     
    21402125 *