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 <getdavemail@gmail.com>

* 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 <getdavemail@gmail.com>

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

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* 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 <getdavemail@gmail.com>

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

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* 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 <getdavemail@gmail.com>

* 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 <getdavemail@gmail.com>

* dynamic url for links on test

---------

Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: MaggieCabrera <maggie.cabrera@automattic.com>
  • Loading branch information
3 people authored and cbravobernal committed Nov 14, 2023
1 parent 5c0781a commit 14ae98b
Show file tree
Hide file tree
Showing 4 changed files with 745 additions and 402 deletions.
Loading

0 comments on commit 14ae98b

Please sign in to comment.