Skip to:
Content

BuddyPress.org

Changeset 10180


Ignore:
Timestamp:
10/04/2015 06:17:20 AM (5 years ago)
Author:
tw2113
Message:

Clean up bp-functions.php documentation.

See #6644.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-legacy/buddypress-functions.php

    r10155 r10180  
    11<?php
    22/**
    3  * Functions of BuddyPress's Legacy theme
     3 * Functions of BuddyPress's Legacy theme.
    44 *
    55 * @since 1.7.0
     
    1717
    1818/**
    19  * Loads BuddyPress Legacy Theme functionality
     19 * Loads BuddyPress Legacy Theme functionality.
    2020 *
    2121 * This is not a real theme by WordPress standards, and is instead used as the
     
    3838
    3939    /**
    40      * The main BuddyPress (Legacy) Loader
     40     * The main BuddyPress (Legacy) Loader.
    4141     *
    4242     * @since 1.7.0
     
    5050
    5151    /**
    52      * Component global variables
     52     * Component global variables.
    5353     *
    5454     * You'll want to customize the values in here, so they match whatever your
     
    6868
    6969    /**
    70      * Setup the theme hooks
     70     * Setup the theme hooks.
    7171     *
    7272     * @since 1.7.0
     
    7878    protected function setup_actions() {
    7979
    80         // Template Output
     80        // Template Output.
    8181        add_filter( 'bp_get_activity_action_pre_meta', array( $this, 'secondary_avatars' ), 10, 2 );
    8282
    83         // Filter BuddyPress template hierarchy and look for page templates
     83        // Filter BuddyPress template hierarchy and look for page templates.
    8484        add_filter( 'bp_get_buddypress_template', array( $this, 'theme_compat_page_templates' ), 10, 1 );
    8585
     
    8989        add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts'  ) ); // Enqueue theme JS
    9090        add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization
    91         add_action( 'bp_head',            array( $this, 'head_scripts'     ) ); // Output some extra JS in the <head>
     91        add_action( 'bp_head',            array( $this, 'head_scripts'     ) ); // Output some extra JS in the <head>.
    9292
    9393        /** Body no-js Class **************************************************/
     
    9999        if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    100100            // Register buttons for the relevant component templates
    101             // Friends button
     101            // Friends button.
    102102            if ( bp_is_active( 'friends' ) )
    103103                add_action( 'bp_member_header_actions',    'bp_add_friend_button',           5 );
    104104
    105             // Activity button
     105            // Activity button.
    106106            if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() )
    107107                add_action( 'bp_member_header_actions',    'bp_send_public_message_button',  20 );
    108108
    109             // Messages button
     109            // Messages button.
    110110            if ( bp_is_active( 'messages' ) )
    111111                add_action( 'bp_member_header_actions',    'bp_send_private_message_button', 20 );
    112112
    113             // Group buttons
     113            // Group buttons.
    114114            if ( bp_is_active( 'groups' ) ) {
    115115                add_action( 'bp_group_header_actions',          'bp_group_join_button',               5 );
     
    119119            }
    120120
    121             // Blog button
     121            // Blog button.
    122122            if ( bp_is_active( 'blogs' ) ) {
    123123                add_action( 'bp_directory_blogs_actions',    'bp_blogs_visit_blog_button'           );
     
    138138        $actions = array(
    139139
    140             // Directory filters
     140            // Directory filters.
    141141            'blogs_filter'    => 'bp_legacy_theme_object_template_loader',
    142142            'forums_filter'   => 'bp_legacy_theme_object_template_loader',
     
    147147            'requests_filter' => 'bp_legacy_theme_requests_template_loader',
    148148
    149             // Friends
     149            // Friends.
    150150            'accept_friendship' => 'bp_legacy_theme_ajax_accept_friendship',
    151151            'addremove_friend'  => 'bp_legacy_theme_ajax_addremove_friend',
    152152            'reject_friendship' => 'bp_legacy_theme_ajax_reject_friendship',
    153153
    154             // Activity
     154            // Activity.
    155155            'activity_get_older_updates'  => 'bp_legacy_theme_activity_template_loader',
    156156            'activity_mark_fav'           => 'bp_legacy_theme_mark_activity_favorite',
     
    165165            'bp_spam_activity_comment'    => 'bp_legacy_theme_spam_activity',
    166166
    167             // Groups
     167            // Groups.
    168168            'groups_invite_user' => 'bp_legacy_theme_ajax_invite_user',
    169169            'joinleave_group'    => 'bp_legacy_theme_ajax_joinleave_group',
    170170
    171             // Messages
     171            // Messages.
    172172            'messages_autocomplete_results' => 'bp_legacy_theme_ajax_messages_autocomplete_results',
    173173            'messages_close_notice'         => 'bp_legacy_theme_ajax_close_notice',
     
    178178        );
    179179
    180         // Conditional actions
     180        // Conditional actions.
    181181        if ( bp_is_active( 'messages', 'star' ) ) {
    182182            $actions['messages_star'] = 'bp_legacy_theme_ajax_messages_star_handler';
     
    184184
    185185        /**
    186          * Register all of these AJAX handlers
     186         * Register all of these AJAX handlers.
    187187         *
    188188         * The "wp_ajax_" action is used for logged in users, and "wp_ajax_nopriv_"
     
    219219        $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    220220
    221         // Locate the BP stylesheet
     221        // Locate the BP stylesheet.
    222222        $ltr = $this->locate_asset_in_stack( "buddypress{$min}.css",     'css' );
    223223
    224         // LTR
     224        // LTR.
    225225        if ( ! is_rtl() && isset( $ltr['location'], $ltr['handle'] ) ) {
    226226            wp_enqueue_style( $ltr['handle'], $ltr['location'], array(), $this->version, 'screen' );
     
    231231        }
    232232
    233         // RTL
     233        // RTL.
    234234        if ( is_rtl() ) {
    235235            $rtl = $this->locate_asset_in_stack( "buddypress-rtl{$min}.css", 'css' );
    236236
    237237            if ( isset( $rtl['location'], $rtl['handle'] ) ) {
    238                 $rtl['handle'] = str_replace( '-css', '-css-rtl', $rtl['handle'] );  // Backwards compatibility
     238                $rtl['handle'] = str_replace( '-css', '-css-rtl', $rtl['handle'] );  // Backwards compatibility.
    239239                wp_enqueue_style( $rtl['handle'], $rtl['location'], array(), $this->version, 'screen' );
    240240
     
    248248        $theme = $this->locate_asset_in_stack( get_template() . "{$min}.css", 'css' );
    249249        if ( ! is_rtl() && isset( $theme['location'] ) ) {
    250             // use a unique handle
     250            // Use a unique handle.
    251251            $theme['handle'] = 'bp-' . get_template();
    252252            wp_enqueue_style( $theme['handle'], $theme['location'], array(), $this->version, 'screen' );
     
    257257        }
    258258
    259         // Compatibility stylesheet for specific themes, RTL-version
     259        // Compatibility stylesheet for specific themes, RTL-version.
    260260        if ( is_rtl() ) {
    261261            $theme_rtl = $this->locate_asset_in_stack( get_template() . "-rtl{$min}.css", 'css' );
     
    280280        $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    281281
    282         // Locate the BP JS file
     282        // Locate the BP JS file.
    283283        $asset = $this->locate_asset_in_stack( "buddypress{$min}.js", 'js' );
    284284
    285285        // Enqueue the global JS, if found - AJAX will not work
    286         // without it
     286        // without it.
    287287        if ( isset( $asset['location'], $asset['handle'] ) ) {
    288288            wp_enqueue_script( $asset['handle'], $asset['location'], bp_core_get_js_dependencies(), $this->version );
     
    313313        wp_localize_script( $asset['handle'], 'BP_DTheme', $params );
    314314
    315         // Maybe enqueue comment reply JS
     315        // Maybe enqueue comment reply JS.
    316316        if ( is_singular() && bp_is_blog_page() && get_option( 'thread_comments' ) ) {
    317317            wp_enqueue_script( 'comment-reply' );
    318318        }
    319319
    320         // Maybe enqueue password verify JS (register page or user settings page)
     320        // Maybe enqueue password verify JS (register page or user settings page).
    321321        if ( bp_is_register_page() || ( function_exists( 'bp_is_user_settings_general' ) && bp_is_user_settings_general() ) ) {
    322322
    323             // Locate the Register Page JS file
     323            // Locate the Register Page JS file.
    324324            $asset = $this->locate_asset_in_stack( "password-verify{$min}.js", 'js', 'bp-legacy-password-verify' );
    325325
     
    328328            ) );
    329329
    330             // Enqueue script
     330            // Enqueue script.
    331331            wp_enqueue_script( $asset['handle'] . '-password-verify', $asset['location'], $dependencies, $this->version);
    332332        }
    333333
    334         // Star private messages
     334        // Star private messages.
    335335        if ( bp_is_active( 'messages', 'star' ) && bp_is_user_messages() ) {
    336336            wp_localize_script( $asset['handle'], 'BP_PM_Star', array(
     
    374374     * @since 1.8.0
    375375     * @access private
    376      * @param string $file A filename like buddypress.css
     376     * @param string $file A filename like buddypress.css.
    377377     * @param string $type Optional. Either "js" or "css" (the default).
    378378     * @param string $script_handle Optional. If set, used as the script name in `wp_enqueue_script`.
     
    389389        }
    390390
    391         // No need to check child if template == stylesheet
     391        // No need to check child if template == stylesheet.
    392392        if ( is_child_theme() ) {
    393393            $locations['bp-child'] = array(
     
    410410        );
    411411
    412         // Subdirectories within the top-level $locations directories
     412        // Subdirectories within the top-level $locations directories.
    413413        $subdirs = array(
    414414            'buddypress/' . $type,
     
    434434
    435435    /**
    436      * Put some scripts in the header, like AJAX url for wp-lists
     436     * Put some scripts in the header, like AJAX url for wp-lists.
    437437     *
    438438     * @since 1.7.0
     
    460460     *
    461461     * @since 1.7.0
     462     *
     463     * @param array $classes Array of classes to append to body tag.
     464     * @return array $classes
    462465     */
    463466    public function add_nojs_body_class( $classes ) {
     
    469472
    470473    /**
    471      * Load localizations for topic script
     474     * Load localizations for topic script.
    472475     *
    473476     * These localizations require information that may not be loaded even by init.
     
    486489     */
    487490    public function sitewide_notices() {
    488         // Do not show notices if user is not logged in
     491        // Do not show notices if user is not logged in.
    489492        if ( ! is_user_logged_in() )
    490493            return;
    491494
    492         // add a class to determine if the admin bar is on or not
     495        // Add a class to determine if the admin bar is on or not.
    493496        $class = did_action( 'admin_bar_menu' ) ? 'admin-bar-on' : 'admin-bar-off';
    494497
     
    503506     * @since 1.7.0
    504507     *
    505      * @param string $action The text of this activity
    506      * @param BP_Activity_Activity $activity Activity object
    507      * @package BuddyPress Theme
     508     * @param string               $action   The text of this activity.
     509     * @param BP_Activity_Activity $activity Activity object.
    508510     * @return string
    509511     */
     
    512514            case 'groups' :
    513515            case 'friends' :
    514                 // Only insert avatar if one exists
     516                // Only insert avatar if one exists.
    515517                if ( $secondary_avatar = bp_get_activity_secondary_avatar() ) {
    516518                    $reverse_content = strrev( $action );
     
    532534     * @since 2.2.0
    533535     *
    534      * @param  array $templates
     536     * @param  array $templates Array of templates.
    535537     * @uses   apply_filters() call 'bp_legacy_theme_compat_page_templates_directory_only' and return false
    536538     *                         to use the defined page template for component's directory and its single items
     
    550552        }
    551553
    552         // No page ID yet
     554        // No page ID yet.
    553555        $page_id = 0;
    554556
     
    573575        }
    574576
    575         // Bail if no directory page set
     577        // Bail if no directory page set.
    576578        if ( 0 === $page_id ) {
    577579            return $templates;
    578580        }
    579581
    580         // Check for page template
     582        // Check for page template.
    581583        $page_template = get_page_template_slug( $page_id );
    582584
     
    605607 * Add the Create a Group button to the Groups directory title.
    606608 *
    607  * bp-legacy puts the Create a Group button into the page title, to mimic
     609 * The bp-legacy puts the Create a Group button into the page title, to mimic
    608610 * the behavior of bp-default.
    609611 *
     
    621623 * Add the Create a Group nav to the Groups directory navigation.
    622624 *
    623  * bp-legacy puts the Create a Group nav at the last position of
     625 * The bp-legacy puts the Create a Group nav at the last position of
    624626 * the Groups directory navigation.
    625627 *
    626628 * @since 2.2.0
    627629 *
    628  * @uses   bp_group_create_nav_item() to output the create a Group nav item
    629  * @return string
     630 * @uses   bp_group_create_nav_item() to output the create a Group nav item.
    630631 */
    631632function bp_legacy_theme_group_create_nav() {
     
    636637 * Add the Create a Site button to the Sites directory title.
    637638 *
    638  * bp-legacy puts the Create a Site button into the page title, to mimic
     639 * The bp-legacy puts the Create a Site button into the page title, to mimic
    639640 * the behavior of bp-default.
    640641 *
     
    652653 * Add the Create a Site nav to the Sites directory navigation.
    653654 *
    654  * bp-legacy puts the Create a Site nav at the last position of
     655 * The bp-legacy puts the Create a Site nav at the last position of
    655656 * the Sites directory navigation.
    656657 *
     
    658659 *
    659660 * @uses   bp_blog_create_nav_item() to output the Create a Site nav item
    660  * @return string
    661661 */
    662662function bp_legacy_theme_blog_create_nav() {
     
    677677 * across page loads.
    678678 *
     679 * @param string $query_string Query string for the current request.
     680 * @param string $object       Object for cookie.
    679681 * @return string Query string for the component loops
    680682 * @since 1.2.0
     
    684686        return '';
    685687
    686     // Set up the cookies passed on this AJAX request. Store a local var to avoid conflicts
     688    // Set up the cookies passed on this AJAX request. Store a local var to avoid conflicts.
    687689    if ( ! empty( $_POST['cookie'] ) ) {
    688690        $_BP_COOKIE = wp_parse_args( str_replace( '; ', '&', urldecode( $_POST['cookie'] ) ) );
     
    698700     */
    699701
    700     // Activity stream filtering on action
     702    // Activity stream filtering on action.
    701703    if ( ! empty( $_BP_COOKIE['bp-' . $object . '-filter'] ) && '-1' != $_BP_COOKIE['bp-' . $object . '-filter'] ) {
    702704        $qs[] = 'type='   . $_BP_COOKIE['bp-' . $object . '-filter'];
     
    719721        $qs[] = 'page=' . absint( $_POST['page'] );
    720722
    721     // excludes activity just posted and avoids duplicate ids
     723    // Excludes activity just posted and avoids duplicate ids.
    722724    if ( ! empty( $_POST['exclude_just_posted'] ) ) {
    723725        $just_posted = wp_parse_id_list( $_POST['exclude_just_posted'] );
     
    725727    }
    726728
    727     // to get newest activities
     729    // To get newest activities.
    728730    if ( ! empty( $_POST['offset'] ) ) {
    729731        $qs[] = 'offset=' . intval( $_POST['offset'] );
     
    780782 */
    781783function bp_legacy_theme_object_template_loader() {
    782     // Bail if not a POST action
     784    // Bail if not a POST action.
    783785    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    784786        return;
    785787
    786     // Bail if no object passed
     788    // Bail if no object passed.
    787789    if ( empty( $_POST['object'] ) )
    788790        return;
    789791
    790     // Sanitize the object
     792    // Sanitize the object.
    791793    $object = sanitize_title( $_POST['object'] );
    792794
    793     // Bail if object is not an active component to prevent arbitrary file inclusion
     795    // Bail if object is not an active component to prevent arbitrary file inclusion.
    794796    if ( ! bp_is_active( $object ) )
    795797        return;
     
    806808    $template_part = $object . '/' . $object . '-loop';
    807809
    808     // The template part can be overridden by the calling JS function
     810    // The template part can be overridden by the calling JS function.
    809811    if ( ! empty( $_POST['template'] ) ) {
    810812        $template_part = sanitize_option( 'upload_path', $_POST['template'] );
    811813    }
    812814
    813     // Locate the object template
     815    // Locate the object template.
    814816    bp_get_template_part( $template_part );
    815817    exit();
     
    819821 * Load messages template loop when searched on the private message page
    820822 *
    821  * @return string Prints template loop for the Messages component
    822823 * @since 1.6.0
     824 *
     825 * @return string Prints template loop for the Messages component.
    823826 */
    824827function bp_legacy_theme_messages_template_loader() {
     
    848851
    849852/**
    850  * Load the activity loop template when activity is requested via AJAX,
     853 * Load the activity loop template when activity is requested via AJAX.
    851854 *
    852855 * @return string JSON object containing 'contents' (output of the template loop
     
    856859 */
    857860function bp_legacy_theme_activity_template_loader() {
    858     // Bail if not a POST action
     861    // Bail if not a POST action.
    859862    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    860863        return;
     
    864867        $scope = $_POST['scope'];
    865868
    866     // We need to calculate and return the feed URL for each scope
     869    // We need to calculate and return the feed URL for each scope.
    867870    switch ( $scope ) {
    868871        case 'friends':
     
    912915    $bp = buddypress();
    913916
    914     // Bail if not a POST action
     917    // Bail if not a POST action.
    915918    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    916919        return;
    917920
    918     // Check the nonce
     921    // Check the nonce.
    919922    check_admin_referer( 'post_update', '_wpnonce_post_update' );
    920923
     
    968971 * Posts new Activity comments received via a POST request.
    969972 *
     973 * @since 1.2.0
     974 *
    970975 * @global BP_Activity_Template $activities_template
     976 *
    971977 * @return string HTML
    972  * @since 1.2.0
    973978 */
    974979function bp_legacy_theme_new_activity_comment() {
     
    977982    $bp = buddypress();
    978983
    979     // Bail if not a POST action
     984    // Bail if not a POST action.
    980985    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
    981986        return;
    982987    }
    983988
    984     // Check the nonce
     989    // Check the nonce.
    985990    check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
    986991
     
    10141019    }
    10151020
    1016     // Load the new activity item into the $activities_template global
     1021    // Load the new activity item into the $activities_template global.
    10171022    bp_has_activities( 'display_comments=stream&hide_spam=false&show_hidden=true&include=' . $comment_id );
    10181023
    1019     // Swap the current comment with the activity item we just loaded
     1024    // Swap the current comment with the activity item we just loaded.
    10201025    if ( isset( $activities_template->activities[0] ) ) {
    10211026        $activities_template->activity = new stdClass();
     
    10241029
    10251030        // Because the whole tree has not been loaded, we manually
    1026         // determine depth
     1031        // determine depth.
    10271032        $depth = 1;
    10281033        $parent_id = (int) $activities_template->activities[0]->secondary_item_id;
     
    10351040    }
    10361041
    1037     // get activity comment template part
     1042    // Get activity comment template part.
    10381043    bp_get_template_part( 'activity/comment' );
    10391044
     
    10451050 * Deletes an Activity item received via a POST request.
    10461051 *
    1047  * @return mixed String on error, void on success
    10481052 * @since 1.2.0
     1053 *
     1054 * @return mixed String on error, void on success.
    10491055 */
    10501056function bp_legacy_theme_delete_activity() {
    1051     // Bail if not a POST action
     1057    // Bail if not a POST action.
    10521058    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    10531059        return;
    10541060
    1055     // Check the nonce
     1061    // Check the nonce.
    10561062    check_admin_referer( 'bp_activity_delete_link' );
    10571063
     
    10641070    $activity = new BP_Activity_Activity( (int) $_POST['id'] );
    10651071
    1066     // Check access
     1072    // Check access.
    10671073    if ( ! bp_activity_user_can_delete( $activity ) )
    10681074        exit( '-1' );
     
    10801086
    10811087/**
    1082  * Deletes an Activity comment received via a POST request
    1083  *
    1084  * @return mixed String on error, void on success
     1088 * Deletes an Activity comment received via a POST request.
     1089 *
    10851090 * @since 1.2.0
     1091 *
     1092 * @return mixed String on error, void on success.
    10861093 */
    10871094function bp_legacy_theme_delete_activity_comment() {
    1088     // Bail if not a POST action
     1095    // Bail if not a POST action.
    10891096    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    10901097        return;
    10911098
    1092     // Check the nonce
     1099    // Check the nonce.
    10931100    check_admin_referer( 'bp_activity_delete_link' );
    10941101
     
    10981105    $comment = new BP_Activity_Activity( $_POST['id'] );
    10991106
    1100     // Check access
     1107    // Check access.
    11011108    if ( ! bp_current_user_can( 'bp_moderate' ) && $comment->user_id != bp_loggedin_user_id() )
    11021109        exit( '-1' );
     
    11171124
    11181125/**
    1119  * AJAX spam an activity item or comment
    1120  *
    1121  * @return mixed String on error, void on success
     1126 * AJAX spam an activity item or comment.
     1127 *
    11221128 * @since 1.6.0
     1129 *
     1130 * @return mixed String on error, void on success.
    11231131 */
    11241132function bp_legacy_theme_spam_activity() {
    11251133    $bp = buddypress();
    11261134
    1127     // Bail if not a POST action
     1135    // Bail if not a POST action.
    11281136    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    11291137        return;
     
    11331141        exit( '-1' );
    11341142
    1135     // Check an item ID was passed
     1143    // Check an item ID was passed.
    11361144    if ( empty( $_POST['id'] ) || ! is_numeric( $_POST['id'] ) )
    11371145        exit( '-1' );
     
    11411149        exit( '-1' );
    11421150
    1143     // Load up the activity item
     1151    // Load up the activity item.
    11441152    $activity = new BP_Activity_Activity( (int) $_POST['id'] );
    11451153    if ( empty( $activity->component ) )
    11461154        exit( '-1' );
    11471155
    1148     // Check nonce
     1156    // Check nonce.
    11491157    check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
    11501158
     
    11521160    do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
    11531161
    1154     // Mark as spam
     1162    // Mark as spam.
    11551163    bp_activity_mark_as_spam( $activity );
    11561164    $activity->save();
     
    11641172 * Mark an activity as a favourite via a POST request.
    11651173 *
     1174 * @since 1.2.0
     1175 *
    11661176 * @return string HTML
    1167  * @since 1.2.0
    11681177 */
    11691178function bp_legacy_theme_mark_activity_favorite() {
    1170     // Bail if not a POST action
     1179    // Bail if not a POST action.
    11711180    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    11721181        return;
     
    11831192 * Un-favourite an activity via a POST request.
    11841193 *
     1194 * @since 1.2.0
     1195 *
    11851196 * @return string HTML
    1186  * @since 1.2.0
    11871197 */
    11881198function bp_legacy_theme_unmark_activity_favorite() {
    1189     // Bail if not a POST action
     1199    // Bail if not a POST action.
    11901200    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    11911201        return;
     
    12031213 * Used for the 'Read More' link on long activity items.
    12041214 *
     1215 * @since 1.5.0
     1216 *
    12051217 * @return string HTML
    1206  * @since 1.5.0
    12071218 */
    12081219function bp_legacy_theme_get_single_activity_content() {
    1209     // Bail if not a POST action
     1220    // Bail if not a POST action.
    12101221    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    12111222        return;
     
    12301241    do_action_ref_array( 'bp_legacy_theme_get_single_activity_content', array( &$activity ) );
    12311242
    1232     // Activity content retrieved through AJAX should run through normal filters, but not be truncated
     1243    // Activity content retrieved through AJAX should run through normal filters, but not be truncated.
    12331244    remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
    12341245
     
    12431254 *
    12441255 * @since 1.2.0
     1256 *
    12451257 * @todo Audit return types
    12461258 */
    12471259function bp_legacy_theme_ajax_invite_user() {
    1248     // Bail if not a POST action
     1260    // Bail if not a POST action.
    12491261    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    12501262        return;
     
    12681280
    12691281        // Users who have previously requested membership do not need
    1270         // another invitation created for them
     1282        // another invitation created for them.
    12711283        if ( BP_Groups_Member::check_for_membership_request( $friend_id, $group_id ) ) {
    12721284            $user_status = 'is_pending';
    12731285
    1274         // Create the user invitation
     1286        // Create the user invitation.
    12751287        } elseif ( groups_invite_user( array( 'user_id' => $friend_id, 'group_id' => $group_id ) ) ) {
    12761288            $user_status = 'is_invited';
    12771289
    1278         // Miscellaneous failure
     1290        // Miscellaneous failure.
    12791291        } else {
    12801292            return;
     
    13041316    } elseif ( 'uninvite' == $_POST['friend_action'] ) {
    13051317        // Users who have previously requested membership should not
    1306         // have their requests deleted on the "uninvite" action
     1318        // have their requests deleted on the "uninvite" action.
    13071319        if ( BP_Groups_Member::check_for_membership_request( $friend_id, $group_id ) ) {
    13081320            return;
    13091321        }
    13101322
    1311         // Remove the unsent invitation
     1323        // Remove the unsent invitation.
    13121324        if ( ! groups_uninvite_user( $friend_id, $group_id ) ) {
    13131325            return;
     
    13241336 * Friend/un-friend a user via a POST request.
    13251337 *
     1338 * @since 1.2.0
     1339 *
    13261340 * @return string HTML
    1327  * @since 1.2.0
    13281341 */
    13291342function bp_legacy_theme_ajax_addremove_friend() {
    13301343
    1331     // Bail if not a POST action
     1344    // Bail if not a POST action.
    13321345    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    13331346        return;
    13341347
    1335     // Cast fid as an integer
     1348    // Cast fid as an integer.
    13361349    $friend_id = (int) $_POST['fid'];
    13371350
    1338     // Trying to cancel friendship
     1351    // Trying to cancel friendship.
    13391352    if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $friend_id ) ) {
    13401353        check_ajax_referer( 'friends_remove_friend' );
     
    13461359        }
    13471360
    1348     // Trying to request friendship
     1361    // Trying to request friendship.
    13491362    } elseif ( 'not_friends' == BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $friend_id ) ) {
    13501363        check_ajax_referer( 'friends_add_friend' );
     
    13561369        }
    13571370
    1358     // Trying to cancel pending request
     1371    // Trying to cancel pending request.
    13591372    } elseif ( 'pending' == BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $friend_id ) ) {
    13601373        check_ajax_referer( 'friends_withdraw_friendship' );
     
    13661379        }
    13671380
    1368     // Request already pending
     1381    // Request already pending.
    13691382    } else {
    13701383        echo __( 'Request Pending', 'buddypress' );
     
    13771390 * Accept a user friendship request via a POST request.
    13781391 *
    1379  * @return mixed String on error, void on success
    13801392 * @since 1.2.0
     1393 *
     1394 * @return mixed String on error, void on success.
    13811395 */
    13821396function bp_legacy_theme_ajax_accept_friendship() {
    1383     // Bail if not a POST action
     1397    // Bail if not a POST action.
    13841398    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    13851399        return;
     
    13961410 * Reject a user friendship request via a POST request.
    13971411 *
    1398  * @return mixed String on error, void on success
    13991412 * @since 1.2.0
     1413 *
     1414 * @return mixed String on error, void on success.
    14001415 */
    14011416function bp_legacy_theme_ajax_reject_friendship() {
    1402     // Bail if not a POST action
     1417    // Bail if not a POST action.
    14031418    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    14041419        return;
     
    14151430 * Join or leave a group when clicking the "join/leave" button via a POST request.
    14161431 *
     1432 * @since 1.2.0
     1433 *
    14171434 * @return string HTML
    1418  * @since 1.2.0
    14191435 */
    14201436function bp_legacy_theme_ajax_joinleave_group() {
    1421     // Bail if not a POST action
     1437    // Bail if not a POST action.
    14221438    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    14231439        return;
    14241440
    1425     // Cast gid as integer
     1441    // Cast gid as integer.
    14261442    $group_id = (int) $_POST['gid'];
    14271443
     
    14451461
    14461462            // If the user has already been invited, then this is
    1447             // an Accept Invitation button
     1463            // an Accept Invitation button.
    14481464            if ( groups_check_user_has_invite( bp_loggedin_user_id(), $group->id ) ) {
    14491465                check_ajax_referer( 'groups_accept_invite' );
     
    14551471                }
    14561472
    1457             // Otherwise, it's a Request Membership button
     1473            // Otherwise, it's a Request Membership button.
    14581474            } else {
    14591475                check_ajax_referer( 'groups_request_membership' );
     
    14851501 * Close and keep closed site wide notices from an admin in the sidebar, via a POST request.
    14861502 *
    1487  * @return mixed String on error, void on success
    14881503 * @since 1.2.0
     1504 *
     1505 * @return mixed String on error, void on success.
    14891506 */
    14901507function bp_legacy_theme_ajax_close_notice() {
    1491     // Bail if not a POST action
     1508    // Bail if not a POST action.
    14921509    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    14931510        return;
     
    15101527 * Send a private message reply to a thread via a POST request.
    15111528 *
     1529 * @since 1.2.0
     1530 *
    15121531 * @return string HTML
    1513  * @since 1.2.0
    15141532 */
    15151533function bp_legacy_theme_ajax_messages_send_reply() {
    1516     // Bail if not a POST action
     1534    // Bail if not a POST action.
    15171535    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    15181536        return;
     
    15241542    if ( !empty( $result ) ) {
    15251543
    1526         // pretend we're in the message loop
     1544        // Pretend we're in the message loop.
    15271545        global $thread_template;
    15281546
    15291547        bp_thread_has_messages( array( 'thread_id' => (int) $_REQUEST['thread_id'] ) );
    15301548
    1531         // set the current message to the 2nd last
     1549        // Set the current message to the 2nd last.
    15321550        $thread_template->message = end( $thread_template->thread->messages );
    15331551        $thread_template->message = prev( $thread_template->thread->messages );
    15341552
    1535         // set current message to current key
     1553        // Set current message to current key.
    15361554        $thread_template->current_message = key( $thread_template->thread->messages );
    15371555
    1538         // now manually iterate message like we're in the loop
     1556        // Now manually iterate message like we're in the loop.
    15391557        bp_thread_the_message();
    15401558
    1541         // manually call oEmbed
    1542         // this is needed because we're not at the beginning of the loop
     1559        // Manually call oEmbed
     1560        // this is needed because we're not at the beginning of the loop.
    15431561        bp_messages_embed();
    15441562
    1545         // add new-message css class
     1563        // Add new-message css class.
    15461564        add_filter( 'bp_get_the_thread_message_css_class', create_function( '$retval', '
    15471565            $retval[] = "new-message";
     
    15491567        ' ) );
    15501568
    1551         // output single message template part
     1569        // Output single message template part.
    15521570        bp_get_template_part( 'members/single/messages/message' );
    15531571
    1554         // clean up the loop
     1572        // Clean up the loop.
    15551573        bp_thread_messages();
    15561574
     
    15651583 * Mark a private message as unread in your inbox via a POST request.
    15661584 *
    1567  * @return mixed String on error, void on success
    15681585 * @since 1.2.0
     1586 *
     1587 * @return mixed String on error, void on success.
    15691588 */
    15701589function bp_legacy_theme_ajax_message_markunread() {
    1571     // Bail if not a POST action
     1590    // Bail if not a POST action.
    15721591    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    15731592        return;
     
    15901609 * Mark a private message as read in your inbox via a POST request.
    15911610 *
    1592  * @return mixed String on error, void on success
    15931611 * @since 1.2.0
     1612 *
     1613 * @return mixed String on error, void on success.
    15941614 */
    15951615function bp_legacy_theme_ajax_message_markread() {
    1596     // Bail if not a POST action
     1616    // Bail if not a POST action.
    15971617    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    15981618        return;
     
    16151635 * Delete a private message(s) in your inbox via a POST request.
    16161636 *
     1637 * @since 1.2.0
     1638 *
    16171639 * @return string HTML
    1618  * @since 1.2.0
    16191640 */
    16201641function bp_legacy_theme_ajax_messages_delete() {
    1621     // Bail if not a POST action
     1642    // Bail if not a POST action.
    16221643    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    16231644        return;
     
    16421663 *
    16431664 * @since 1.2.0
    1644  *
    1645  * @return string HTML.
    16461665 */
    16471666function bp_legacy_theme_ajax_messages_autocomplete_results() {
     
    16751694
    16761695            // Note that the final line break acts as a delimiter for the
    1677             // autocomplete JavaScript and thus should not be removed
     1696            // autocomplete JavaScript and thus should not be removed.
    16781697            printf( '<span id="%s" href="#"></span><img src="%s" style="width: 15px"> &nbsp; %s (%s)' . "\n",
    16791698                esc_attr( 'link-' . $user->ID ),
     
    16981717    }
    16991718
    1700     // Check nonce
     1719    // Check nonce.
    17011720    check_ajax_referer( 'bp-messages-star-' . (int) $_POST['message_id'], 'nonce' );
    17021721
    1703     // Check capability
     1722    // Check capability.
    17041723    if ( ! is_user_logged_in() || ! bp_core_can_edit_settings() ) {
    17051724        return;
     
    17201739
    17211740/**
    1722  * BP Legacy's callback for the cover image feature
     1741 * BP Legacy's callback for the cover image feature.
    17231742 *
    17241743 * @since  2.4.0
    17251744 *
    1726  * @param  array  $params the current component's feature parameters
     1745 * @param  array $params the current component's feature parameters.
    17271746 * @return array          an array to inform about the css handle to attach the css rules to
    17281747 */
     
    17321751    }
    17331752
    1734     // avatar height - padding - 1/2 avatar height
     1753    // Avatar height - padding - 1/2 avatar height.
    17351754    $avatar_offset = $params['height'] - 5 - round( (int) bp_core_avatar_full_height() / 2 );
    17361755
    1737     // header content offset + spacing
     1756    // Header content offset + spacing.
    17381757    $top_offset  = bp_core_avatar_full_height() - 10;
    17391758    $left_offset = bp_core_avatar_full_width() + 20;
     
    17431762    $hide_avatar_style = '';
    17441763
    1745     // Adjust the cover image header, in case avatars are completely disabled
     1764    // Adjust the cover image header, in case avatars are completely disabled.
    17461765    if ( ! buddypress()->avatar->show_avatars ) {
    17471766        $hide_avatar_style = '
Note: See TracChangeset for help on using the changeset viewer.