Skip to content

Instantly share code, notes, and snippets.

@jmdodd
Created October 27, 2011 11:18
Show Gist options
  • Save jmdodd/1319302 to your computer and use it in GitHub Desktop.
Save jmdodd/1319302 to your computer and use it in GitHub Desktop.
Unmask file locations in a WordPress Multisite installation (for WP 3.1+)
<?php
if ( ! function_exists( 'ucc_upload_dir_wp31' ) ) {
function ucc_upload_dir_wp31( $uploads ) {
// Set these options in Network Admin > Sites > Edit > Settings > Upload Path and Upload Url Path.
$upload_path = get_option( 'upload_path' ); // Example: /home/username/public_html/wp-content/blogs.dir/2/files
$upload_url_path = get_option( 'upload_url_path' ); // Example: http://sub.domain.com/wp-content/blogs.dir/2/files
$uploads['baseurl'] = $upload_url_path;
$uploads['url'] = $upload_url_path . $uploads[ 'subdir' ];
$uploads['basedir'] = $upload_path;
$uploads['path'] = $upload_path . $uploads[ 'subdir' ];
return $uploads;
} }
add_filter( 'upload_dir', 'ucc_upload_dir_wp31' );
/*
Copyright 2011 Jennifer M. Dodd (email: jmdodd@gmail.com)
Released under the GPLv2 (or later).
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment