Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Menu API enhancements#2517

Merged
nlemoine merged 26 commits into
2.xfrom
2.x-menu-enhancements
May 3, 2022
Merged

Menu API enhancements#2517
nlemoine merged 26 commits into
2.xfrom
2.x-menu-enhancements

Conversation

@nlemoine

Copy link
Copy Markdown
Member

No description provided.

- Introduce Timber::get_menu_by(closes #2496)
- Improve filter compatibility (#1820)
- Refactor Menu factory and Menu build method
Comment thread lib/Factory/MenuFactory.php
@coveralls

coveralls commented Nov 10, 2021

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.7%) to 89.032% when pulling e02db34 on 2.x-menu-enhancements into 5344a44 on 2.x.

Comment thread lib/Factory/MenuItemFactory.php
Comment thread lib/Menu.php
Comment thread lib/Menu.php
Comment thread lib/Menu.php
Comment thread lib/MenuItem.php Outdated

@gchtr gchtr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you’re way deeper into the menu logic than I will ever be. Thanks a lot for all your work! There’s lots of optimizations in there. I also like the part about the caching compatibility with other plugins.

I saw a couple of things that I think we discussed before. I added comments right in the code.

Comment thread lib/Factory/MenuFactory.php
Comment thread lib/Factory/MenuItemFactory.php
Comment thread lib/Factory/MenuFactory.php
Comment thread lib/Menu.php
Comment thread lib/MenuItem.php Outdated
Comment thread lib/Timber.php
Comment thread lib/Timber.php
@nlemoine nlemoine requested a review from gchtr December 4, 2021 14:08
@gchtr gchtr added the 2.0 label Feb 21, 2022
gchtr
gchtr previously approved these changes Feb 21, 2022

@gchtr gchtr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t want to keep this back much longer. There are lots of good things in here. I take three todos out of this:

  • I’d like to just leave in the pages menu logic and refactor it with a separate issue (#2292).
  • Then there’s the idea about the feature parity with wp_nav_menu(), which we found is quite hard to accomplish. A separate method that builds a menu using the nav menu walker is quite a good idea for people who need to use it for compatibility reasons (see #2517 (comment)).
  • And finally, to return null instead of false from the factory methods so that they work with the null coalescing operator.

Once all the tests go green we can merge this in. Thank you so much for your work @nlemoine. Tell me if you still find the time to get this pull request ready more merging or if you’d like to pass it on.

@gchtr gchtr mentioned this pull request Feb 21, 2022
@jarednova

Copy link
Copy Markdown
Member

Just want to flag the two failing tests we have remaining ...

There were 2 failures:

1) TestMenuItemFactory::testMenuGarbageInGarbageOut
Failed asserting that false is null.

Error: /home/runner/work/timber/timber/tests/test-menu-item-factory.php:53
phpvfscomposer:///home/runner/work/timber/timber/vendor/phpunit/phpunit/phpunit:60

2) TestTimberTerm::testTermWithNativeMetaNotExisting
Failed asserting that 'qux' is null.

Error: /home/runner/work/timber/timber/tests/test-timber-term.php:4[49](https://github.com/timber/timber/runs/5343496381?check_suite_focus=true#step:15:49)
phpvfscomposer:///home/runner/work/timber/timber/vendor/phpunit/phpunit/phpunit:[60](https://github.com/timber/timber/runs/5343496381?check_suite_focus=true#step:15:60)```

Comment thread lib/Factory/MenuFactory.php Outdated
@gchtr gchtr removed the request for review from acobster March 24, 2022 21:43
Comment thread lib/Menu.php Outdated
nlemoine and others added 2 commits March 28, 2022 22:13
Co-authored-by: Lukas Gächter <[email protected]>
- Add classmap to `MenuItemFactory`
- Don't return a menu when no `$params` are passed to `MenuFactory::from()`
Comment thread tests/test-menu-item-factory.php
Comment thread lib/MenuItem.php
Comment thread lib/Factory/MenuItemFactory.php

@gchtr gchtr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for the additional updates @nlemoine. I like the new timber/menuitem/classmap filter 💪. And good catch with the assertInstanceOf() checks. I added two more issues to finish work on these in #2571 and #2572.

For me, the only remaining discussion is in #2517 (comment). Apart from that it would be nice if we could merge this in, soon.

If you want to add additional features, I think it would be nice to add it in a separate pull request. I think it’s better to have many smaller pull requests instead of having one big pull request that keeps growing and growing.

@gchtr

gchtr commented Apr 12, 2022

Copy link
Copy Markdown
Member

Oh, and #2517 (comment) is also unfinished 🙂. Do we want to move that to a separate issue as well, or do you want to solve it here, @nlemoine?

@nlemoine

Copy link
Copy Markdown
Member Author

@gchtr I think we're finally good on menus 😅

Please check my comment here: #2517 (comment) for the title explanation.

@nlemoine

nlemoine commented May 3, 2022

Copy link
Copy Markdown
Member Author

Do I still need to wait for @jarednova approval?

@gchtr

gchtr commented May 3, 2022

Copy link
Copy Markdown
Member

@nlemoine No, I think Jared would have commented already earlier in the process if he saw something. You can merge it in 🎉. Thanks for your work on this!

@nlemoine nlemoine merged commit f165c68 into 2.x May 3, 2022
@nlemoine nlemoine deleted the 2.x-menu-enhancements branch May 3, 2022 15:35
@nlemoine

nlemoine commented May 3, 2022

Copy link
Copy Markdown
Member Author

Yeah! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants