Skip to content

Commit

Permalink
files
Browse files Browse the repository at this point in the history
  • Loading branch information
miriamgoldman committed Oct 17, 2024
0 parents commit aa6207b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# WP Offload Media Overrides

The following plugin has been developed to allow WP Offload Media to work on Pantheon environments that have less resources available to them.

## Install

Download release, and upload to the /plugins/ folder, and activate via normal methods.
36 changes: 36 additions & 0 deletions wp-offload-media-overrides.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Plugin Name: WP Offload Media Overrides.
* Description: Overrides the wp_unique_filename filter in WP Offload Media.
* Version: 1.0
* Author: Pantheon
*/

add_action( 'init', function() {

if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) && 'live' != $_ENV['PANTHEON_ENVIRONMENT'] ) {
global $wp_filter;

if ( class_exists( 'DeliciousBrains\WP_Offload_Media\Integrations\Media_Library' ) ) {
global $as3cf;

// Access the media library integration instance
$media_library_integration = new DeliciousBrains\WP_Offload_Media\Integrations\Media_Library( $as3cf );

// Remove the wp_unique_filename filter
remove_filter( 'wp_unique_filename', [ $media_library_integration, 'wp_unique_filename' ], 10 );


}

// Check if wp_unique_filename filter exists and if there's a callback at priority 10
if ( isset( $wp_filter['wp_unique_filename']->callbacks[10] ) ) {
// Clear all filters at priority 10
unset( $wp_filter['wp_unique_filename']->callbacks[10] );

}
}


});

0 comments on commit aa6207b

Please sign in to comment.