Skip to:
Content

BuddyPress.org

Changeset 10356


Ignore:
Timestamp:
11/15/2015 07:57:03 PM (9 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 *
    21412126 * @since 1.9.0
     2127 *
    21422128 * @return bool
    21432129 */
     
    21802166    ) );
    21812167
    2182     // Try custom locations in WP_LANG_DIR
     2168    // Try custom locations in WP_LANG_DIR.
    21832169    foreach ( $locations as $location ) {
    21842170        if ( load_textdomain( 'buddypress', $location . $mofile_custom ) ) {
     
    21872173    }
    21882174
    2189     // default to WP and glotpress
     2175    // Default to WP and glotpress.
    21902176    return load_plugin_textdomain( $domain );
    21912177}
     
    23192305function bp_nav_menu_get_loggedin_pages() {
    23202306
    2321     // Try to catch the cached version first
     2307    // Try to catch the cached version first.
    23222308    if ( ! empty( buddypress()->wp_nav_menu_items->loggedin ) ) {
    23232309        return buddypress()->wp_nav_menu_items->loggedin;
    23242310    }
    23252311
    2326     // Pull up a list of items registered in BP's top-level nav array
     2312    // Pull up a list of items registered in BP's top-level nav array.
    23272313    $bp_menu_items = buddypress()->bp_nav;
    23282314
    2329     // Alphabetize
     2315    // Alphabetize.
    23302316    $bp_menu_items = bp_alpha_sort_by_key( $bp_menu_items, 'name' );
    23312317
     
    23382324    );
    23392325
    2340     // If there's nothing to show, we're done
     2326    // If there's nothing to show, we're done.
    23412327    if ( count( $bp_menu_items ) < 1 ) {
    23422328        return false;
     
    23472333    foreach ( $bp_menu_items as $bp_item ) {
    23482334
    2349         // Remove <span>number</span>
     2335        // Remove <span>number</span>.
    23502336        $item_name = preg_replace( '/([.0-9]+)/', '', $bp_item['name'] );
    23512337        $item_name = trim( strip_tags( $item_name ) );
     
    23892375function bp_nav_menu_get_loggedout_pages() {
    23902376
    2391     // Try to catch the cached version first
     2377    // Try to catch the cached version first.
    23922378    if ( ! empty( buddypress()->wp_nav_menu_items->loggedout ) ) {
    23932379        return buddypress()->wp_nav_menu_items->loggedout;
     
    24052391
    24062392    // The Register page will not always be available (ie, when
    2407     // registration is disabled)
     2393    // registration is disabled).
    24082394    $bp_directory_page_ids = bp_core_get_directory_page_ids();
    24092395
     
    24172403    }
    24182404
    2419     // If there's nothing to show, we're done
     2405    // If there's nothing to show, we're done.
    24202406    if ( count( $bp_menu_items ) < 1 ) {
    24212407        return false;
     
    24582444 * @param string $slug The slug of the nav item: login, register, or one of the
    24592445 *                     slugs from buddypress()->bp_nav.
    2460  *
    24612446 * @return string $nav_item_url The URL generated for the current user.
    24622447 */
     
    24822467 * @since 2.1.0
    24832468 *
    2484  * @param array $args
    2485  *
     2469 * @param array $args Array of args for the suggestions.
    24862470 * @return array|WP_Error Array of results. If there were any problems, returns a WP_Error object.
    24872471 */
     
    25662550        $need_switch = (bool) ( is_multisite() && ! bp_is_root_blog() );
    25672551
    2568         // Maybe juggle to root blog
     2552        // Maybe juggle to root blog.
    25692553        if ( true === $need_switch ) {
    25702554            switch_to_blog( bp_get_root_blog_id() );
    25712555        }
    25722556
    2573         // Get the upload directory (maybe for root blog)
     2557        // Get the upload directory (maybe for root blog).
    25742558        $wp_upload_dir = wp_upload_dir();
    25752559
    2576         // Maybe juggle back to current blog
     2560        // Maybe juggle back to current blog.
    25772561        if ( true === $need_switch ) {
    25782562            restore_current_blog();
    25792563        }
    25802564
    2581         // Bail if an error occurred
     2565        // Bail if an error occurred.
    25822566        if ( ! empty( $wp_upload_dir['error'] ) ) {
    25832567            return false;
  • trunk/src/bp-core/bp-core-loader.php

    r10108 r10356  
    1212defined( 'ABSPATH' ) || exit;
    1313
     14/**
     15 * Creates the Core component.
     16 */
    1417class BP_Core extends BP_Component {
    1518
     
    5154        do_action( 'bp_core_loaded' );
    5255
    53         /** Components ********************************************************/
     56        /** Components *******************************************************
     57         */
    5458
    5559        /**
     
    7175        $bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
    7276
    73         // Get a list of activated components
     77        // Get a list of activated components.
    7478        if ( $active_components = bp_get_option( 'bp-active-components' ) ) {
    7579
     
    8690            $bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) );
    8791
    88         // Pre 1.5 Backwards compatibility
     92        // Pre 1.5 Backwards compatibility.
    8993        } elseif ( $deactivated_components = bp_get_option( 'bp-deactivated-components' ) ) {
    9094
    91             // Trim off namespace and filename
     95            // Trim off namespace and filename.
    9296            foreach ( array_keys( (array) $deactivated_components ) as $component ) {
    9397                $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
     
    97101            $bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed );
    98102
    99             // Setup the active components
     103            // Setup the active components.
    100104            $active_components     = array_fill_keys( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ), '1' );
    101105
     
    103107            $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
    104108
    105         // Default to all components active
     109        // Default to all components active.
    106110        } else {
    107111
    108             // Set globals
     112            // Set globals.
    109113            $bp->deactivated_components = array();
    110114
    111             // Setup the active components
     115            // Setup the active components.
    112116            $active_components     = array_fill_keys( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), '1' );
    113117
     
    116120        }
    117121
    118         // Loop through optional components
     122        // Loop through optional components.
    119123        foreach( $bp->optional_components as $component ) {
    120124            if ( bp_is_active( $component ) && file_exists( $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php' ) ) {
     
    123127        }
    124128
    125         // Loop through required components
     129        // Loop through required components.
    126130        foreach( $bp->required_components as $component ) {
    127131            if ( file_exists( $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php' ) ) {
     
    130134        }
    131135
    132         // Add Core to required components
     136        // Add Core to required components.
    133137        $bp->required_components[] = 'core';
    134138
     
    176180        $bp = buddypress();
    177181
    178         /** Database **********************************************************/
    179 
    180         // Get the base database prefix
     182        /** Database *********************************************************
     183         */
     184
     185        // Get the base database prefix.
    181186        if ( empty( $bp->table_prefix ) ) {
    182187            $bp->table_prefix = bp_core_get_table_prefix();
    183188        }
    184189
    185         // The domain for the root of the site where the main blog resides
     190        // The domain for the root of the site where the main blog resides.
    186191        if ( empty( $bp->root_domain ) ) {
    187192            $bp->root_domain = bp_core_get_root_domain();
    188193        }
    189194
    190         // Fetches all of the core BuddyPress settings in one fell swoop
     195        // Fetches all of the core BuddyPress settings in one fell swoop.
    191196        if ( empty( $bp->site_options ) ) {
    192197            $bp->site_options = bp_core_get_root_options();
    193198        }
    194199
    195         // The names of the core WordPress pages used to display BuddyPress content
     200        // The names of the core WordPress pages used to display BuddyPress content.
    196201        if ( empty( $bp->pages ) ) {
    197202            $bp->pages = bp_core_get_directory_pages();
    198203        }
    199204
    200         /** Basic current user data *******************************************/
    201 
    202         // Logged in user is the 'current_user'
     205        /** Basic current user data ******************************************
     206         */
     207
     208        // Logged in user is the 'current_user'.
    203209        $current_user            = wp_get_current_user();
    204210
     
    207213        $bp->loggedin_user->id   = isset( $current_user->ID ) ? $current_user->ID : 0;
    208214
    209         /** Avatars ***********************************************************/
    210 
    211         // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
     215        /** Avatars **********************************************************
     216         */
     217
     218        // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar.
    212219        $bp->grav_default        = new stdClass;
    213220
     
    271278    public function setup_cache_groups() {
    272279
    273         // Global groups
     280        // Global groups.
    274281        wp_cache_add_global_groups( array(
    275282            'bp'
  • trunk/src/bp-core/bp-core-moderation.php

    r10108 r10356  
    2727 *
    2828 * @param int $user_id User id to check for flood.
    29  *
    3029 * @return bool True if there is no flooding, false if there is.
    3130 */
     
    3736    }
    3837
    39     // Bail if no user ID passed
     38    // Bail if no user ID passed.
    4039    if ( empty( $user_id ) ) {
    4140        return false;
     
    6261 * @param string $title   The title of the content.
    6362 * @param string $content The content being posted.
    64  *
    6563 * @return bool True if test is passed, false if fail.
    6664 */
     
    8179    }
    8280
    83     // Bail if super admin is author
     81    // Bail if super admin is author.
    8482    if ( is_super_admin( $user_id ) ) {
    8583        return true;
    8684    }
    8785
    88     // Define local variable(s)
     86    // Define local variable(s).
    8987    $_post     = array();
    9088    $match_out = '';
    9189
    92     /** User Data *************************************************************/
     90    /** User Data ************************************************************
     91     */
    9392
    9493    if ( ! empty( $user_id ) ) {
    9594
    96         // Get author data
     95        // Get author data.
    9796        $user = get_userdata( $user_id );
    9897
    99         // If data exists, map it
     98        // If data exists, map it.
    10099        if ( ! empty( $user ) ) {
    101100            $_post['author'] = $user->display_name;
     
    105104    }
    106105
    107     // Current user IP and user agent
     106    // Current user IP and user agent.
    108107    $_post['user_ip'] = bp_core_current_user_ip();
    109108    $_post['user_ua'] = bp_core_current_user_ua();
    110109
    111     // Post title and content
     110    // Post title and content.
    112111    $_post['title']   = $title;
    113112    $_post['content'] = $content;
    114113
    115     /** Max Links *************************************************************/
     114    /** Max Links ************************************************************
     115     */
    116116
    117117    $max_links = get_option( 'comment_max_links' );
     
    121121        $num_links = preg_match_all( '/(http|ftp|https):\/\//i', $content, $match_out );
    122122
    123         // Allow for bumping the max to include the user's URL
     123        // Allow for bumping the max to include the user's URL.
    124124        if ( ! empty( $_post['url'] ) ) {
    125125
     
    141141    }
    142142
    143     /** Blacklist *************************************************************/
    144 
    145     // Get the moderation keys
     143    /** Blacklist ************************************************************
     144     */
     145
     146    // Get the moderation keys.
    146147    $blacklist = trim( get_option( 'moderation_keys' ) );
    147148
    148     // Bail if blacklist is empty
     149    // Bail if blacklist is empty.
    149150    if ( ! empty( $blacklist ) ) {
    150151
    151         // Get words separated by new lines
     152        // Get words separated by new lines.
    152153        $words = explode( "\n", $blacklist );
    153154
    154         // Loop through words
     155        // Loop through words.
    155156        foreach ( (array) $words as $word ) {
    156157
    157             // Trim the whitespace from the word
     158            // Trim the whitespace from the word.
    158159            $word = trim( $word );
    159160
    160             // Skip empty lines
     161            // Skip empty lines.
    161162            if ( empty( $word ) ) {
    162163                continue;
     
    164165
    165166            // Do some escaping magic so that '#' chars in the
    166             // spam words don't break things:
     167            // spam words don't break things.
    167168            $word    = preg_quote( $word, '#' );
    168169            $pattern = "#$word#i";
    169170
    170             // Loop through post data
     171            // Loop through post data.
    171172            foreach ( $_post as $post_data ) {
    172173
    173                 // Check each user data for current word
     174                // Check each user data for current word.
    174175                if ( preg_match( $pattern, $post_data ) ) {
    175176
    176                     // Post does not pass
     177                    // Post does not pass.
    177178                    return false;
    178179                }
     
    181182    }
    182183
    183     // Check passed successfully
     184    // Check passed successfully.
    184185    return true;
    185186}
     
    197198 * @param string $title   The title of the content.
    198199 * @param string $content The content being posted.
    199  *
    200200 * @return bool True if test is passed, false if fail.
    201201 */
     
    216216    }
    217217
    218     // Bail if super admin is author
     218    // Bail if super admin is author.
    219219    if ( is_super_admin( $user_id ) ) {
    220220        return true;
    221221    }
    222222
    223     // Define local variable
     223    // Define local variable.
    224224    $_post = array();
    225225
    226     /** Blacklist *************************************************************/
    227 
    228     // Get the moderation keys
     226    /** Blacklist ************************************************************
     227     */
     228
     229    // Get the moderation keys.
    229230    $blacklist = trim( get_option( 'blacklist_keys' ) );
    230231
    231     // Bail if blacklist is empty
     232    // Bail if blacklist is empty.
    232233    if ( empty( $blacklist ) ) {
    233234        return true;
    234235    }
    235236
    236     /** User Data *************************************************************/
    237 
    238     // Map current user data
     237    /** User Data ************************************************************
     238     */
     239
     240    // Map current user data.
    239241    if ( ! empty( $user_id ) ) {
    240242
    241         // Get author data
     243        // Get author data.
    242244        $user = get_userdata( $user_id );
    243245
    244         // If data exists, map it
     246        // If data exists, map it.
    245247        if ( ! empty( $user ) ) {
    246248            $_post['author'] = $user->display_name;
     
    250252    }
    251253
    252     // Current user IP and user agent
     254    // Current user IP and user agent.
    253255    $_post['user_ip'] = bp_core_current_user_ip();
    254256    $_post['user_ua'] = bp_core_current_user_ua();
    255257
    256     // Post title and content
     258    // Post title and content.
    257259    $_post['title']   = $title;
    258260    $_post['content'] = $content;
    259261
    260     /** Words *****************************************************************/
    261 
    262     // Get words separated by new lines
     262    /** Words ****************************************************************
     263     */
     264
     265    // Get words separated by new lines.
    263266    $words = explode( "\n", $blacklist );
    264267
    265     // Loop through words
     268    // Loop through words.
    266269    foreach ( (array) $words as $word ) {
    267270
    268         // Trim the whitespace from the word
     271        // Trim the whitespace from the word.
    269272        $word = trim( $word );
    270273
    271         // Skip empty lines
     274        // Skip empty lines.
    272275        if ( empty( $word ) ) { continue; }
    273276
    274277        // Do some escaping magic so that '#' chars in the
    275         // spam words don't break things:
     278        // spam words don't break things.
    276279        $word    = preg_quote( $word, '#' );
    277280        $pattern = "#$word#i";
    278281
    279         // Loop through post data
     282        // Loop through post data.
    280283        foreach( $_post as $post_data ) {
    281284
    282             // Check each user data for current word
     285            // Check each user data for current word.
    283286            if ( preg_match( $pattern, $post_data ) ) {
    284287
    285                 // Post does not pass
     288                // Post does not pass.
    286289                return false;
    287290            }
     
    289292    }
    290293
    291     // Check passed successfully
     294    // Check passed successfully.
    292295    return true;
    293296}
     
    322325function bp_core_current_user_ua() {
    323326
    324     // Sanity check the user agent
     327    // Sanity check the user agent.
    325328    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
    326329        $retval = substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 );
  • trunk/src/bp-core/bp-core-options.php

    r10152 r10356  
    1919function bp_get_default_options() {
    2020
    21     // Default options
     21    // Default options.
    2222    $options = array (
    2323
    24         /** Components ********************************************************/
     24        /* Components ********************************************************/
    2525
    2626        'bp-deactivated-components'            => array(),
    2727
    28         /** bbPress ***********************************************************/
    29 
    30         // Legacy bbPress config location
     28        /* bbPress ***********************************************************/
     29
     30        // Legacy bbPress config location.
    3131        'bb-config-location'                   => ABSPATH . 'bb-config.php',
    3232
    33         /** XProfile **********************************************************/
    34 
    35         // Base profile groups name
     33        /* XProfile **********************************************************/
     34
     35        // Base profile groups name.
    3636        'bp-xprofile-base-group-name'          => 'Base',
    3737
    38         // Base fullname field name
     38        // Base fullname field name.
    3939        'bp-xprofile-fullname-field-name'      => 'Name',
    4040
    41         /** Blogs *************************************************************/
    42 
    43         // Used to decide if blogs need indexing
     41        /* Blogs *************************************************************/
     42
     43        // Used to decide if blogs need indexing.
    4444        'bp-blogs-first-install'               => false,
    4545
    46         /** Settings **********************************************************/
    47 
    48         // Disable the WP to BP profile sync
     46        /* Settings **********************************************************/
     47
     48        // Disable the WP to BP profile sync.
    4949        'bp-disable-profile-sync'              => false,
    5050
    51         // Hide the Toolbar for logged out users
     51        // Hide the Toolbar for logged out users.
    5252        'hide-loggedout-adminbar'              => false,
    5353
    54         // Avatar uploads
     54        // Avatar uploads.
    5555        'bp-disable-avatar-uploads'            => false,
    5656
    57         // Cover image uploads
     57        // Cover image uploads.
    5858        'bp-disable-cover-image-uploads'       => false,
    5959
    60         // Group Profile Photos
     60        // Group Profile Photos.
    6161        'bp-disable-group-avatar-uploads'      => false,
    6262
    63         // Group Cover image uploads
     63        // Group Cover image uploads.
    6464        'bp-disable-group-cover-image-uploads' => false,
    6565
    66         // Allow users to delete their own accounts
     66        // Allow users to delete their own accounts.
    6767        'bp-disable-account-deletion'          => false,
    6868
    69         // Allow comments on blog and forum activity items
     69        // Allow comments on blog and forum activity items.
    7070        'bp-disable-blogforum-comments'        => true,
    7171
     
    7373        '_bp_theme_package_id'                 => 'legacy',
    7474
    75         /** Groups ************************************************************/
     75        /* Groups ************************************************************/
    7676
    7777        // @todo Move this into the groups component
    78 
    79         // Restrict group creation to super admins
     78        // Restrict group creation to super admins.
    8079        'bp_restrict_group_creation'           => false,
    8180
    82         /** Akismet ***********************************************************/
    83 
    84         // Users from all sites can post
     81        /* Akismet ***********************************************************/
     82
     83        // Users from all sites can post.
    8584        '_bp_enable_akismet'                   => true,
    8685
    87         /** Activity HeartBeat ************************************************/
    88 
    89         // HeartBeat is on to refresh activities
     86        /* Activity HeartBeat ************************************************/
     87
     88        // HeartBeat is on to refresh activities.
    9089        '_bp_enable_heartbeat_refresh'         => true,
    9190
    92         /** BuddyBar **********************************************************/
    93 
    94         // Force the BuddyBar
     91        /* BuddyBar **********************************************************/
     92
     93        // Force the BuddyBar.
    9594        '_bp_force_buddybar'                   => false,
    9695
    97         /** Legacy theme *********************************************/
    98 
    99         // Whether to register the bp-default themes directory
     96        /* Legacy theme *********************************************/
     97
     98        // Whether to register the bp-default themes directory.
    10099        '_bp_retain_bp_default'                => false,
    101100
    102         /** Widgets **************************************************/
     101        /* Widgets **************************************************/
    103102        'widget_bp_core_login_widget'                => false,
    104103        'widget_bp_core_members_widget'              => false,
     
    133132function bp_add_options() {
    134133
    135     // Get the default options and values
     134    // Get the default options and values.
    136135    $options = bp_get_default_options();
    137136
    138     // Add default options
     137    // Add default options.
    139138    foreach ( $options as $key => $value ) {
    140139        bp_add_option( $key, $value );
     
    167166function bp_delete_options() {
    168167
    169     // Get the default options and values
     168    // Get the default options and values.
    170169    $options = bp_get_default_options();
    171170
    172     // Add default options
     171    // Add default options.
    173172    foreach ( array_keys( $options ) as $key ) {
    174173        delete_option( $key );
     
    198197function bp_setup_option_filters() {
    199198
    200     // Get the default options and values
     199    // Get the default options and values.
    201200    $options = bp_get_default_options();
    202201
    203     // Add filters to each BuddyPress option
     202    // Add filters to each BuddyPress option.
    204203    foreach ( array_keys( $options ) as $key ) {
    205204        add_filter( 'pre_option_' . $key, 'bp_pre_get_option' );
     
    224223 *
    225224 * @param bool $value Optional. Default value false.
    226  *
    227225 * @return mixed False if not overloaded, mixed if set.
    228226 */
     
    230228    $bp = buddypress();
    231229
    232     // Get the name of the current filter so we can manipulate it
     230    // Get the name of the current filter so we can manipulate it.
    233231    $filter = current_filter();
    234232
    235     // Remove the filter prefix
     233    // Remove the filter prefix.
    236234    $option = str_replace( 'pre_option_', '', $filter );
    237235
    238     // Check the options global for preset value
     236    // Check the options global for preset value.
    239237    if ( ! empty( $bp->options[ $option ] ) ) {
    240238        $value = $bp->options[ $option ];
    241239    }
    242240
    243     // Always return a value, even if false
     241    // Always return a value, even if false.
    244242    return $value;
    245243}
     
    260258 * @param string $default     Optional. Default value to be returned if the option
    261259 *                            isn't set. See {@link get_blog_option()}.
    262  *
    263260 * @return mixed The value for the option.
    264261 */
     
    286283 * @param string $option_name The option key to be set.
    287284 * @param mixed  $value       The value to be set.
    288  *
    289285 * @return bool True on success, false on failure.
    290286 */
     
    306302 * @param string $option_name The option key to be set.
    307303 * @param string $value       The value to be set.
    308  *
    309304 * @return bool True on success, false on failure.
    310305 */
     
    325320 *
    326321 * @param string $option_name The option key to be deleted.
    327  *
    328322 * @return bool True on success, false on failure.
    329323 */
     
    342336 * @deprecated 1.6.0
    343337 *
    344  * @param array $keys
    345  *
     338 * @param array $keys Array of site options.
    346339 * @return bool
    347340 */
     
    385378    global $wpdb;
    386379
    387     // Get all the BuddyPress settings, and a few useful WP ones too
     380    // Get all the BuddyPress settings, and a few useful WP ones too.
    388381    $root_blog_options                   = bp_get_default_options();
    389382    $root_blog_options['registration']   = '0';
     
    394387    // Check cache first - We cache here instead of using the standard WP
    395388    // settings cache because the current blog may not be the root blog,
    396     // and it's not practical to access the cache across blogs
     389    // and it's not practical to access the cache across blogs.
    397390    $root_blog_options_meta = wp_cache_get( 'root_blog_options', 'bp' );
    398391
     
    403396        $root_blog_options_meta = $wpdb->get_results( $blog_options_query );
    404397
    405         // On Multisite installations, some options must always be fetched from sitemeta
     398        // On Multisite installations, some options must always be fetched from sitemeta.
    406399        if ( is_multisite() ) {
    407400
     
    426419            $network_options_meta   = $wpdb->get_results( $sitemeta_options_query );
    427420
    428             // Sitemeta comes second in the merge, so that network 'registration' value wins
     421            // Sitemeta comes second in the merge, so that network 'registration' value wins.
    429422            $root_blog_options_meta = array_merge( $root_blog_options_meta, $network_options_meta );
    430423        }
    431424
    432         // Missing some options, so do some one-time fixing
     425        // Missing some options, so do some one-time fixing.
    433426        if ( empty( $root_blog_options_meta ) || ( count( $root_blog_options_meta ) < count( $root_blog_option_keys ) ) ) {
    434427
    435             // Get a list of the keys that are already populated
     428            // Get a list of the keys that are already populated.
    436429            $existing_options = array();
    437430            foreach( $root_blog_options_meta as $already_option ) {
     
    439432            }
    440433
    441             // Unset the query - We'll be resetting it soon
     434            // Unset the query - We'll be resetting it soon.
    442435            unset( $root_blog_options_meta );
    443436
    444             // Loop through options
     437            // Loop through options.
    445438            foreach ( $root_blog_options as $old_meta_key => $old_meta_default ) {
    446439
     
    449442                }
    450443
    451                 // Get old site option
     444                // Get old site option.
    452445                if ( is_multisite() ) {
    453446                    $old_meta_value = get_site_option( $old_meta_key );
    454447                }
    455448
    456                 // No site option so look in root blog
     449                // No site option so look in root blog.
    457450                if ( empty( $old_meta_value ) ) {
    458451                    $old_meta_value = bp_get_option( $old_meta_key, $old_meta_default );
    459452                }
    460453
    461                 // Update the root blog option
     454                // Update the root blog option.
    462455                bp_update_option( $old_meta_key, $old_meta_value );
    463456
    464                 // Update the global array
     457                // Update the global array.
    465458                $root_blog_options_meta[$old_meta_key] = $old_meta_value;
    466459
    467                 // Clear out the value for the next time around
     460                // Clear out the value for the next time around.
    468461                unset( $old_meta_value );
    469462            }
     
    472465            unset( $existing_options );
    473466
    474         // We're all matched up
     467        // We're all matched up.
    475468        } else {
    476             // Loop through our results and make them usable
     469            // Loop through our results and make them usable.
    477470            foreach ( $root_blog_options_meta as $root_blog_option ) {
    478471                $root_blog_options[$root_blog_option->name] = $root_blog_option->value;
    479472            }
    480473
    481             // Copy the options no the return val
     474            // Copy the options no the return val.
    482475            $root_blog_options_meta = $root_blog_options;
    483476
    484             // Clean up our temporary copy
     477            // Clean up our temporary copy.
    485478            unset( $root_blog_options );
    486479        }
     
    509502 *
    510503 * @param  string $option Name of the option key.
    511  *
    512504 * @return mixed Value, if found.
    513505 */
     
    538530 * @param bool $default Optional. Fallback value if not found in the database.
    539531 *                      Default: true.
    540  *
    541532 * @return bool True if profile sync is enabled, otherwise false.
    542533 */
     
    562553 * @param bool $default Optional. Fallback value if not found in the database.
    563554 *                      Default: true.
    564  *
    565555 * @return bool True if the admin bar should be hidden for logged-out users,
    566556 *              otherwise false.
     
    587577 * @param bool $default Optional. Fallback value if not found in the database.
    588578 *                      Default: true.
    589  *
    590579 * @return bool True if avatar uploads are disabled, otherwise false.
    591580 */
     
    611600 * @param bool $default Optional. Fallback value if not found in the database.
    612601 *                      Default: false.
    613  *
    614602 * @return bool True if cover image uploads are disabled, otherwise false.
    615603 */
     
    636624 * @param bool|null $default Optional. Fallback value if not found in the database.
    637625 *                           Defaults to the value of `bp_disable_avatar_uploads()`.
    638  *
    639626 * @return bool True if group avatar uploads are disabled, otherwise false.
    640627 */
     
    670657 * @param bool $default Optional. Fallback value if not found in the database.
    671658 *                      Default: false.
    672  *
    673659 * @return bool True if group cover image uploads are disabled, otherwise false.
    674660 */
     
    694680 * @param bool $default Optional. Fallback value if not found in the database.
    695681 *                      Default: true.
    696  *
    697682 * @return bool True if users are able to delete their own accounts, otherwise
    698683 *              false.
     
    720705 * @param bool $default Optional. Fallback value if not found in the database.
    721706 *                      Default: false.
    722  *
    723707 * @return bool True if activity comments are disabled for blog and forum
    724708 *              items, otherwise false.
     
    746730 * @param bool $default Optional. Fallback value if not found in the database.
    747731 *                      Default: true.
    748  *
    749732 * @return bool True if group creation is restricted, otherwise false.
    750733 */
     
    770753 * @param bool $default Optional. Fallback value if not found in the database.
    771754 *                      Default: true.
    772  *
    773755 * @return bool True if the BuddyBar should be forced on, otherwise false.
    774756 */
     
    803785     *
    804786     * @param bool|string $default Optional. Default: '0'.
    805      *
    806787     * @return int The ID of the group forums root forum.
    807788     */
     
    827808 * @param bool $default Optional. Fallback value if not found in the database.
    828809 *                      Default: true.
    829  *
    830810 * @return bool True if group forums are active, otherwise false.
    831811 */
     
    851831 * @param bool $default Optional. Fallback value if not found in the database.
    852832 *                      Default: true.
    853  *
    854833 * @return bool True if Akismet is enabled, otherwise false.
    855834 */
     
    875854 * @param bool $default Optional. Fallback value if not found in the database.
    876855 *                      Default: true.
    877  *
    878856 * @return bool True if Heartbeat refresh is enabled, otherwise false.
    879857 */
     
    899877 * @param string $default Optional. Fallback value if not found in the database.
    900878 *                        Default: 'legacy'.
    901  *
    902879 * @return string ID of the theme package.
    903880 */
  • trunk/src/bp-core/bp-core-taxonomy.php

    r10108 r10356  
    4040 * @param string       $taxonomy  Taxonomy name.
    4141 * @param bool         $append    Optional. True to append terms to existing terms. Default: false.
    42  *
    4342 * @return array Array of term taxonomy IDs.
    4443 */
     
    6968 * @param string|array $taxonomies Name or names of taxonomies to match.
    7069 * @param array        $args       See {@see wp_get_object_terms()}.
    71  *
    7270 * @return array
    7371 */
     
    9896 * @param string|array $terms     Term or terms to remove.
    9997 * @param string       $taxonomy  Taxonomy name.
    100  *
    10198 * @return bool|WP_Error True on success, false or WP_Error on failure.
    10299 */
  • trunk/src/bp-core/bp-core-template-loader.php

    r10279 r10356  
    2727 * @param string $name Optional. Template part name. Used to generate
    2828 *                     secondary filenames, eg 'personal' for 'activity-personal.php'.
    29  *
    3029 * @return string Path to located template. See {@link bp_locate_template()}.
    3130 */
     
    4443    do_action( 'get_template_part_' . $slug, $slug, $name );
    4544
    46     // Setup possible parts
     45    // Setup possible parts.
    4746    $templates = array();
    4847    if ( isset( $name ) ) {
     
    6261    $templates = apply_filters( 'bp_get_template_part', $templates, $slug, $name );
    6362
    64     // Return the part that is found
     63    // Return the part that is found.
    6564    return bp_locate_template( $templates, true, false );
    6665}
     
    8079 * @param bool         $require_once   Optional. Whether to require_once or require. Has
    8180 *                                     no effect if $load is false. Default: true.
    82  *
    8381 * @return string The template filename if one is located.
    8482 */
    8583function bp_locate_template( $template_names, $load = false, $require_once = true ) {
    8684
    87     // No file found yet
     85    // No file found yet.
    8886    $located            = false;
    8987    $template_locations = bp_get_template_stack();
    9088
    91     // Try to find a template file
     89    // Try to find a template file.
    9290    foreach ( (array) $template_names as $template_name ) {
    9391
    94         // Continue if template is empty
     92        // Continue if template is empty.
    9593        if ( empty( $template_name ) ) {
    9694            continue;
    9795        }
    9896
    99         // Trim off any slashes from the template name
     97        // Trim off any slashes from the template name.
    10098        $template_name  = ltrim( $template_name, '/' );
    10199
    102         // Loop through template stack
     100        // Loop through template stack.
    103101        foreach ( (array) $template_locations as $template_location ) {
    104102
    105             // Continue if $template_location is empty
     103            // Continue if $template_location is empty.
    106104            if ( empty( $template_location ) ) {
    107105                continue;
    108106            }
    109107
    110             // Check child theme first
     108            // Check child theme first.
    111109            if ( file_exists( trailingslashit( $template_location ) . $template_name ) ) {
    112110                $located = trailingslashit( $template_location ) . $template_name;
     
    125123    do_action( 'bp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once );
    126124
    127     // Maybe load the template if one was located
     125    // Maybe load the template if one was located.
    128126    $use_themes = defined( 'WP_USE_THEMES' ) && WP_USE_THEMES;
    129127    $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
     
    147145 * @param int    $priority          Optional. The priority parameter as passed to
    148146 *                                  add_filter(). Default: 10.
    149  *
    150147 * @return bool See {@link add_filter()}.
    151148 */
    152149function bp_register_template_stack( $location_callback = '', $priority = 10 ) {
    153150
    154     // Bail if no location, or function/method is not callable
     151    // Bail if no location, or function/method is not callable.
    155152    if ( empty( $location_callback ) || ! is_callable( $location_callback ) ) {
    156153        return false;
    157154    }
    158155
    159     // Add location callback to template stack
     156    // Add location callback to template stack.
    160157    return add_filter( 'bp_template_stack', $location_callback, (int) $priority );
    161158}
     
    171168 * @param int    $priority          Optional. The priority parameter passed to
    172169 *                                  {@link bp_register_template_stack()}. Default: 10.
    173  *
    174170 * @return bool See {@link remove_filter()}.
    175171 */
    176172function bp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
    177173
    178     // Bail if no location, or function/method is not callable
     174    // Bail if no location, or function/method is not callable.
    179175    if ( empty( $location_callback ) || ! is_callable( $location_callback ) ) {
    180176        return false;
    181177    }
    182178
    183     // Add location callback to template stack
     179    // Add location callback to template stack.
    184180    return remove_filter( 'bp_template_stack', $location_callback, (int) $priority );
    185181}
     
    199195 * @global array $wp_current_filter Stores the list of current filters with
    200196 *                                  the current one last.
    201  *
    202197 * @return array The filtered value after all hooked functions are applied to it.
    203198 */
     
    205200    global $wp_filter, $merged_filters, $wp_current_filter;
    206201
    207     // Setup some default variables
     202    // Setup some default variables.
    208203    $tag  = 'bp_template_stack';
    209204    $args = $stack = array();
    210205
    211     // Add 'bp_template_stack' to the current filter array
     206    // Add 'bp_template_stack' to the current filter array.
    212207    $wp_current_filter[] = $tag;
    213208
    214     // Sort
     209    // Sort.
    215210    if ( class_exists( 'WP_Hook' ) ) {
    216211        $filter = $wp_filter[ $tag ]->callbacks;
     
    224219    }
    225220
    226     // Ensure we're always at the beginning of the filter array
     221    // Ensure we're always at the beginning of the filter array.
    227222    reset( $filter );
    228223
    229     // Loop through 'bp_template_stack' filters, and call callback functions
     224    // Loop through 'bp_template_stack' filters, and call callback functions.
    230225    do {
    231226        foreach( (array) current( $filter ) as $the_ ) {
     
    237232    } while ( next( $filter ) !== false );
    238233
    239     // Remove 'bp_template_stack' from the current filter array
     234    // Remove 'bp_template_stack' from the current filter array.
    240235    array_pop( $wp_current_filter );
    241236
    242     // Remove empties and duplicates
     237    // Remove empties and duplicates.
    243238    $stack = array_unique( array_filter( $stack ) );
    244239
     
    264259 * @param bool   $echo If true, template content will be echoed. If false,
    265260 *                     returned. Default: true.
    266  *
    267261 * @return string|null If $echo, returns the template content.
    268262 */
     
    270264    ob_start();
    271265
    272     // Remove 'bp_replace_the_content' filter to prevent infinite loops
     266    // Remove 'bp_replace_the_content' filter to prevent infinite loops.
    273267    remove_filter( 'the_content', 'bp_replace_the_content' );
    274268
    275269    bp_get_template_part( $slug, $name );
    276270
    277     // Remove 'bp_replace_the_content' filter to prevent infinite loops
     271    // Remove 'bp_replace_the_content' filter to prevent infinite loops.
    278272    add_filter( 'the_content', 'bp_replace_the_content' );
    279273
    280     // Get the output buffer contents
     274    // Get the output buffer contents.
    281275    $output = ob_get_clean();
    282276
    283     // Echo or return the output buffer contents
     277    // Echo or return the output buffer contents.
    284278    if ( true === $echo ) {
    285279        echo $output;
     
    305299 * @param string $type      Filename without extension.
    306300 * @param array  $templates An optional list of template candidates.
    307  *
    308301 * @return string Full path to file.
    309302 */
     
    352345 *
    353346 * @param array $templates Templates we are looking for.
    354  *
    355347 * @return array Possible subfolders to look in.
    356348 */
     
    379371 *
    380372 * @param array $stacks Array of template locations.
    381  *
    382373 * @return array() Array of all template locations registered so far.
    383374 */
     
    385376    $retval = array();
    386377
    387     // Get alternate locations
     378    // Get alternate locations.
    388379    $locations = bp_get_template_locations();
    389380
    390     // Loop through locations and stacks and combine
     381    // Loop through locations and stacks and combine.
    391382    foreach ( (array) $stacks as $stack ) {
    392383        foreach ( (array) $locations as $custom_location ) {
     
    411402 * @since 1.7.0
    412403 *
    413  * @param WP_Query $posts_query
     404 * @param WP_Query $posts_query WP_Query object.
    414405 */
    415406function bp_parse_query( $posts_query ) {
    416407
    417     // Bail if $posts_query is not the main loop
     408    // Bail if $posts_query is not the main loop.
    418409    if ( ! $posts_query->is_main_query() ) {
    419410        return;
    420411    }
    421412
    422     // Bail if filters are suppressed on this query
     413    // Bail if filters are suppressed on this query.
    423414    if ( true == $posts_query->get( 'suppress_filters' ) ) {
    424415        return;
    425416    }
    426417
    427     // Bail if in admin
     418    // Bail if in admin.
    428419    if ( is_admin() ) {
    429420        return;
     
    454445 * @since 1.7.0
    455446 *
    456  * @param string $template
    457  *
     447 * @param string $template The path to the template file that is being used.
    458448 * @return string The path to the template file that is being used.
    459449 */
     
    492482 *
    493483 * @param mixed $template Default: false.
    494  *
    495484 * @return mixed False if empty. Template name if template included.
    496485 */
     
    523512    global $pagenow, $wp_query;
    524513
    525     // do not load our custom BP functions file if theme compat is disabled
     514    // Do not load our custom BP functions file if theme compat is disabled.
    526515    if ( ! bp_use_theme_compat_with_current_theme() ) {
    527516        return;
    528517    }
    529518
    530     // Do not include on BuddyPress deactivation
     519    // Do not include on BuddyPress deactivation.
    531520    if ( bp_is_deactivation() ) {
    532521        return;
     
    536525    // or has been reset), load_template() will fail at setting certain
    537526    // global values. This does not happen on a normal page load, but can
    538     // cause problems when running automated tests
     527    // cause problems when running automated tests.
    539528    if ( ! is_a( $wp_query, 'WP_Query' ) ) {
    540529        return;
    541530    }
    542531
    543     // Only include if not installing or if activating via wp-activate.php
     532    // Only include if not installing or if activating via wp-activate.php.
    544533    if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
    545534        bp_locate_template( 'buddypress-functions.php', true );
  • trunk/src/bp-core/bp-core-template.php

    r10209 r10356  
    2727 *       viewed user.
    2828 *
    29  * @param string $parent_slug
    30  *
     29 * @param string $parent_slug Options nav slug.
    3130 * @return string
    3231 */
     
    3534
    3635    // If we are looking at a member profile, then the we can use the current
    37     // component as an index. Otherwise we need to use the component's root_slug
     36    // component as an index. Otherwise we need to use the component's root_slug.
    3837    $component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() );
    3938    $selected_item   = bp_current_action();
     
    6059    }
    6160
    62     // Loop through each navigation item
     61    // Loop through each navigation item.
    6362    foreach ( (array) $bp->bp_options_nav[$the_index] as $subnav_item ) {
    6463        if ( empty( $subnav_item['user_has_access'] ) ) {
     
    7372        }
    7473
    75         // List type depends on our current component
     74        // List type depends on our current component.
    7675        $list_type = bp_is_group() ? 'groups' : 'personal';
    7776
     
    9594 *
    9695 * Not currently used in BuddyPress.
     96 *
    9797 * @todo Deprecate.
    9898 */
     
    115115 * @since 2.0.0
    116116 *
    117  * @param string $component
    118  *
     117 * @param string $component Component to get directory title for.
    119118 * @return string
    120119 */
     
    122121    $title = '';
    123122
    124     // Use the string provided by the component
     123    // Use the string provided by the component.
    125124    if ( ! empty( buddypress()->{$component}->directory_title ) ) {
    126125        $title = buddypress()->{$component}->directory_title;
    127126
    128     // If none is found, concatenate
     127    // If none is found, concatenate.
    129128    } elseif ( isset( buddypress()->{$component}->name ) ) {
    130129        $title = sprintf( __( '%s Directory', 'buddypress' ), buddypress()->{$component}->name );
     
    341340 * @since 1.1.0
    342341 *
    343  * @param int|string  $time         The UNIX timestamp to be formatted.
    344  * @param bool        $exclude_time Optional. True to return only the month + day, false
    345  *                                  to return month, day, and time. Default: false.
    346  * @param bool        $gmt          Optional. True to display in local time, false to
     342 * @param int|string $time         The UNIX timestamp to be formatted.
     343 * @param bool       $exclude_time Optional. True to return only the month + day, false
     344 *                                 to return month, day, and time. Default: false.
     345 * @param bool       $gmt          Optional. True to display in local time, false to
    347346 *                                  leave in GMT. Default: true.
    348  *
    349347 * @return mixed A string representation of $time, in the format
    350348 *               "March 18, 2014 at 2:00 pm" (or whatever your
     
    355353
    356354    // Bail if time is empty or not numeric
    357     // @todo We should output something smarter here
     355    // @todo We should output something smarter here.
    358356    if ( empty( $time ) || ! is_numeric( $time ) ) {
    359357        return false;
    360358    }
    361359
    362     // Get GMT offset from root blog
     360    // Get GMT offset from root blog.
    363361    if ( true === $gmt ) {
    364362
    365         // Use Timezone string if set
     363        // Use Timezone string if set.
    366364        $timezone_string = bp_get_option( 'timezone_string' );
    367365        if ( ! empty( $timezone_string ) ) {
     
    370368            $timezone_offset = timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS;
    371369
    372         // Fall back on less reliable gmt_offset
     370        // Fall back on less reliable gmt_offset.
    373371        } else {
    374372            $timezone_offset = bp_get_option( 'gmt_offset' );
    375373        }
    376374
    377         // Calculate time based on the offset
     375        // Calculate time based on the offset.
    378376        $calculated_time = $time + ( $timezone_offset * HOUR_IN_SECONDS );
    379377
    380     // No localizing, so just use the time that was submitted
     378    // No localizing, so just use the time that was submitted.
    381379    } else {
    382380        $calculated_time = $time;
    383381    }
    384382
    385     // Formatted date: "March 18, 2014"
     383    // Formatted date: "March 18, 2014".
    386384    $formatted_date = date_i18n( bp_get_option( 'date_format' ), $calculated_time, $gmt );
    387385
     
    389387    if ( true !== $exclude_time ) {
    390388
    391         // Formatted time: "2:00 pm"
     389        // Formatted time: "2:00 pm".
    392390        $formatted_time = date_i18n( bp_get_option( 'time_format' ), $calculated_time, $gmt );
    393391
    394         // Return string formatted with date and time
     392        // Return string formatted with date and time.
    395393        $formatted_date = sprintf( esc_html__( '%1$s at %2$s', 'buddypress' ), $formatted_date, $formatted_time );
    396394    }
     
    415413 * do the necessary argument swapping for dynamic phrases.
    416414 *
    417  * @param string $youtext  The "you" version of the phrase (eg "Your Friends").
    418  * @param string $nametext The other-user version of the phrase. Should be in
    419  *                         a format appropriate for sprintf() - use %s in place of the displayed
    420  *                         user's name (eg "%'s Friends").
    421  * @param bool $capitalize Optional. Force into title case. Default: true.
    422  * @param bool $echo       Optional. True to echo the results, false to return them.
    423  *                         Default: true.
    424  *
     415 * @param string $youtext    The "you" version of the phrase (eg "Your Friends").
     416 * @param string $nametext   The other-user version of the phrase. Should be in
     417 *                           a format appropriate for sprintf() - use %s in place of the displayed
     418 *                           user's name (eg "%'s Friends").
     419 * @param bool   $capitalize Optional. Force into title case. Default: true.
     420 * @param bool   $echo       Optional. True to echo the results, false to return them.
     421 *                           Default: true.
    425422 * @return string|null $nametext If ! $echo, returns the appropriate string.
    426423 */
     
    569566     *
    570567     * @param string $component Component name. Default: current component.
    571      *
    572568     * @return string Placeholder text for search field.
    573569     */
     
    582578        $default_text = __( 'Search anything...', 'buddypress' );
    583579
    584         // Most of the time, $component will be the actual component ID
     580        // Most of the time, $component will be the actual component ID.
    585581        if ( !empty( $component ) ) {
    586582            if ( !empty( $bp->{$component}->search_string ) ) {
     
    588584            } else {
    589585                // When the request comes through AJAX, we need to get the component
    590                 // name out of $bp->pages
     586                // name out of $bp->pages.
    591587                if ( !empty( $bp->pages->{$component}->slug ) ) {
    592588                    $key = $bp->pages->{$component}->slug;
     
    757753 * @param int    $length Optional. Length of returned string, including ellipsis.
    758754 *                       Default: 225.
    759  * @param array $options {
     755 * @param array  $options {
    760756 *     An array of HTML attributes and options. Each item is optional.
    761757 *     @type string $ending            The string used after truncation.
     
    772768function bp_create_excerpt( $text, $length = 225, $options = array() ) {
    773769
    774     // Backward compatibility. The third argument used to be a boolean $filter_shortcodes
     770    // Backward compatibility. The third argument used to be a boolean $filter_shortcodes.
    775771    $filter_shortcodes_default = is_bool( $options ) ? $options : true;
    776772
     
    782778    ), 'create_excerpt' );
    783779
    784     // Save the original text, to be passed along to the filter
     780    // Save the original text, to be passed along to the filter.
    785781    $original_text = $text;
    786782
     
    803799    $ending = apply_filters( 'bp_excerpt_append_text', $r['ending'] );
    804800
    805     // Remove shortcodes if necessary
     801    // Remove shortcodes if necessary.
    806802    if ( ! empty( $r['filter_shortcodes'] ) ) {
    807803        $text = strip_shortcodes( $text );
     
    809805
    810806    // When $html is true, the excerpt should be created without including HTML tags in the
    811     // excerpt length
     807    // excerpt length.
    812808    if ( ! empty( $r['html'] ) ) {
    813809
    814         // The text is short enough. No need to truncate
     810        // The text is short enough. No need to truncate.
    815811        if ( mb_strlen( preg_replace( '/<.*?>/', '', $text ) ) <= $length ) {
    816812            return $text;
     
    821817        $truncate    = '';
    822818
    823         // Find all the tags and HTML comments and put them in a stack for later use
     819        // Find all the tags and HTML comments and put them in a stack for later use.
    824820        preg_match_all( '/(<\/?([\w+!]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER );
    825821
    826822        foreach ( $tags as $tag ) {
    827             // Process tags that need to be closed
     823            // Process tags that need to be closed.
    828824            if ( !preg_match( '/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s',  $tag[2] ) ) {
    829825                if ( preg_match( '/<[\w]+[^>]*>/s', $tag[0] ) ) {
     
    872868    }
    873869
    874     // If $exact is false, we can't break on words
     870    // If $exact is false, we can't break on words.
    875871    if ( empty( $r['exact'] ) ) {
    876872        // Find the position of the last space character not part of a tag.
     
    11161112 * WordPress theme without coping the functions from functions.php.
    11171113 *
    1118  * @param string|bool $object
    1119  *
     1114 * @param string|bool $object Current template component.
    11201115 * @return string The AJAX querystring.
    11211116 */
     
    12331228 *
    12341229 * @param int $position The key of the action_variables array that you want.
    1235  *
    12361230 * @return string|bool $action_variable The value of that position in the
    12371231 *                                      array, or false if not found.
     
    13231317     *
    13241318     * @param string $component Optional. Defaults to the current component.
    1325      *
    13261319     * @return string $root_slug The root slug.
    13271320     */
     
    13301323        $root_slug = '';
    13311324
    1332         // Use current global component if none passed
     1325        // Use current global component if none passed.
    13331326        if ( empty( $component ) ) {
    13341327            $component = bp_current_component();
    13351328        }
    13361329
    1337         // Component is active
     1330        // Component is active.
    13381331        if ( ! empty( $bp->active_components[ $component ] ) ) {
    13391332
    13401333            // Backward compatibility: in legacy plugins, the canonical component id
    1341             // was stored as an array value in $bp->active_components
     1334            // was stored as an array value in $bp->active_components.
    13421335            $component_name = ( '1' == $bp->active_components[ $component ] )
    13431336                ? $component
    13441337                : $bp->active_components[$component];
    13451338
    1346             // Component has specific root slug
     1339            // Component has specific root slug.
    13471340            if ( ! empty( $bp->{$component_name}->root_slug ) ) {
    13481341                $root_slug = $bp->{$component_name}->root_slug;
     
    13501343        }
    13511344
    1352         // No specific root slug, so fall back to component slug
     1345        // No specific root slug, so fall back to component slug.
    13531346        if ( empty( $root_slug ) ) {
    13541347            $root_slug = $component;
     
    13721365 *
    13731366 * @param string $root_slug Needle to our active component haystack.
    1374  *
    13751367 * @return mixed False if none found, component name if found.
    13761368 */
     
    13781370    $bp = buddypress();
    13791371
    1380     // If no slug is passed, look at current_component
     1372    // If no slug is passed, look at current_component.
    13811373    if ( empty( $root_slug ) ) {
    13821374        $root_slug = bp_current_component();
    13831375    }
    13841376
    1385     // No current component or root slug, so flee
     1377    // No current component or root slug, so flee.
    13861378    if ( empty( $root_slug ) ) {
    13871379        return false;
    13881380    }
    13891381
    1390     // Loop through active components and look for a match
     1382    // Loop through active components and look for a match.
    13911383    foreach ( array_keys( $bp->active_components ) as $component ) {
    13921384        if ( ( ! empty( $bp->{$component}->slug ) && ( $bp->{$component}->slug == $root_slug ) ) || ( ! empty( $bp->{$component}->root_slug ) && ( $bp->{$component}->root_slug === $root_slug ) ) ) {
     
    14861478}
    14871479
    1488 /** is_() functions to determine the current page *****************************/
     1480/** The is_() functions to determine the current page *****************************/
    14891481
    14901482/**
     
    15001492 *
    15011493 * @param string $component Name of the component being checked.
    1502  *
    15031494 * @return bool Returns true if the component matches, or else false.
    15041495 */
    15051496function bp_is_current_component( $component = '' ) {
    15061497
    1507     // Default is no match. We'll check a few places for matches
     1498    // Default is no match. We'll check a few places for matches.
    15081499    $is_current_component = false;
    15091500
    1510     // Always return false if a null value is passed to the function
     1501    // Always return false if a null value is passed to the function.
    15111502    if ( empty( $component ) ) {
    15121503        return false;
    15131504    }
    15141505
    1515     // Backward compatibility: 'xprofile' should be read as 'profile'
     1506    // Backward compatibility: 'xprofile' should be read as 'profile'.
    15161507    if ( 'xprofile' === $component ) {
    15171508        $component = 'profile';
     
    15201511    $bp = buddypress();
    15211512
    1522     // Only check if BuddyPress found a current_component
     1513    // Only check if BuddyPress found a current_component.
    15231514    if ( ! empty( $bp->current_component ) ) {
    15241515
    15251516        // First, check to see whether $component_name and the current
    1526         // component are a simple match
     1517        // component are a simple match.
    15271518        if ( $bp->current_component == $component ) {
    15281519            $is_current_component = true;
    15291520
    15301521        // Since the current component is based on the visible URL slug let's
    1531         // check the component being passed and see if its root_slug matches
     1522        // check the component being passed and see if its root_slug matches.
    15321523        } elseif ( isset( $bp->{$component}->root_slug ) && $bp->{$component}->root_slug == $bp->current_component ) {
    15331524            $is_current_component = true;
    15341525
    1535         // Because slugs can differ from root_slugs, we should check them too
     1526        // Because slugs can differ from root_slugs, we should check them too.
    15361527        } elseif ( isset( $bp->{$component}->slug ) && $bp->{$component}->slug == $bp->current_component ) {
    15371528            $is_current_component = true;
     
    15461537
    15471538        // If we haven't found a match yet, check against the root_slugs
    1548         // created by $bp->pages, as well as the regular slugs
     1539        // created by $bp->pages, as well as the regular slugs.
    15491540        } else {
    15501541            foreach ( $bp->active_components as $id ) {
    15511542                // If the $component parameter does not match the current_component,
    1552                 // then move along, these are not the droids you are looking for
     1543                // then move along, these are not the droids you are looking for.
    15531544                if ( empty( $bp->{$id}->root_slug ) || $bp->{$id}->root_slug != $bp->current_component ) {
    15541545                    continue;
     
    15891580 *
    15901581 * @param string $action The action being tested against.
    1591  *
    15921582 * @return bool True if the current action matches $action.
    15931583 */
     
    16141604 *                                  don't provide a $position, the function will return true if the
    16151605 *                                  $action_variable is found *anywhere* in the action variables array.
    1616  *
    16171606 * @return bool True if $action_variable matches at the $position provided.
    16181607 */
     
    16211610
    16221611    if ( false !== $position ) {
    1623         // When a $position is specified, check that slot in the action_variables array
     1612        // When a $position is specified, check that slot in the action_variables array.
    16241613        if ( $action_variable ) {
    16251614            $is_action_variable = $action_variable == bp_action_variable( $position );
    16261615        } else {
    16271616            // If no $action_variable is provided, we are essentially checking to see
    1628             // whether the slot is empty
     1617            // whether the slot is empty.
    16291618            $is_action_variable = !bp_action_variable( $position );
    16301619        }
    16311620    } else {
    1632         // When no $position is specified, check the entire array
     1621        // When no $position is specified, check the entire array.
    16331622        $is_action_variable = in_array( $action_variable, (array)bp_action_variables() );
    16341623    }
     
    16501639 *
    16511640 * @param string $item The item being checked.
    1652  *
    16531641 * @return bool True if $item is the current item.
    16541642 */
     
    16681656
    16691657/**
    1670  * Are we looking at a single item? (group, user, etc)
     1658 * Are we looking at a single item? (group, user, etc).
    16711659 *
    16721660 * @return bool True if looking at a single item, otherwise false.
     
    17701758 * already deprecated functions.
    17711759 *
    1772  * @param string $component_name
     1760 * @param string $component_name Component name to check.
    17731761 *
    17741762 * @return bool True if root component, else false.
     
    17781766    $retval = false;
    17791767
    1780     // Default to the current component if none is passed
     1768    // Default to the current component if none is passed.
    17811769    if ( empty( $component_name ) ) {
    17821770        $component_name = bp_current_component();
    17831771    }
    17841772
    1785     // Loop through active components and check for key/slug matches
     1773    // Loop through active components and check for key/slug matches.
    17861774    if ( ! empty( $bp->active_components ) ) {
    17871775        foreach ( (array) $bp->active_components as $key => $slug ) {
     
    18141802 * @param string $component Optional. Name of the component to check for.
    18151803 *                          Default: current component.
    1816  *
    18171804 * @return bool True if the specified component is set to be the site's front
    18181805 *              page, otherwise false.
     
    18231810    $bp = buddypress();
    18241811
    1825     // Default to the current component if none is passed
     1812    // Default to the current component if none is passed.
    18261813    if ( empty( $component ) ) {
    18271814        $component = bp_current_component();
    18281815    }
    18291816
    1830     // Get the path for the current blog/site
     1817    // Get the path for the current blog/site.
    18311818    $path = is_main_site()
    18321819        ? bp_core_get_site_path()
    18331820        : $current_blog->path;
    18341821
    1835     // Get the front page variables
     1822    // Get the front page variables.
    18361823    $show_on_front = get_option( 'show_on_front' );
    18371824    $page_on_front = get_option( 'page_on_front' );
     
    19181905 * @param string $component The component name.
    19191906 * @param string $feature   The feature name.
    1920  *
    19211907 * @return bool
    19221908 */
     
    19241910    $retval = false;
    19251911
    1926     // Default to the current component if none is passed
     1912    // Default to the current component if none is passed.
    19271913    if ( empty( $component ) ) {
    19281914        $component = bp_current_component();
    19291915    }
    19301916
    1931     // Is component in either the active or required components arrays
     1917    // Is component in either the active or required components arrays.
    19321918    if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
    19331919        $retval = true;
     
    19351921        // Is feature active?
    19361922        if ( ! empty( $feature ) ) {
    1937             // The xProfile component is specific
     1923            // The xProfile component is specific.
    19381924            if ( 'xprofile' === $component ) {
    19391925                $component = 'profile';
     
    20932079 * @since 2.0.0
    20942080 *
    2095  * @return True if the current page is the activity directory.
     2081 * @return bool True if the current page is the activity directory.
    20962082 */
    20972083function bp_is_activity_directory() {
     
    21062092 * Is the current page a single activity item permalink?
    21072093 *
    2108  * @return True if the current page is a single activity item permalink.
     2094 * @return bool True if the current page is a single activity item permalink.
    21092095 */
    21102096function bp_is_single_activity() {
     
    21192105 * @since 2.0.0
    21202106 *
    2121  * @return True if the current page is the members directory.
     2107 * @return bool True if the current page is the members directory.
    21222108 */
    21232109function bp_is_members_directory() {
     
    21352121 * http://example.com/members/joe/friends/.
    21362122 *
    2137  * @return True if the current page is part of the profile of the logged-in user.
     2123 * @return bool True if the current page is part of the profile of the logged-in user.
    21382124 */
    21392125function bp_is_my_profile() {
     
    21592145 * Will return true anytime there is a displayed user.
    21602146 *
    2161  * @return True if the current page is a user page.
     2147 * @return bool True if the current page is a user page.
    21622148 */
    21632149function bp_is_user() {
     
    21702156 * Eg http://example.com/members/joe/activity/ (or any subpages thereof).
    21712157 *
    2172  * @return True if the current page is a user's activity stream page.
     2158 * @return bool True if the current page is a user's activity stream page.
    21732159 */
    21742160function bp_is_user_activity() {
     
    21812167 * Eg http://example.com/members/joe/friends/
    21822168 *
    2183  * @return True if the current page is a user's Friends activity stream.
     2169 * @return bool True if the current page is a user's Friends activity stream.
    21842170 */
    21852171function bp_is_user_friends_activity() {
     
    22072193 * Eg http://example.com/members/joe/groups/
    22082194 *
    2209  * @return True if the current page is a user's Groups activity stream.
     2195 * @return bool True if the current page is a user's Groups activity stream.
    22102196 */
    22112197function bp_is_user_groups_activity() {
     
    22312217 * Eg http://example.com/members/joe/profile/ (or a subpage thereof).
    22322218 *
    2233  * @return True if the current page is part of a user's extended profile.
     2219 * @return bool True if the current page is part of a user's extended profile.
    22342220 */
    22352221function bp_is_user_profile() {
     
    22422228 * Eg http://example.com/members/joe/profile/edit/ (or a subpage thereof).
    22432229 *
    2244  * @return True if the current page is a user's profile edit page.
     2230 * @return bool True if the current page is a user's profile edit page.
    22452231 */
    22462232function bp_is_user_profile_edit() {
     
    22592245 * @since  2.4.0
    22602246 *
    2261  * @return True if the current page is a user's profile edit cover image page.
     2247 * @return bool True if the current page is a user's profile edit cover image page.
    22622248 */
    22632249function bp_is_user_change_cover_image() {
     
    24562442
    24572443/**
    2458  * Is the current page the groups directory ?
     2444 * Is the current page the groups directory?
    24592445 *
    24602446 * @since 2.0.0
     
    25332519    $retval = false;
    25342520
    2535     // At a forum URL
     2521    // At a forum URL.
    25362522    if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) ) {
    25372523        $retval = true;
     
    27662752 * @param string $component Current component to check for.
    27672753 * @param string $callback  Callback to invoke.
    2768  *
    27692754 * @return bool
    27702755 */
     
    28102795     * @param array      $wp_classes     The body classes coming from WP.
    28112796     * @param array|bool $custom_classes Classes that were passed to get_body_class().
    2812      *
    28132797     * @return array $classes The BP-adjusted body classes.
    28142798     */
     
    28172801        $bp_classes = array();
    28182802
    2819         /** Pages *************************************************************/
     2803        /* Pages *************************************************************/
    28202804
    28212805        if ( is_front_page() ) {
     
    28312815        }
    28322816
    2833         /** Components ********************************************************/
     2817        /* Components ********************************************************/
    28342818
    28352819        if ( ! bp_is_blog_page() ) {
     
    28632847        }
    28642848
    2865         /** User **************************************************************/
     2849        /* User **************************************************************/
    28662850
    28672851        if ( bp_is_user() ) {
     
    29232907        }
    29242908
    2925         /** Messages **********************************************************/
     2909        /* Messages **********************************************************/
    29262910
    29272911        if ( bp_is_messages_inbox() ) {
     
    29492933        }
    29502934
    2951         /** Groups ************************************************************/
     2935        /* Groups ************************************************************/
    29522936
    29532937        if ( bp_is_group() ) {
     
    29972981        }
    29982982
    2999         /** Registration ******************************************************/
     2983        /* Registration ******************************************************/
    30002984
    30012985        if ( bp_is_register_page() ) {
     
    30072991        }
    30082992
    3009         /** Current Component & Action ****************************************/
     2993        /* Current Component & Action ****************************************/
    30102994
    30112995        if ( ! bp_is_blog_page() ) {
     
    30142998        }
    30152999
    3016         /** Clean up ***********************************************************/
    3017 
    3018         // Add BuddyPress class if we are within a BuddyPress page
     3000        /* Clean up ***********************************************************/
     3001
     3002        // Add BuddyPress class if we are within a BuddyPress page.
    30193003        if ( ! bp_is_blog_page() ) {
    30203004            $bp_classes[] = 'buddypress';
    30213005        }
    30223006
    3023         // Merge WP classes with BuddyPress classes and remove any duplicates
     3007        // Merge WP classes with BuddyPress classes and remove any duplicates.
    30243008        $classes = array_unique( array_merge( (array) $bp_classes, (array) $wp_classes ) );
    30253009
     
    30463030 *
    30473031 * @param array $wp_classes The post classes coming from WordPress.
    3048  *
    30493032 * @return array
    30503033 */
    30513034function bp_get_the_post_class( $wp_classes = array() ) {
    3052     // don't do anything if we're not on a BP page
     3035    // Don't do anything if we're not on a BP page.
    30533036    if ( ! is_buddypress() ) {
    30543037        return $wp_classes;
     
    30833066    }
    30843067
    3085     // emulate post type css class
     3068    // Emulate post type css class.
    30863069    foreach ( $bp_classes as $bp_class ) {
    30873070        $bp_classes[] = "type-{$bp_class}";
    30883071    }
    30893072
    3090     // okay let's merge!
     3073    // Okay let's merge!
    30913074    return array_unique( array_merge( $bp_classes, $wp_classes ) );
    30923075}
     
    31043087 * @param array $a First item.
    31053088 * @param array $b Second item.
    3106  *
    31073089 * @return int Returns an integer less than, equal to, or greater than zero if
    31083090 *             the first argument is considered to be respectively less than,
     
    31293111    $menus = $selected_menus = array();
    31303112
    3131     // Get the second level menus
     3113    // Get the second level menus.
    31323114    foreach ( (array) buddypress()->bp_options_nav as $parent_menu => $sub_menus ) {
    31333115
     
    31373119        }
    31383120
    3139         // Sort the items in this menu's navigation by their position property
     3121        // Sort the items in this menu's navigation by their position property.
    31403122        $second_level_menus = (array) $sub_menus;
    31413123        usort( $second_level_menus, '_bp_nav_menu_sort' );
    31423124
    3143         // Iterate through the second level menus
     3125        // Iterate through the second level menus.
    31443126        foreach( $second_level_menus as $sub_nav ) {
    31453127
    3146             // Skip items we don't have access to
     3128            // Skip items we don't have access to.
    31473129            if ( empty( $sub_nav['user_has_access'] ) ) {
    31483130                continue;
    31493131            }
    31503132
    3151             // Add this menu
     3133            // Add this menu.
    31523134            $menu         = new stdClass;
    31533135            $menu->class  = array( 'menu-child' );
     
    31553137            $menu->link   = $sub_nav['link'];
    31563138            $menu->name   = $sub_nav['name'];
    3157             $menu->parent = $parent_menu;  // Associate this sub nav with a top-level menu
    3158 
    3159             // If we're viewing this item's screen, record that we need to mark its parent menu to be selected
     3139            $menu->parent = $parent_menu;  // Associate this sub nav with a top-level menu.
     3140
     3141            // If we're viewing this item's screen, record that we need to mark its parent menu to be selected.
    31603142            if ( $sub_nav['slug'] == bp_current_action() ) {
    31613143                $menu->class[]    = 'current-menu-item';
     
    31673149    }
    31683150
    3169     // Get the top-level menu parts (Friends, Groups, etc) and sort by their position property
     3151    // Get the top-level menu parts (Friends, Groups, etc) and sort by their position property.
    31703152    $top_level_menus = (array) buddypress()->bp_nav;
    31713153    usort( $top_level_menus, '_bp_nav_menu_sort' );
    31723154
    3173     // Iterate through the top-level menus
     3155    // Iterate through the top-level menus.
    31743156    foreach ( $top_level_menus as $nav ) {
    31753157
    3176         // Skip items marked as user-specific if you're not on your own profile
     3158        // Skip items marked as user-specific if you're not on your own profile.
    31773159        if ( empty( $nav['show_for_displayed_user'] ) && ! bp_core_can_edit_settings()  ) {
    31783160            continue;
    31793161        }
    31803162
    3181         // Get the correct menu link. See https://buddypress.trac.wordpress.org/ticket/4624
     3163        // Get the correct menu link. See https://buddypress.trac.wordpress.org/ticket/4624.
    31823164        $link = bp_loggedin_user_domain() ? str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav['link'] ) : trailingslashit( bp_displayed_user_domain() . $nav['link'] );
    31833165
    3184         // Add this menu
     3166        // Add this menu.
    31853167        $menu         = new stdClass;
    31863168        $menu->class  = array( 'menu-parent' );
     
    31903172        $menu->parent = 0;
    31913173
    3192         // Check if we need to mark this menu as selected
     3174        // Check if we need to mark this menu as selected.
    31933175        if ( in_array( $nav['css_id'], $selected_menus ) ) {
    31943176            $menu->class[] = 'current-menu-parent';
     
    32423224 *                                   Default: 'BP_Walker_Nav_Menu'.
    32433225 * }
    3244  *
    32453226 * @return string|null If $echo is false, returns a string containing the nav
    32463227 *                     menu markup.
     
    32803261    $show_container = false;
    32813262
    3282     // Create custom walker if one wasn't set
     3263    // Create custom walker if one wasn't set.
    32833264    if ( empty( $args->walker ) ) {
    32843265        $args->walker = new BP_Walker_Nav_Menu;
    32853266    }
    32863267
    3287     // Sanitise values for class and ID
     3268    // Sanitise values for class and ID.
    32883269    $args->container_class = sanitize_html_class( $args->container_class );
    32893270    $args->container_id    = sanitize_html_class( $args->container_id );
    32903271
    3291     // Whether to wrap the ul, and what to wrap it with
     3272    // Whether to wrap the ul, and what to wrap it with.
    32923273    if ( $args->container ) {
    32933274
     
    33293310        $wrap_id = 'menu-bp';
    33303311
    3331         // If a specific ID wasn't requested, and there are multiple menus on the same screen, make sure the autogenerated ID is unique
     3312        // If a specific ID wasn't requested, and there are multiple menus on the same screen, make sure the autogenerated ID is unique.
    33323313        while ( in_array( $wrap_id, $menu_id_slugs ) ) {
    33333314            if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) {
     
    33523333    $items = apply_filters( 'bp_nav_menu_items', $items, $args );
    33533334
    3354     // Build the output
     3335    // Build the output.
    33553336    $wrap_class  = $args->menu_class ? $args->menu_class : '';
    33563337    $nav_menu   .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items );
    33573338    unset( $items );
    33583339
    3359     // If we've wrapped the ul, close it
     3340    // If we've wrapped the ul, close it.
    33603341    if ( ! empty( $show_container ) ) {
    33613342        $nav_menu .= '</' . $args->container . '>';
  • trunk/src/bp-core/bp-core-theme-compatibility.php

    r10327 r10356  
    7575     */
    7676    protected function start() {
    77         // Sanity check
     77        // Sanity check.
    7878        if ( ! bp_use_theme_compat_with_current_theme() ) {
    7979            return;
    8080        }
    8181
    82         // Setup methods
     82        // Setup methods.
    8383        $this->setup_globals();
    8484        $this->setup_actions();
     
    112112     * @param string $property Property name.
    113113     * @param mixed  $value    Property value.
    114      *
    115114     * @return bool True on success, false on failure.
    116115     */
     
    125124     *
    126125     * @param string $property Property name.
    127      *
    128126     * @return mixed The value of the property if it exists, otherwise an
    129127     *               empty string.
     
    146144    $bp = buddypress();
    147145
    148     // Make sure theme package is available, set to default if not
     146    // Make sure theme package is available, set to default if not.
    149147    if ( ! isset( $bp->theme_compat->packages[$theme] ) || ! is_a( $bp->theme_compat->packages[$theme], 'BP_Theme_Compat' ) ) {
    150148        $theme = 'legacy';
    151149    }
    152150
    153     // Set the active theme compat theme
     151    // Set the active theme compat theme.
    154152    $bp->theme_compat->theme = $bp->theme_compat->packages[$theme];
    155153}
     
    230228 * Get the absolute path of the theme package being used.
    231229 *
    232  * or set manually. Tricky theme authors can override the default and include
     230 * Or set manually. Tricky theme authors can override the default and include
    233231 * their own BuddyPress compatibility layers for their themes.
    234232 *
     
    324322    }
    325323
    326     // theme compat enabled by default
     324    // Theme compat enabled by default.
    327325    $theme_compat = true;
    328326
     
    331329        $theme_compat = false;
    332330
    333     // If the theme doesn't support BP, do some additional checks
     331    // If the theme doesn't support BP, do some additional checks.
    334332    } else {
    335         // Bail if theme is a derivative of bp-default
     333        // Bail if theme is a derivative of bp-default.
    336334        if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
    337335            $theme_compat = false;
    338336
    339         // Brute-force check for a BP template
    340         // Examples are clones of bp-default
     337        // Brute-force check for a BP template.
     338        // Examples are clones of bp-default.
    341339        } elseif ( locate_template( 'members/members-loop.php', false, false ) ) {
    342340            $theme_compat = false;
     
    344342    }
    345343
    346     // set a flag in the buddypress() singleton so we don't have to run this again
     344    // Set a flag in the buddypress() singleton so we don't have to run this again.
    347345    buddypress()->theme_compat->use_with_current_theme = $theme_compat;
    348346
     
    373371 *
    374372 * @param bool $set True to set the flag to true, false to set it to false.
    375  *
    376373 * @return bool Returns the value of $set.
    377374 */
     
    391388 *
    392389 * @param array $templates The template stack.
    393  *
    394390 * @return array The template stack (value of $templates).
    395391 */
     
    409405 *
    410406 * @param string $template The template currently in use.
    411  *
    412407 * @return string The template currently in use (value of $template).
    413408 */
     
    427422 *
    428423 * @param string $template The template originally selected by WP.
    429  *
    430424 * @return string The template originally selected by WP (value of $template).
    431425 */
     
    441435 * @since 2.4.0
    442436 *
    443  * @param  string $theme_id the theme id (eg: legacy)
    444  * @param  array  $feature  an associative array (eg: array( name => 'feature_name', 'settings' => array() ))
     437 * @param  string $theme_id The theme id (eg: legacy).
     438 * @param  array  $feature  An associative array (eg: array( name => 'feature_name', 'settings' => array() )).
    445439 */
    446440function bp_set_theme_compat_feature( $theme_id, $feature = array() ) {
     
    449443    }
    450444
    451     // Get BuddyPress instance
     445    // Get BuddyPress instance.
    452446    $bp = buddypress();
    453447
    454     // Get current theme compat theme
     448    // Get current theme compat theme.
    455449    $theme_compat_theme = $bp->theme_compat->theme;
    456450
    457     // Bail if the Theme Compat theme is not in use
     451    // Bail if the Theme Compat theme is not in use.
    458452    if ( $theme_id !== bp_get_theme_compat_id() ) {
    459453        return;
     
    465459    }
    466460
    467     // Bail if the feature is already registered or no settings were provided
     461    // Bail if the feature is already registered or no settings were provided.
    468462    if ( isset( $features[ $feature['name'] ] ) || empty( $feature['settings'] ) ) {
    469463        return;
    470464    }
    471465
    472     // Add the feature
     466    // Add the feature.
    473467    $features[ $feature['name'] ] = (object) $feature['settings'];
    474468
    475     // The feature is attached to components
     469    // The feature is attached to components.
    476470    if ( isset( $features[ $feature['name'] ]->components ) ) {
    477         // Set the feature for each concerned component
     471        // Set the feature for each concerned component.
    478472        foreach ( (array) $features[ $feature['name'] ]->components as $component ) {
    479             // The xProfile component is specific
     473            // The xProfile component is specific.
    480474            if ( 'xprofile' === $component ) {
    481475                $component = 'profile';
     
    492486    }
    493487
    494     // Finally update the theme compat features
     488    // Finally update the theme compat features.
    495489    $theme_compat_theme->__set( 'features', $features );
    496490}
     
    501495 * @since 2.4.0
    502496 *
    503  * @param  string $feature the feature (eg: cover_image)
    504  * @return object          the feature settings.
     497 * @param  string $feature The feature (eg: cover_image).
     498 * @return object          The feature settings.
    505499 */
    506500function bp_get_theme_compat_feature( $feature = '' ) {
    507     // Get current theme compat theme
     501    // Get current theme compat theme.
    508502    $theme_compat_theme = buddypress()->theme_compat->theme;
    509503
    510     // Get features
     504    // Get features.
    511505    $features = $theme_compat_theme->__get( 'features' );
    512506
     
    526520 * @since 2.4.0
    527521 *
    528  * @global $content_width the content width of the theme
     522 * @global string $content_width the content width of the theme
    529523 */
    530524function bp_register_theme_compat_default_features() {
    531525    global $content_width;
    532526
    533     // Do not set up default features on deactivation
     527    // Do not set up default features on deactivation.
    534528    if ( bp_is_deactivation() ) {
    535529        return;
     
    546540    }
    547541
    548     // Get the theme
     542    // Get the theme.
    549543    $current_theme = wp_get_theme();
    550544    $theme_handle  = $current_theme->get_stylesheet();
     
    560554     * content width for the concerned themes.
    561555     *
    562      * array( stylesheet => content width used by BuddyPress )
     556     * Example: array( stylesheet => content width used by BuddyPress )
    563557     */
    564558    $bp_content_widths = array(
     
    568562    );
    569563
    570     // Default values
     564    // Default values.
    571565    $bp_content_width = (int) $content_width;
    572566    $bp_handle        = 'bp-legacy-css';
    573567
    574     // Specific to themes having companion stylesheets
     568    // Specific to themes having companion stylesheets.
    575569    if ( isset( $bp_content_widths[ $theme_handle ] ) ) {
    576570        $bp_content_width = $bp_content_widths[ $theme_handle ];
     
    607601 *
    608602 * @param string $template The template name to check.
    609  *
    610603 * @return bool True if the value of $template is the same as the
    611604 *              "original_template" originally selected by WP. Otherwise false.
     
    637630function bp_register_theme_package( $theme = array(), $override = true ) {
    638631
    639     // Create new BP_Theme_Compat object from the $theme array
     632    // Create new BP_Theme_Compat object from the $theme array.
    640633    if ( is_array( $theme ) ) {
    641634        $theme = new BP_Theme_Compat( $theme );
    642635    }
    643636
    644     // Bail if $theme isn't a proper object
     637    // Bail if $theme isn't a proper object.
    645638    if ( ! is_a( $theme, 'BP_Theme_Compat' ) ) {
    646639        return;
    647640    }
    648641
    649     // Load up BuddyPress
     642    // Load up BuddyPress.
    650643    $bp = buddypress();
    651644
    652645    // Only set if the theme package was not previously registered or if the
    653     // override flag is set
     646    // override flag is set.
    654647    if ( empty( $bp->theme_compat->packages[$theme->id] ) || ( true === $override ) ) {
    655648        $bp->theme_compat->packages[$theme->id] = $theme;
     
    676669    global $wp_query, $post;
    677670
    678     // Switch defaults if post is set
     671    // Switch defaults if post is set.
    679672    if ( isset( $wp_query->post ) ) {
    680673        $dummy = wp_parse_args( $args, array(
     
    745738    }
    746739
    747     // Bail if dummy post is empty
     740    // Bail if dummy post is empty.
    748741    if ( empty( $dummy ) ) {
    749742        return;
    750743    }
    751744
    752     // Set the $post global
     745    // Set the $post global.
    753746    $post = new WP_Post( (object) $dummy );
    754747
    755     // Copy the new post global into the main $wp_query
     748    // Copy the new post global into the main $wp_query.
    756749    $wp_query->post       = $post;
    757750    $wp_query->posts      = array( $post );
    758751
    759     // Prevent comments form from appearing
     752    // Prevent comments form from appearing.
    760753    $wp_query->post_count = 1;
    761754    $wp_query->is_404     = $dummy['is_404'];
     
    765758    $wp_query->is_tax     = $dummy['is_tax'];
    766759
    767     // Clean up the dummy post
     760    // Clean up the dummy post.
    768761    unset( $dummy );
    769762
     
    777770    }
    778771
    779     // If we are resetting a post, we are in theme compat
     772    // If we are resetting a post, we are in theme compat.
    780773    bp_set_theme_compat_active( true );
    781774
    782     // If we are in theme compat, we don't need the 'Edit' post link
     775    // If we are in theme compat, we don't need the 'Edit' post link.
    783776    add_filter( 'get_edit_post_link', 'bp_core_filter_edit_post_link', 10, 2 );
    784777}
     
    808801 *
    809802 * @param string $template Template name.
    810  *
    811803 * @return string $template Template name.
    812804 */
     
    829821    do_action( 'bp_template_include_reset_dummy_post_data' );
    830822
    831     // Bail if the template already matches a BuddyPress template
     823    // Bail if the template already matches a BuddyPress template.
    832824    if ( ! empty( buddypress()->theme_compat->found_template ) ) {
    833825        return $template;
     
    856848        add_filter( 'the_content', 'bp_replace_the_content' );
    857849
    858         // Add BuddyPress's head action to wp_head
     850        // Add BuddyPress's head action to wp_head.
    859851        if ( ! has_action( 'wp_head', 'bp_head' ) ) {
    860852            add_action( 'wp_head', 'bp_head' );
     
    882874 *
    883875 * @param string $content Original post content.
    884  *
    885876 * @return string $content Post content, potentially modified.
    886877 */
    887878function bp_replace_the_content( $content = '' ) {
    888879
    889     // Bail if not the main loop where theme compat is happening
     880    // Bail if not the main loop where theme compat is happening.
    890881    if ( ! bp_do_theme_compat() ) {
    891882        return $content;
     
    905896    $new_content = apply_filters( 'bp_replace_the_content', $content );
    906897
    907     // Juggle the content around and try to prevent unsightly comments
     898    // Juggle the content around and try to prevent unsightly comments.
    908899    if ( ! empty( $new_content ) && ( $new_content !== $content ) ) {
    909900
    910         // Set the content to be the new content
     901        // Set the content to be the new content.
    911902        $content = $new_content;
    912903
    913         // Clean up after ourselves
     904        // Clean up after ourselves.
    914905        unset( $new_content );
    915906
    916         // Reset the $post global
     907        // Reset the $post global.
    917908        wp_reset_postdata();
    918909    }
    919910
    920     // Return possibly hi-jacked content
     911    // Return possibly hi-jacked content.
    921912    return $content;
    922913}
     
    951942 *                           at a given priority will be removed. Otherwise, all callbacks
    952943 *                           attached to the tag will be removed, regardless of priority.
    953  *
    954944 * @return bool True on success.
    955945 */
     
    959949    $bp = buddypress();
    960950
    961     // Filters exist
     951    // Filters exist.
    962952    if ( isset( $wp_filter[$tag] ) ) {
    963953
    964         // Filters exist in this priority
     954        // Filters exist in this priority.
    965955        if ( ! empty( $priority ) && isset( $wp_filter[$tag][$priority] ) ) {
    966956
    967             // Store filters in a backup
     957            // Store filters in a backup.
    968958            $bp->filters->wp_filter[$tag][$priority] = $wp_filter[$tag][$priority];
    969959
    970             // Unset the filters
     960            // Unset the filters.
    971961            unset( $wp_filter[$tag][$priority] );
    972962
    973         // Priority is empty
     963        // Priority is empty.
    974964        } else {
    975965
    976             // Store filters in a backup
     966            // Store filters in a backup.
    977967            $bp->filters->wp_filter[$tag] = $wp_filter[$tag];
    978968
    979             // Unset the filters
     969            // Unset the filters.
    980970            unset( $wp_filter[$tag] );
    981971        }
    982972    }
    983973
    984     // Check merged filters
     974    // Check merged filters.
    985975    if ( isset( $merged_filters[$tag] ) ) {
    986976
    987         // Store filters in a backup
     977        // Store filters in a backup.
    988978        $bp->filters->merged_filters[$tag] = $merged_filters[$tag];
    989979
    990         // Unset the filters
     980        // Unset the filters.
    991981        unset( $merged_filters[$tag] );
    992982    }
     
    1007997 *                           attached to the tag with $priority will be restored. Otherwise,
    1008998 *                           all available filters will be restored, regardless of priority.
    1009  *
    1010999 * @return bool True on success.
    10111000 */
     
    10151004    $bp = buddypress();
    10161005
    1017     // Filters exist
     1006    // Filters exist.
    10181007    if ( isset( $bp->filters->wp_filter[$tag] ) ) {
    10191008
    1020         // Filters exist in this priority
     1009        // Filters exist in this priority.
    10211010        if ( ! empty( $priority ) && isset( $bp->filters->wp_filter[$tag][$priority] ) ) {
    10221011
    1023             // Store filters in a backup
     1012            // Store filters in a backup.
    10241013            $wp_filter[$tag][$priority] = $bp->filters->wp_filter[$tag][$priority];
    10251014
    1026             // Unset the filters
     1015            // Unset the filters.
    10271016            unset( $bp->filters->wp_filter[$tag][$priority] );
    10281017
    1029         // Priority is empty
     1018        // Priority is empty.
    10301019        } else {
    10311020
    1032             // Store filters in a backup
     1021            // Store filters in a backup.
    10331022            $wp_filter[$tag] = $bp->filters->wp_filter[$tag];
    10341023
    1035             // Unset the filters
     1024            // Unset the filters.
    10361025            unset( $bp->filters->wp_filter[$tag] );
    10371026        }
    10381027    }
    10391028
    1040     // Check merged filters
     1029    // Check merged filters.
    10411030    if ( isset( $bp->filters->merged_filters[$tag] ) ) {
    10421031
    1043         // Store filters in a backup
     1032        // Store filters in a backup.
    10441033        $merged_filters[$tag] = $bp->filters->merged_filters[$tag];
    10451034
    1046         // Unset the filters
     1035        // Unset the filters.
    10471036        unset( $bp->filters->merged_filters[$tag] );
    10481037    }
     
    10581047 * @param bool $open    True if open, false if closed.
    10591048 * @param int  $post_id ID of the post to check.
    1060  *
    10611049 * @return bool True if open, false if closed.
    10621050 */
     
    10941082 *
    10951083 * @param string $retval The current post content.
    1096  *
    10971084 * @return string $retval
    10981085 */
     
    11021089    $wp_query->is_page = false;
    11031090
    1104     // Set a switch so we know that we've toggled these WP_Query properties
     1091    // Set a switch so we know that we've toggled these WP_Query properties.
    11051092    buddypress()->theme_compat->is_page_toggled = true;
    11061093
     
    11191106function bp_theme_compat_loop_end( $query ) {
    11201107
    1121     // Get BuddyPress
     1108    // Get BuddyPress.
    11221109    $bp = buddypress();
    11231110
    1124     // Bail if page is not toggled
     1111    // Bail if page is not toggled.
    11251112    if ( ! isset( $bp->theme_compat->is_page_toggled ) ) {
    11261113        return;
    11271114    }
    11281115
    1129     // Revert our toggled WP_Query properties
     1116    // Revert our toggled WP_Query properties.
    11301117    $query->is_page = true;
    11311118
    1132     // Unset our switch
     1119    // Unset our switch.
    11331120    unset( $bp->theme_compat->is_page_toggled );
    11341121}
  • trunk/src/bp-core/bp-core-update.php

    r10349 r10356  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    6161 *
    6262 * @param string $basename BuddyPress basename.
    63  *
    6463 * @return bool True if activating BuddyPress, false if not.
    6564 */
     
    108107 *
    109108 * @param string $basename BuddyPress basename.
    110  *
    111109 * @return bool True if deactivating BuddyPress, false if not.
    112110 */
  • trunk/src/bp-core/bp-core-widgets.php

    r10211 r10356  
    156156     * @param array $new_instance The new instance options.
    157157     * @param array $old_instance The old instance options.
    158      *
    159158     * @return array $instance The parsed options to be saved.
    160159     */
     
    170169     *
    171170     * @param array $instance Settings for this widget.
    172      *
    173171     * @return void
    174172     */
  • trunk/src/bp-core/bp-core-wpabstraction.php

    r10108 r10356  
    4040
    4141    if ( !function_exists( 'get_blog_option' ) ) {
    42         /**
     42
     43        /**
     44         * Retrieve blog option.
     45         *
    4346         * @see get_blog_option()
     47         *
     48         * @param int    $blog_id     Blog ID to fetch for. Not used.
     49         * @param string $option_name Option name to fetch.
     50         * @param bool   $default     Whether or not default.
     51         *
     52         * @return mixed
    4453         */
    4554        function get_blog_option( $blog_id, $option_name, $default = false ) {
     
    4958
    5059    if ( ! function_exists( 'add_blog_option' ) ) {
    51         /**
     60
     61        /**
     62         * Add blog option
     63         *
    5264         * @see add_blog_option()
     65         *
     66         * @param int    $blog_id      Blog ID to add for. Not used.
     67         * @param string $option_name  Option name to add.
     68         * @param mixed  $option_value Option value to add.
     69         *
     70         * @return mixed
    5371         */
    5472        function add_blog_option( $blog_id, $option_name, $option_value ) {
     
    5876
    5977    if ( !function_exists( 'update_blog_option' ) ) {
    60         /**
     78
     79        /**
     80         * Update blog option.
     81         *
    6182         * @see update_blog_option()
     83         *
     84         * @param int    $blog_id     Blog ID to update for. Not used.
     85         * @param string $option_name Option name to update.
     86         * @param mixed  $value       Option value to update.
     87         *
     88         * @return mixed
    6289         */
    6390        function update_blog_option( $blog_id, $option_name, $value ) {
     
    6794
    6895    if ( !function_exists( 'delete_blog_option' ) ) {
    69         /**
     96
     97        /**
     98         * Delete blog option.
     99         *
    70100         * @see delete_blog_option()
     101         *
     102         * @param int    $blog_id     Blog ID to delete for. Not used.
     103         * @param string $option_name Option name to delete.
     104         *
     105         * @return mixed
    71106         */
    72107        function delete_blog_option( $blog_id, $option_name ) {
     
    76111
    77112    if ( !function_exists( 'switch_to_blog' ) ) {
    78         /**
     113
     114        /**
     115         * Switch to specified blog.
     116         *
    79117         * @see switch_to_blog()
     118         *
     119         * @param mixed $new_blog   New blog to switch to. Not used.
     120         * @param null  $deprecated Whether or not deprecated. Not used.
     121         *
     122         * @return int
    80123         */
    81124        function switch_to_blog( $new_blog, $deprecated = null ) {
     
    85128
    86129    if ( !function_exists( 'restore_current_blog' ) ) {
    87         /**
     130
     131        /**
     132         * Restore current blog.
     133         *
    88134         * @see restore_current_blog()
     135         *
     136         * @return int
    89137         */
    90138        function restore_current_blog() {
     
    94142
    95143    if ( !function_exists( 'get_blogs_of_user' ) ) {
    96         /**
     144
     145        /**
     146         * Retrive blogs associated with user.
     147         *
    97148         * @see get_blogs_of_user()
     149         *
     150         * @param int  $user_id ID of the user. Not used.
     151         * @param bool $all     Whether or not to return all. Not used.
     152         *
     153         * @return false
    98154         */
    99155        function get_blogs_of_user( $user_id, $all = false ) {
     
    104160    if ( !function_exists( 'update_blog_status' ) ) {
    105161        /**
     162         * Whether or not to update blog status.
     163         *
    106164         * @see update_blog_status()
     165         *
     166         * @param int    $blog_id    Blog to update status for. Not used.
     167         * @param mixed  $pref       Preference. Not used.
     168         * @param string $value      Value. Not used.
     169         * @param null   $deprecated Whether or not deprecated. Not used.
     170         *
     171         * @return true
    107172         */
    108173        function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
     
    113178    if ( !function_exists( 'is_subdomain_install' ) ) {
    114179        /**
     180         * Whether or not if subdomain install.
     181         *
    115182         * @see is_subdomain_install()
     183         *
     184         * @return bool
    116185         */
    117186        function is_subdomain_install() {
     
    131200 *
    132201 * @param string|bool $prefix Global table prefix.
    133  *
    134202 * @return string SQL chunk.
    135203 */
     
    155223     * @param string $str String to be measured.
    156224     * @param string $enc Optional. Encoding type. Ignored.
    157      *
    158225     * @return int String length.
    159226     */
     
    162229        $total = 0;
    163230
    164         // Count ASCII bytes
     231        // Count ASCII bytes.
    165232        for( $i = 0; $i < 0x80; $i++ ) {
    166233            $total += $counts[$i];
    167234        }
    168235
    169         // Count multibyte sequence heads
     236        // Count multibyte sequence heads.
    170237        for( $i = 0xc0; $i < 0xff; $i++ ) {
    171238            $total += $counts[$i];
     
    183250     * @param int    $offset Optional. Start position for the search. Default: 0.
    184251     * @param string $encoding Optional. Encoding type. Ignored.
    185      *
    186252     * @return int|bool Position of needle in haystack if found, else false.
    187253     */
     
    208274     * @param int    $offset Optional. Start position for the search. Default: 0.
    209275     * @param string $encoding Optional. Encoding type. Ignored.
    210      *
    211276     * @return int Position of last needle in haystack if found, else false.
    212277     */
Note: See TracChangeset for help on using the changeset viewer.