WordPress.org

Forums

Download Attachments
[resolved] Problem after update to WP 3.9 (9 posts)

  1. trawp
    Member
    Posted 1 year ago #

    DA plugin works fine on posts and pages, but problem on Custom Post Types (Types Version 1.5.5)

    Don't know which plugin has problem. Deactivated all other plugins, same problem:

    DA recognizes the CPT's in settings and loads the metabox correctly on the CPT.

    Add New Attachment on CPT always get's;
    Unexpected error occured. Please refresh the page and try again.

    Thank you in advance

    https://wordpress.org/plugins/download-attachments/

  2. dFactory
    Member
    Plugin Author

    Posted 1 year ago #

    It looks ok on our installs. But more compatibility tests are on the way.

  3. trawp
    Member
    Posted 1 year ago #

    Hi dFactory

    Also have issue submitted with Types plugin

    Thanks

  4. badpat
    Member
    Posted 1 year ago #

    I too got the "Unexpected error occured. Please refresh the page and try again." message while trying to add additional attachments to a page.

    I backtraced it to the "public function update_attachments()" in metabox.php

    The problem seems to be that "$_POST['post_id']" equals zero.

    Getting further back into "admin-post.js" the object "wp.media.view.settings.post" seems to be empty. At least the id is zero in there.

    I don't know where this is normally set, so just take it as a hint.

    As I am only having one page with attachments I hardcoded the post_id of said page into the plugin in metabox.php . Works for me at the moment.

  5. dFactory
    Member
    Plugin Author

    Posted 1 year ago #

    @badpat, are you sure you did not change anything else? If not we'll probably need to dive into your site's admin. (you'll need to post a topic on our dedicated forum)

    We tested the plugin on our installs and it worked as expected.

  6. trawp
    Member
    Posted 1 year ago #

    I finally traced it down to neither of the plugins having a problem.

    The problem was in the Custom Post Types settings:
    Display Sections
    Thumbnail
    must be activated.

    It must be in the new way attachments are called in 3.9. Although I was only using audio attachments, after activating Thumbnails for the CPT all was well.

    Thanks

  7. badpat
    Member
    Posted 4 months ago #

    Sorry to ressurect this old thread, but I just had some spare minutes and I think I found a solution.

    According to WP Function_Reference - wp_enqueue_media the post has to be specified to which the media should be added. Otherwise: "if you do not set this parameter, uploaded files will not be attached to a post."

    So, in download-attachments.php change line 404 from:

    wp_enqueue_media();

    to

    wp_enqueue_media( array( 'post' => (isset($post->ID) ? $post->ID : 0 ) ) );

    This fixed the problem for me...

    Cheers,
    Patrick

  8. dFactory
    Member
    Plugin Author

    Posted 4 months ago #

    But we don't won't to attach it to a post. At least it was not our intention.

    Maybe a plugin option would be handy here.

  9. dFactory
    Member
    Plugin Author

    Posted 4 months ago #

    It will be modified in the upcoming release.
    Thx @badpat

    Regards,
    Bartosz / dfactory

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Download Attachments
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.