michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Conflicting with WR MegaMenu #218

Closed mnajafzadeh closed 8 years ago

mnajafzadeh commented 8 years ago

Hello, Unfortunately, the Admin Page Framework conflicts with WR MegaMenu, https://wordpress.org/plugins/wr-megamenu/ plugin and the options in back-end do no shown and stops working. When I deactivate the WR MegaMenu plugin everything work fine. Could you help me with a patch or any solution? Thank you.

michaeluno commented 8 years ago

Hi,

Looks like the global $post variable gets modified by that plugin and Admin Page Framework accesses it to check the post type of the current admin screen.

The problematic code is https://github.com/wp-plugins/wr-megamenu/blob/d95f67e0a181ff0039a23a255987589bbb2eb091/includes/helpers/type.php#L679 where the_post() method is used.

Here you can install this plugin that fixes the problem. https://gist.github.com/michaeluno/2b4c2462527937476516

mnajafzadeh commented 8 years ago

The plugin fixed the issue. Does this plugin solves this issue on all other plugins that may conflicts because of the same issue $post variable problem?

Thank you.

michaeluno commented 8 years ago

Glad to hear it works.

Does this plugin solves this issue on all other plugins that may conflicts because of the same issue $post variable problem?

Not likely because it uses an action hook that only gets triggered by that plugin.

Here I posted another one (https://gist.github.com/michaeluno/b8df5e5796980fcec8ad) that may work for other plugins that modify the global $post variable.

mnajafzadeh commented 8 years ago

Yes, the wr_megamenu_init action hook was the reason that I asked for another solution. This one works like a charm. Thank you very much.

michaeluno commented 8 years ago

I've changed the code not to use the global $post variable to determine the current screen post type in the development branch. You may try it. Download

mnajafzadeh commented 8 years ago

It's Great! Thank you.