Skip to:
Content

BuddyPress.org

Ticket #5999: 5999.patch

File 5999.patch, 1.9 KB (added by imath, 11 years ago)
  • src/bp-core/bp-core-avatars.php

    diff --git src/bp-core/bp-core-avatars.php src/bp-core/bp-core-avatars.php
    index 65c516e..9f947d1 100644
    function bp_core_avatar_default_thumb( $type = 'gravatar' ) { 
    11961196
    11971197        return apply_filters( 'bp_core_avatar_thumb', $avatar );
    11981198}
     1199
     1200/**
     1201 * Is the user changing an avatar (profile or group) ?
     1202 *
     1203 * @since  BuddyPress (2.2.0)
     1204 *
     1205 * @uses   bp_is_group_create()
     1206 * @uses   bp_is_group_admin_page()
     1207 * @uses   bp_is_group_admin_screen() to check for a group admin screen
     1208 * @uses   bp_action_variable() to check for the group's avatar creation step
     1209 * @uses   bp_is_user_change_avatar() to check for the user's change profile screen
     1210 * @return bool true if on a "change avatar" screen, false otherwise
     1211 */
     1212function bp_core_avatar_is_crop_step() {
     1213        $retval = false;
     1214
     1215        /**
     1216         * Use core template functions checks before specific to the groups component ones.
     1217         */
     1218        if ( bp_is_group_admin_page() ) {
     1219                $retval = (bool) bp_is_group_admin_screen( 'group-avatar' );
     1220        } else if ( bp_is_group_create() ) {
     1221                // we can't use bp_get_groups_current_create_step() as it's not set yet
     1222                $retval = (bool) 'group-avatar' == bp_action_variable( 1 );
     1223        } else {
     1224                $retval = bp_is_user_change_avatar();
     1225        }
     1226
     1227        return $retval;
     1228}
     1229
     1230/**
     1231 * Reset the week argument of the main query if needed
     1232 *
     1233 * When cropping an avatar, a $_POST['w'] var is sent, setting
     1234 * the 'week' paramater of WordPress main query to this posted var.
     1235 * To avoid notices we need to make sure this query var is reset to 0
     1236 *
     1237 * @since  BuddyPress (2.2.0)
     1238 *
     1239 * @param  WP_Quert $posts_query the main query object
     1240 */
     1241function bp_core_avatar_reset_query( $posts_query = null ) {
     1242        if ( bp_core_avatar_is_crop_step() && isset( $_POST['avatar-crop-submit'] ) ) {
     1243                $posts_query->set( 'w', 0 );
     1244        }
     1245}
     1246add_action( 'bp_parse_query', 'bp_core_avatar_reset_query', 10, 1 );