-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aa6207b
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] ); | ||
|
||
} | ||
} | ||
|
||
|
||
}); | ||
|