Title: [Plugin: Custom Upload Dir] correction submit
Last modified: August 20, 2016

---

# [Plugin: Custom Upload Dir] correction submit

 *  Resolved [Claude ws](https://wordpress.org/support/users/clauden/)
 * (@clauden)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/)
 * Hello ulfben, thx for your great plugin.
 * I made the following “correction” at line 160
 * original
    $post_name = (!empty($post->post_name)) ? $post->post_name : (!empty(
   $post->post_title)**)** ? sanitize_title($post->post_title) : $post_id;
 * “correction”
    $post_name = (!empty($post->post_name)) ? $post->post_name : (!
   empty($post->post_title) ? sanitize_title($post->post_title) : $post_id**)**;
 * simply moved a parenthesis. I was getting the post_title instead of the post_name(
   slug).
 * Kind regards.
    Claude.
 * [http://wordpress.org/extend/plugins/custom-upload-dir/](http://wordpress.org/extend/plugins/custom-upload-dir/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470593)
 * Hi Claude, and thanks!
 * I’d like to run the modification through some test cases to make sure it’s correct.
   Do you have some string that will ’cause my original version to foul-up?
 *  Thread Starter [Claude ws](https://wordpress.org/support/users/clauden/)
 * (@clauden)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470595)
 * Hey Ulfben!
 * to test:
    1. set custom upload to %post_name%. 2. create and save one post with“
   title-test” as title & “slug-test” as slug. 3. upload an image and it will create
   a folder with the name “title-test”, not “slug-test”.
 * Tell me if you get a different result.
 * Kind regards,
    Claude.
 *  Plugin Author [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470600)
 * Commited to the development version (along with some other fixes). I’d appreciate
   it if you could try it out and let me know if it seems alright.
 * [http://wordpress.org/extend/plugins/custom-upload-dir/download/](http://wordpress.org/extend/plugins/custom-upload-dir/download/)
 *  Thread Starter [Claude ws](https://wordpress.org/support/users/clauden/)
 * (@clauden)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470602)
 * – Did a test. same problem.
    – modified the line as described: works. – furthermore.
   Allow me to be a bit “direct” about the use of parenthesis on that line: `(!empty(
   $post->post_name)) ? $post->post_name : (!empty($post->post_title) ? sanitize_title(
   $post->post_title) : $post_id);`
 * is equal to
    `( if .. ) then .. else ( if .. ) then .. else ..` in which I fail
   to see the logic.
 * what you want is:
    `if .. then .. else (if .. then .. else .. )`
 * But I could be mistaking.
 * Kind regards, & keep the good work.
    claude.
 *  Plugin Author [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470608)
 * The line you’re quoting now is identical to the correction you gave me, and identical
   to the line currently in the source. Can you please re-download the development
   version and make sure we’re talking about the same test?
 * **Currently in the source:**
    `(!empty($post->post_name)) ? $post->post_name :(!
   empty($post->post_title) ? sanitize_title($post->post_title) : $post_id);`
 * **Your correction:**
    `(!empty($post->post_name)) ? $post->post_name : (!empty(
   $post->post_title) ? sanitize_title($post->post_title) : $post_id);`
 * As for the “redundant” parenthesis (surrounding the test-parts of the if-statement)
   they makes no logical difference to PHP. The pre-processor simply removes them
   when evaluating the line.
 * I use them to separate and clarify the expressions of the ternary operators –
   especially when doing multiple comparisons: `($a > 5 && $a < 15) ? doWhatever():
   doSomethingElse();`
 *  Thread Starter [Claude ws](https://wordpress.org/support/users/clauden/)
 * (@clauden)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470612)
 * Hello Ulf,
    your modification of the line 160, in my latest download of custom-
   upload-dir, is the modification I made. Correct.
 * No worries, I do share your “parenthesis approach” when dealing with long formulations.
 * Thank you for you great plugin.
 * Kind regards,
    Claude.
 *  Plugin Author [ulfben](https://wordpress.org/support/users/ulfben/)
 * (@ulfben)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470614)
 * Thanks. So I can mark this resolved?
 *  Thread Starter [Claude ws](https://wordpress.org/support/users/clauden/)
 * (@clauden)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470615)
 * Yes Ulf, you may.
    Kind regards Claude.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘[Plugin: Custom Upload Dir] correction submit’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-upload-dir.svg)
 * [Custom Upload Dir](https://wordpress.org/plugins/custom-upload-dir/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-upload-dir/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-upload-dir/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-upload-dir/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-upload-dir/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-upload-dir/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Claude ws](https://wordpress.org/support/users/clauden/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-custom-upload-dir-correction-submit/#post-2470615)
 * Status: resolved