Hi,
the plugin custom_upload_dir promised to provide a great feature. Unfortunately, it did not work at first, because all %post*%
variables dependend on post_id in the function cud_custom_upload_dir()
did not work. The reason was that post_id was defined as global
in the function and it got the initial value 0. The correct initialization was skipped due to the (wrong) if clause.
PHP Version: 5.2.17 .
Solution:
# diff custom_upload_dir.php custom_upload_dir.php.save
[...]
< if(!isset($post_id) || !(is_numeric($post_id) && ($post_id>0))){
< // print("DEBUG: setting post_id...\n");
---
> if(!isset($post_id) && !is_numeric($post_id)){
This thread just appeared on my RSS, six days after being posted?
Neither of those lines are in Custom Upload Dir. They probably haven't been for some time as $post_id dissapeared a thousand years ago.
You've probably already got the updgrade notie in the WP admin, but here's the link anyway. http://wordpress.org/extend/plugins/custom-upload-dir/
And thanks for taking the time to report an issue and providing the fix. Even if it wasn't current. :)
Hi,
I changed the tag from custom_upload_dir to custom-upload-dir recently...
Meanwhile I got the latest version and the mentioned lines are gone, great! I didn't look at the dev release before.
> grep post_id custom_upload_dir.php | wc -l
31
There might be a time machine in between... ;-)
Thanks for this great contribution to wordpress!