Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/02/2024 07:14:55 PM (20 months ago)
Author:
espellcaste
Message:

WPCS: Part IX: miscellaneous fixes for some of the files of the core component.

Follow-up to [13883], [13886], [13887], [13888], [13891], [13892], [13893] and [13900]

See #9164 and #7228

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-attachment-avatar.php

    r13414 r13901  
    3232        $allowed_types = bp_core_get_allowed_avatar_types();
    3333
    34         parent::__construct( array(
    35             'action'                => 'bp_avatar_upload',
    36             'file_input'            => 'file',
    37             'original_max_filesize' => bp_core_avatar_original_max_filesize(),
    38 
    39             // Specific errors for avatars.
    40             'upload_error_strings'  => array(
    41                 /* translators: %s: Max file size for the profile photo */
    42                 9  => sprintf( _x( 'That photo is too big. Please upload one smaller than %s', 'profile photo upload error', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ),
    43 
    44                 /* translators: %s: comma separated list of file types allowed for the profile photo */
    45                 10 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'profile photo upload error', 'buddypress' ), self::get_avatar_types( $allowed_types ) ),
    46             ),
    47         ) );
     34        parent::__construct(
     35            array(
     36                'action'                => 'bp_avatar_upload',
     37                'file_input'            => 'file',
     38                'original_max_filesize' => bp_core_avatar_original_max_filesize(),
     39
     40                // Specific errors for avatars.
     41                'upload_error_strings'  => array(
     42                    /* translators: %s: Max file size for the profile photo */
     43                    9  => sprintf( _x( 'That photo is too big. Please upload one smaller than %s', 'profile photo upload error', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ),
     44
     45                    /* translators: %s: comma separated list of file types allowed for the profile photo */
     46                    10 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'profile photo upload error', 'buddypress' ), self::get_avatar_types( $allowed_types ) ),
     47                ),
     48            )
     49        );
    4850    }
    4951
     
    98100            $file['error'] = 9;
    99101
    100         // File is of invalid type.
     102            // File is of invalid type.
    101103        } elseif ( ! bp_core_check_avatar_type( array( 'file' => $file ) ) ) {
    102104            $file['error'] = 10;
     
    153155            3 => 180,
    154156            6 => -90,
    155             8 =>  90,
     157            8 => 90,
    156158        );
    157159
     
    163165        if ( empty( $edit_args ) ) {
    164166            return false;
     167        }
    165168
    166169        // Add the file to the edit arguments.
    167         } else {
    168             $edit_args['file'] = $file;
    169         }
     170        $edit_args['file'] = $file;
    170171
    171172        return parent::edit_image( 'avatar', $edit_args );
     
    176177     *
    177178     * @since 2.3.0
    178      *
    179179     *
    180180     * @param string $file the absolute path to the file.
     
    186186        $full_height    = bp_core_avatar_full_height();
    187187
    188         if ( isset( $uploaded_image[0] ) && $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) {
    189             return true;
    190         }
    191 
    192         return false;
     188        return ( isset( $uploaded_image[0] ) && ( $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) );
    193189    }
    194190
     
    198194     * @since 2.3.0
    199195     *
    200      * @see  BP_Attachment::crop for the list of parameters
     196     * @see BP_Attachment::crop() for the list of parameters
    201197     *
    202198     * @param array $args Array of arguments for the cropping.
     
    229225
    230226        // Bail if the avatar is not available.
    231         if ( ! file_exists( $absolute_path ) )  {
     227        if ( ! file_exists( $absolute_path ) ) {
    232228            return false;
    233229        }
     
    281277                        }
    282278
    283                         $is_full  = preg_match( "/-bpfull/", $avatar_file->name );
    284                         $is_thumb = preg_match( "/-bpthumb/", $avatar_file->name );
     279                        $is_full  = preg_match( '/-bpfull/', $avatar_file->name );
     280                        $is_thumb = preg_match( '/-bpthumb/', $avatar_file->name );
    285281
    286282                        if ( $is_full || $is_thumb ) {
     
    322318            'thumb' => '',
    323319        );
    324         $timestamp   = bp_core_current_time( true, 'timestamp' );
     320        $timestamp    = bp_core_current_time( true, 'timestamp' );
    325321
    326322        foreach ( $avatar_types as $key_type => $type ) {
     
    359355     */
    360356    private function get_user_id() {
    361         $bp = buddypress();
     357        $bp      = buddypress();
    362358        $user_id = 0;
    363359
     
    424420                'item_id'    => $user_id,
    425421                'has_avatar' => bp_get_user_has_avatar( $user_id ),
    426                 'nonces'  => array(
     422                'nonces'     => array(
    427423                    'set'    => wp_create_nonce( 'bp_avatar_cropstore' ),
    428424                    'remove' => wp_create_nonce( 'bp_delete_avatar_link' ),
     
    476472
    477473        // Include the specific css.
    478         $script_data['extra_js']  = $js_scripts;
     474        $script_data['extra_js'] = $js_scripts;
    479475
    480476        // Set the object to contextualize the filter.
Note: See TracChangeset for help on using the changeset viewer.