fix(autoload): Correct autoloader pathing (#3) and unbundle free version#4
Conversation
- fix the broken autoloader (wordpress-premium#3) regarding acf/ vs ACF/ directories - unbundle the free version from the repository - use upstream Polylang free plugin version to generate the classmap - ... and redump the autoloader Setup: - install the free version of the plugin - then this one - For a futureproof maintenance free setup for Bedrock/composer WP installation, polylang (free) should come too with an adequate composer.json autoload configuration
|
Many thanks for this, @drzraf. I'll have an eye on future releases. |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes autoloader pathing issues and removes the bundled free version of Polylang in favor of using the upstream version. The changes address issue #3 related to ACF directory case sensitivity and improve the plugin's dependency management.
- Removed the bundled free version and its direct require statement
- Added classmap autoloading configuration to include both local directories and the upstream Polylang plugin
- Configured the setup to work with the free version installed separately
Reviewed Changes
Copilot reviewed 2 out of 475 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| polylang.php | Removes direct require of bundled Polylang free version |
| composer.json | Adds classmap autoloading for local directories and upstream Polylang |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| "localization" | ||
| ], | ||
| "autoload": { | ||
| "classmap": ["include/", "integrations/", "modules/", "services/", "../polylang"] |
There was a problem hiding this comment.
The relative path '../polylang' in the classmap is fragile and assumes a specific directory structure. Consider using a more robust approach like requiring polylang as a composer dependency or documenting the expected directory layout clearly.
| "classmap": ["include/", "integrations/", "modules/", "services/", "../polylang"] | |
| "classmap": ["include/", "integrations/", "modules/", "services/"] |
There was a problem hiding this comment.
There are two scenarios:
- WP zip install
- composer installation
zip install doesn't depends upon composer install / autoload etc... => out of scope.
Regarding the composer install, the underlying problem is that -pro version depends on classes defined by the free version, aka the free-version autoloader must load before the -pro version which is more about WordPress plugin load order.
Normally it's not a problem because the free and the -pro version would be installed as packages and the same root-level autoloader would be used.
The above is only when doing composer install within polylang-pro directory which is probably not the most common case.
That being said, if PolyLang-free isn't installed, the fact that the -pro version autoloader can't find ../polylang is just another symptom of the same underlying problem which would happen anyway.
Setup: