Skip to content

Commit

Permalink
Add an early return filter for get_upload_dir()
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwiebe committed Nov 21, 2024
1 parent 12883a5 commit b2fbe46
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1478,12 +1478,22 @@ function get_attribution_domains() {
* @return string The upload base URL.
*/
function get_upload_baseurl() {
$upload_dir = \wp_get_upload_dir();
/**
* Early filter to allow plugins to set the upload base URL.
*
* @param string|false $maybe_upload_dir The upload base URL or false if not set.
*/
$maybe_upload_dir = apply_filters( 'pre_activitypub_get_upload_baseurl', false );
if ( false !== $maybe_upload_dir ) {
return $maybe_upload_dir;
}

$upload_dir = \wp_upload_dir();

/**
* Filters the upload base URL.
*
* @param string \wp_get_upload_dir()['baseurl'] The upload base URL.
* @param string \wp_upload_dir()['baseurl'] The upload base URL.
*/
return apply_filters( 'activitypub_get_upload_baseurl', $upload_dir['baseurl'] );
}

0 comments on commit b2fbe46

Please sign in to comment.