Skip to content

Instantly share code, notes, and snippets.

@MaximeCulea
Created May 20, 2019 12:18
Show Gist options
  • Save MaximeCulea/7243ed7781d262fa0115a38fd2126bdd to your computer and use it in GitHub Desktop.
Save MaximeCulea/7243ed7781d262fa0115a38fd2126bdd to your computer and use it in GitHub Desktop.
Rewrite to have only one folder for all files
<?php
/**
* For all files into one site folder.
*/
//add_filter( 'upload_dir', 'move_uploads' );
function move_uploads( $cache_key ) {
$blog_id = get_current_blog_id();
if ( 6 === $blog_id ) {
return $cache_key;
}
$cache_key['path'] = WP_CONTENT_DIR . '/uploads/sites/6' . $cache_key['subdir'];
$cache_key['url'] = WP_CONTENT_URL . '/uploads/sites/6' . $cache_key['subdir'];
$cache_key['basedir'] = WP_CONTENT_DIR . '/uploads/sites/6';
$cache_key['baseurl'] = WP_CONTENT_URL . '/uploads/sites/6';
return $cache_key;
}
/**
* Remove site rewriting, means all files into upload one.
*/
//add_filter( 'pre_site_option_' . 'ms_files_rewriting', '__return_true' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment