You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changes to autoloader to allow companion plugins to register and utilize the autoloader via the gatherpress_autoloader filter. This filter is an array where the key is the namespace (eg GatherPress) and the value is the root directory (eg __DIR__).
Improvements to the Autoloader Class
The class-autoloader.php file underwent multiple enhancements to ensure more accurate and efficient automatic class loading. These changes refine the way classes are recognized and loaded by introducing additional checks and refinement techniques.
The method responsible for registering classes now strictly accepts string values, to make sure we are handling correct data type.
We introduced a default array to handle specific default behaviors in the auto-loading process. This helps us manage package behavior more effectively.
We adopted an application of filters to our gatherpress_autoloader hook. It allows us to modify certain elements during the auto-loading process, giving us more flexibility in control and execution.
We implemented a loop to oversee registered autoloaders. This means that we've made provisions to manage multiple autoloaders smartly.
With application of the trim function, we are ensuring there are no leading or trailing backslashes disrupting class string manipulations.
We've applied checks to ensure that the class string is neither empty nor excluding backslashes. This helps us keep our data uniform and valid.
The class string is broken down into smaller strings. This process aids in managing and determining the different components of a given class path.
These small strings (or array elements) are converted to lowercase and standardized by replacing underscores with hyphens. This promotes consistency and effective pattern recognition in the class path naming schema.
The type of file and class gets derived from this array, breaking down complex identification into smaller, manageable parts.
Further, the array is manipulated according to the class type. This ensures each class type is handled in a manner conducive to its specifics.
The array elements and the path are used to generate the final file path. This results in an organized directory structure ensuring faster and easier file access.
We use the validate_file function to ensure the designated file path is valid and reliable, helping us avoid inefficiencies or errors due to faulty paths.
If the file is confirmed to exist and its validity verified, it is included within the current script. This guarantees accurate class loading and improved script execution.
Lastly, the registration of autoload mechanisms now uses a static anonymous function with a definite void type. It guarantees better manageability and cleaner code since we are making sure what kind of data (in this case, no data or void) is being returned by our function.
The changes to this autoloader are designed to make your application's class loading process more precise, efficient, and flexible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
Changes to autoloader to allow companion plugins to register and utilize the autoloader via the
gatherpress_autoloaderfilter. This filter is an array where the key is the namespace (egGatherPress) and the value is the root directory (eg__DIR__).How to test the Change
Everything in GatherPress should work normally.
Changelog Entry
Credits
Props @mauteri
Checklist: