Skip to content

Instantly share code, notes, and snippets.

@edubacco
Last active September 4, 2018 15:43
Show Gist options
  • Save edubacco/36b83ce7fb507f736f8bcf8fd2d4ef54 to your computer and use it in GitHub Desktop.
Save edubacco/36b83ce7fb507f736f8bcf8fd2d4ef54 to your computer and use it in GitHub Desktop.
<?php
/*
* This file is just an example for a woocommerce issue
*/
add_action( 'plugins_loaded', 'maybe_custom_upload_dir' );
/**
* under some circumstances, we need to move the upload dir
*/
function maybe_custom_upload_dir() {
if (1) { //if we need to move the upload dir
add_filter( 'upload_dir', 'filter_upload_dir' );
}
}
/**
* return the new upload dir path
*
* @param $dirs
*
* @return mixed
*/
function filter_upload_dir($dirs) {
$dirs['path'] = '/mynew/upload/path';
$dirs['url'] = 'www.mysite.com/mynew/upload/url';
$dirs['baseurl'] = 'www.mysite.com/mynew/upload/baseurl';
$dirs['subdir'] = '/mynew/upload/subdir';
$dirs['basedir'] = '/mynew/upload/basedir';
return $dirs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment