Hack to allow some macros in pathspec
-
Hi –
I wanted to be able to organize uploaded files in my Dropbox by user, and by date, and so I added the following around line 422 of gravity-forms-dropbox-uploader/dropbox.php, just before the dropbox API code is included:
/* replace any macros in path */ global $current_user; if(!empty($path)) { $replace_macro = array('login','date','time'); foreach($replace_macro as $replace){ $needle = '$' . $replace . '$'; if (strpos($path,$needle) !== false) { switch ($replace) { case 'login': $login = empty($current_user->user_login) ? 'anonymous' : $current_user->user_login; $path = str_replace($needle,$login,$path); break; case 'date': $path = str_replace($needle,date('Y-m-d'),$path); break; case 'time': $path = str_replace($needle,date('H-i-s'),$path); break; } } } }Not sure if anyone else will find this useful or not, but this allows you to specify the following kind of thing in the ‘Path’ value of Dropbox Uploader Options:
Path: $login$\$date$\$time$\
Thanks for the plugin!
http://ww.wp.xz.cn/extend/plugins/gravity-forms-dropbox-uploader/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Hack to allow some macros in pathspec’ is closed to new replies.