Last active
December 21, 2022 14:09
-
-
Save giucu91/6bd0e2bd25122a9c8b5c83ea43e83bae to your computer and use it in GitHub Desktop.
change-dlm-upload-folder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'upload_dir', 'change_upload_dir_for_dlm', 30 ); | |
function change_upload_dir_for_dlm( $pathdata ){ | |
if ( isset( $_POST['type'] ) && 'dlm_download' === $_POST['type'] ) { | |
if ( empty( $pathdata['subdir'] ) ) { | |
$pathdata['path'] = $pathdata['path'] . '/private'; | |
$pathdata['url'] = $pathdata['url'] . '/private'; | |
$pathdata['subdir'] = '/private'; | |
} else { | |
$new_subdir = '/private' . $pathdata['subdir']; | |
$pathdata['path'] = str_replace( $pathdata['subdir'], $new_subdir, $pathdata['path'] ); | |
$pathdata['url'] = str_replace( $pathdata['subdir'], $new_subdir, $pathdata['url'] ); | |
$pathdata['subdir'] = str_replace( $pathdata['subdir'], $new_subdir, $pathdata['subdir'] ); | |
} | |
} | |
return $pathdata; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment