Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/02/2015 08:55:07 PM (10 years ago)
Author:
imath
Message:

Make sure the BP Attachments API behaves the right way when WordPress < 4.0

Before WordPress 4.0, there was no dynamic filter based on the name of the action posted in the upload form. So we also need to filter wp_handle_upload_prefilter to make sure the BP_Attachments->validate_upload() function will actually validate the uploads for versions of WordPress < 4.0.

Improve the i18n of the avatar type error, as the avatar types can now be filtered in the BP_Attachment_Avatar class.

Add unit tests for the BP Attachement class.

Fixes #6278

File:
1 edited

Legend:

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

    r9819 r9831  
    2929     */
    3030    public function __construct() {
     31        // Allowed avatar types
     32        $allowed_types = bp_core_get_allowed_avatar_types();
     33
    3134        parent::__construct( array(
    3235            'action'                => 'bp_avatar_upload',
     
    3740            'upload_error_strings'  => array(
    3841                9  => sprintf( __( 'That photo is too big. Please upload one smaller than %s', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ),
    39                 10 => __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ),
     42                10 => sprintf( _n( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'buddypress' ), self::get_avatar_types( $allowed_types ) ),
    4043            ),
    4144        ) );
     45    }
     46
     47    /**
     48     * Gets the available avatar types
     49     *
     50     * @since BuddyPress (2.3.0)
     51     * @return string comma separated list of allowed avatar types
     52     */
     53    public static function get_avatar_types( $allowed_types = array() ) {
     54        $types = array_map( 'strtoupper', $allowed_types );
     55        $comma = _x( ',', 'avatar types separator', 'buddypress' );
     56        return join( $comma . ' ', $types );
    4257    }
    4358
Note: See TracChangeset for help on using the changeset viewer.