Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension interferes with menu items #356

Open
agh1 opened this issue Jan 11, 2023 · 1 comment
Open

Extension interferes with menu items #356

agh1 opened this issue Jan 11, 2023 · 1 comment

Comments

@agh1
Copy link

agh1 commented Jan 11, 2023

The method of adding menu items can interfere with custom menu items added in the Navigation Menu page and nested under the Mailings menu.

To reproduce:

  1. Install the extension
  2. Visit the Navigation Menu admin page and create a new menu item with "Mailings" as the parent menu item.
  3. Note that it doesn't appear in the menu.
  4. Repeat 4-5 more times. Notice that eventually the menu items start to appear.
  5. Disable the extension and see how all of the custom menu items appear.
  6. Re-enable the extension and see several disappear.

It seems that the code here is the problem:

$maxId = max(array_keys($params));
$mailChimpMaxId = empty($mailchimpSettings) ? $maxId+1 : $mailchimpSettings;
$mailChimpsyncId = empty($mailchimpSync) ? $mailChimpMaxId+1 : $mailchimpSync;
$mailChimpPullId = empty($mailchimpPull) ? $mailChimpsyncId+1 : $mailchimpPull;
$mailChimpCheckId = empty($mailchimpCheck) ? $mailChimpPullId+1 : $mailchimpCheck;

By taking the max ID of the menu items as they were passed to the hook and assuming that nobody would be adding further menu items, certainly not in the Mailings menu, it ends up interfering with custom menu items and other extensions' menu items that appear under Mailings.

I'm not 100% confident of the solution, but I think it would be to add navigation items via the API and position them appropriately.

@agh1
Copy link
Author

agh1 commented Jan 11, 2023

If anyone needs a workaround, just create a pile of custom menu items under Mailings until they start to show up, then create the custom menu item you actually need, then delete the filler ones. This will leave a gap in the Navigation IDs big enough for those four Mailchimp items to be inserted with overlapping IDs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant