Re-add autoloading using PSR-4
Changes proposed in this Pull Request:
-
Re-add autoloading using PSR-4 class autoloading. This will prevent the errors indicated in #361 because the class won't be loaded until called in
wp_nav_menu(). -
Added namespace to prevent conflicts.
-
Moved and renamed class file for autoloading, implemented PSR-2 coding standards.
Testing instructions:
-
requirethis package in a WordPress theme which includes Composer'sautoload.phplike Sage 9. -
Add the
walkerargument to yourwp_nav_menu():
'walker' => new \WP_Bootstrap\WP_Bootstrap_Navwalker()
Hey, for autoloading would a classmap not be better? The navwalker does not currently use namespaces at all an adding those would be a breaking change needing a major version bump. Adding this to the v5 mileston
Would love to see this revived, and a backwards-compat breaking move to namespaces would be required for Composer 2.0 compatibility:
Deprecation Notice: Class WP_Bootstrap_Navwalker located in .../vendor/wp-bootstrap/wp-bootstrap-navwalker\class-wp-bootstrap-navwalker.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class WP_Nav_Menu_Args located in .../vendor/wp-bootstrap/wp-bootstrap-navwalker\tests\phpstan\class-wp-nav-menu-args.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class WP_Nav_Menu_Item located in .../vendor/wp-bootstrap/wp-bootstrap-navwalker\tests\phpstan\class-wp-nav-menu-item.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Test_WP_Bootstrap_NavWalker located in .../vendor/wp-bootstrap/wp-bootstrap-navwalker\tests\test-navwalker.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201