wp-bootstrap-navwalker icon indicating copy to clipboard operation
wp-bootstrap-navwalker copied to clipboard

Re-add autoloading using PSR-4

Open MWDelaney opened this issue 7 years ago • 2 comments

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:

  • require this package in a WordPress theme which includes Composer's autoload.php like Sage 9.

  • Add the walker argument to your wp_nav_menu():

        'walker'            => new \WP_Bootstrap\WP_Bootstrap_Navwalker()

MWDelaney avatar Jul 31 '18 19:07 MWDelaney

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

pattonwebz avatar Oct 02 '19 17:10 pattonwebz

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

ethanclevenger91 avatar Oct 28 '20 18:10 ethanclevenger91