Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/02/2024 07:14:55 PM (2 years 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-cover-image.php

    r13414 r13901  
    3030                $max_upload_file_size = bp_attachments_get_max_upload_file_size( 'cover_image' );
    3131
    32                 parent::__construct( array(
    33                         'action'                => 'bp_cover_image_upload',
    34                         'file_input'            => 'file',
    35                         'original_max_filesize' => $max_upload_file_size,
    36                         'base_dir'              => bp_attachments_uploads_dir_get( 'dir' ),
    37                         'required_wp_files'     => array( 'file', 'image' ),
    38 
    39                         // Specific errors for cover images.
    40                         'upload_error_strings'  => array(
    41                                 /* translators: %s: Max file size for the cover image */
    42                                 11  => sprintf( _x( 'That image is too big. Please upload one smaller than %s', 'cover image upload error', 'buddypress' ), size_format( $max_upload_file_size ) ),
    43 
    44                                 /* translators: %s: comma separated list of file types allowed for the cover image */
    45                                 12  => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'cover image upload error', 'buddypress' ), self::get_cover_image_types( $allowed_types ) ),
    46                         ),
    47                 ) );
     32                parent::__construct(
     33                        array(
     34                                'action'                => 'bp_cover_image_upload',
     35                                'file_input'            => 'file',
     36                                'original_max_filesize' => $max_upload_file_size,
     37                                'base_dir'              => bp_attachments_uploads_dir_get( 'dir' ),
     38                                'required_wp_files'     => array( 'file', 'image' ),
     39
     40                                // Specific errors for cover images.
     41                                'upload_error_strings'  => array(
     42                                        /* translators: %s: Max file size for the cover image */
     43                                        11 => sprintf( _x( 'That image is too big. Please upload one smaller than %s', 'cover image upload error', 'buddypress' ), size_format( $max_upload_file_size ) ),
     44
     45                                        /* translators: %s: comma separated list of file types allowed for the cover image */
     46                                        12 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'cover image upload error', 'buddypress' ), self::get_cover_image_types( $allowed_types ) ),
     47                                ),
     48                        )
     49                );
    4850        }
    4951
    … …  
    8385                        $file['error'] = 11;
    8486
    85                 // File is of invalid type.
     87                        // File is of invalid type.
    8688                } elseif ( isset( $file['tmp_name'] ) && isset( $file['name'] ) && ! bp_attachments_check_filetype( $file['tmp_name'], $file['name'], bp_attachments_get_allowed_mimes( 'cover_image' ) ) ) {
    8789                        $file['error'] = 12;
    … …  
    138140                        3 => 180,
    139141                        6 => -90,
    140                         8 =>  90,
     142                        8 => 90,
    141143                );
    142144
    … …  
    149151                        return false;
    150152
    151                 // Add the file to the edit arguments.
     153                        // Add the file to the edit arguments.
    152154                } else {
    153                         $edit_args = array_merge( $edit_args, array( 'file' => $file, 'save' => false ) );
     155                        $edit_args = array_merge(
     156                                $edit_args,
     157                                array(
     158                                        'file' => $file,
     159                                        'save' => false,
     160                                )
     161                        );
    154162                }
    155163
    … …  
    157165                $editor = parent::edit_image( 'cover_image', $edit_args );
    158166
    159                 if ( is_wp_error( $editor ) )  {
     167                if ( is_wp_error( $editor ) ) {
    160168                        return $editor;
    161169                } elseif ( ! is_a( $editor, 'WP_Image_Editor' ) ) {
    … …  
    173181         *
    174182         * @param string $file The absolute path to the file.
    175          * @return false|string $value The absolute path to the new file name.
     183         * @return false|string
    176184         */
    177185        public function generate_filename( $file = '' ) {
    … …  
    208216                                'item_id'         => $item_id,
    209217                                'has_cover_image' => bp_attachments_get_user_has_cover_image( $item_id ),
    210                                 'nonces'  => array(
     218                                'nonces'          => array(
    211219                                        'remove' => wp_create_nonce( 'bp_delete_cover_image' ),
    212220                                ),
    … …  
    226234                                'item_id'         => bp_get_current_group_id(),
    227235                                'has_cover_image' => bp_attachments_get_group_has_cover_image( $item_id ),
    228                                 'nonces'  => array(
     236                                'nonces'          => array(
    229237                                        'remove' => wp_create_nonce( 'bp_delete_cover_image' ),
    230238                                ),
Note: See TracChangeset for help on using the changeset viewer.