Skip to content

Commit

Permalink
Navigation: Refactor the PHP render function to make it easier to mak…
Browse files Browse the repository at this point in the history
…e changes in the future (#55605)

* Navigation: Refactor the PHP render function to make it easier to make changes in the future

* move code to get_inner_blocks_html

* remove is-fallback class

* allow multiple menus

* add some comments

* refactor directives to a different function

* fix submenus

* refactor responseive navigation function

* remove a passed param

* create a function for get_styles

* dont pass the container_attributes as a param

* handle view script loading

* reorder code

* simplify the return

* tidy up the wrapper attributes

* remove one dependence on has_submenu

* remove the should load view script variable

* more simplification

* Update packages/block-library/src/navigation/index.php

Co-authored-by: Dave Smith <[email protected]>

* rename class

* remname is_responsive_navigation

* rename does_navigation_have_submenus

* rename get_inner_blocks_for_navigation

* rename get_layout_class_for_navigation

* Update packages/block-library/src/navigation/index.php

Co-authored-by: Dave Smith <[email protected]>

* Update packages/block-library/src/navigation/index.php

Co-authored-by: Dave Smith <[email protected]>

* change name of get_nav_markup

* split get_inner_blocks into smaller functions

* add comment

* remove unnecessary spaces

* update docs

* reverse parameter order

* reverse parameter order

* reverse parameter order

* move the class to a new file

* add docs

* rename  to

* move function that's only used by the plugin into that section of the code

* fix linter

* reference the class internally using static

* move variable to static variables

* Update lib/compat/wordpress-6.5/class-wp-navigation-block-renderer.php

Co-authored-by: Dave Smith <[email protected]>

* Update lib/compat/wordpress-6.5/class-wp-navigation-block-renderer.php

Co-authored-by: Dave Smith <[email protected]>

* move the logic for inner block rendering to a separate function

* test for navigation link markup

* test for site title markup

* removed comments, changed assertSame to assertEquals

* format php

* hide the condition in a function

* hide the condition in a function

* return early from has_submenus

* comments for the tests

* create a function to get the name

* rename variable to nav_blocks_wrapped_in_list_item

* phpcs

* phpcs

* Update phpunit/class-wp-navigation-block-renderer-test.php

Co-authored-by: Dave Smith <[email protected]>

* Update phpunit/class-wp-navigation-block-renderer-test.php

* Update phpunit/class-wp-navigation-block-renderer-test.php

* Apply suggestions from code review

Co-authored-by: Dave Smith <[email protected]>

* dynamic url for links on test

---------

Co-authored-by: Dave Smith <[email protected]>
Co-authored-by: MaggieCabrera <[email protected]>
  • Loading branch information
3 people authored Nov 9, 2023
1 parent 1e3dd2a commit f3bb6d5
Show file tree
Hide file tree
Showing 4 changed files with 745 additions and 402 deletions.
Loading

1 comment on commit f3bb6d5

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in f3bb6d5.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6811607303
📝 Reported issues:

Please sign in to comment.