Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/02/2015 08:55:07 PM (11 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.php

    r9819 r9831  
    220220                add_filter( "{$this->action}_prefilter", array( $this, 'validate_upload' ), 10, 1 );
    221221
     222                /**
     223                 * The above dynamic filter was introduced in WordPress 4.0, as we support WordPress
     224                 * back to 3.6, we need to also use the pre 4.0 static filter and remove it after
     225                 * the upload was processed.
     226                 */
     227                add_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 );
     228
    222229                // Set Default overrides
    223230                $overrides = array(
     
    265272                // Restore WordPress Uploads data
    266273                remove_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
     274
     275                // Remove the pre WordPress 4.0 static filter
     276                remove_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 );
    267277
    268278                // Finally return the uploaded file or the error
Note: See TracChangeset for help on using the changeset viewer.