WPChill / download-monitor

A WordPress plugin which provides an intuitive UI for uploading and managing downloadable files (including support for multiple versions), inserting download links into posts & logging downloads.
http://wordpress.org/extend/plugins/download-monitor/
262 stars 117 forks source link

Plugin conflict with Event Espresso plugin #1548

Closed razvanaldea89 closed 2 months ago

razvanaldea89 commented 2 months ago

Describe the bug Plugin conflict with the Event Espresso plugin, but is it more general with all plugins that define an admin page that have meta boxes but the $post is null.

https://support.wpchill.com/conversation/19203?folder_id=251

cristinnaiulia commented 2 months ago

Steps to reproduce the issue:

  1. Have both Download Monitor and Event Espresso active
  2. Go to Event Espresso settings and see the warning:

Screenshot 2024-09-20 101019

The problem is solved with DLM 5.0.10.

Pebblo commented 2 months ago

Hi folks,

I'm one of the EventEspresso team, the user who reported the above also opened a support thread with ourselves regarding this which ultimately led me here.

Firstly, thank you for the fix, we load the admin on non-standard routes and recognise that part of these issues is on us. Simple enough to fix but as I'm sure you are aware trying to explain to the end user, which plugin needs to update to fix this gets... messy. So finding you folks are already on top of it is a welcome surprise :)

If I may, I have a recommendation on this as we've worked through it before.

Your add_meta_boxes callback simply removes the submitdiv metabox from your post type, then checks if loading your post type before doing its thing, which is great, nothing wrong with that at all.

However, if you switch out to use the add_metaboxes{$post_type} action you'll avoid having to jump through those post type hoops as the callback will only ever be called on your specific post type and not all. That also covers if $post is somehow not null and isn't a WP_Post (which we've also seen elsewhere).

So just - add_action( 'add_meta_boxes_dlm_download', array( $this, 'add_meta_boxes' ), 15 );

That hook is also passed the current $post as it's single parameter so you'll already have that available when called.

Anyway, feel free to ignore me I just ended up here when reviewing our support thread, remembered the same fix from a previous discussion so thought it worth mentioning for you guys to consider. Either way again, thanks for fixing this and hope you all have a great week.

Tony

razvanaldea89 commented 2 months ago

Hello Tony,

Thanks for the feedback. You're right, we should go with the hook you've mentioned, going to make the modifications and we'll include it in the next update.

Warmly, Razvan