Permalink
Browse files

Filter "upload_dir"

  • Loading branch information...
1 parent c142220 commit 3071f2fead8bc30c3d1cc2930a849025d0649959 @markjaquith committed Jul 13, 2012
Showing with 24 additions and 2 deletions.
  1. +24 −2 WordPress-Dropins/wp-stack-ms-uploads.php
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: WP Stack Multisite Uploads
-Version: 0.2
+Version: 0.3
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@@ -21,10 +21,32 @@ public function __construct() {
public function init() {
global $blog_id;
- if ( $blog_id != 1 )
+ if ( $blog_id != 1 ) {
$this->hook( 'option_fileupload_url' );
+ $this->hook( 'upload_dir' );
+ }
}
+ public function upload_dir( $upload ) {
+ /*
+ array(
+ 'subdir' => '/2012/07',
+ 'basedir' => '/Users/mark/Sites/wp.git/wp-content/uploads',
+ 'path' => '/Users/mark/Sites/wp.git/wp-content/uploads/2012/07',
+ 'baseurl' => 'http://wp.git/wp-files/1',
+ 'url' => 'http://wp.git/wp-content/uploads/2012/07',
+ 'error' => false
+ )
+ */
+ global $blog_id;
+ $parsed = parse_url( $upload['baseurl'] );
+ $upload['baseurl'] = $parsed['scheme'] . '://' . $parsed['host'] . '/wp-files/' . $blog_id;
+ $upload['url'] = $upload['baseurl'] . $upload['subdir'];
+ var_export( $upload ); die();
+ return $upload;
+ }
+
+ // Does core even use this anymore?
public function option_fileupload_url( $url ) {
global $blog_id;
$parsed = parse_url( $url );

0 comments on commit 3071f2f

Please sign in to comment.