Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an Autoloader based on the Plugin Directory, for autoloading of utilities #331

Merged
merged 6 commits into from
Feb 24, 2023

Conversation

dd32
Copy link
Member

@dd32 dd32 commented Feb 1, 2023

This makes it easier to use the included utilities, such as #330 without having to manually include the files.

@dd32 dd32 marked this pull request as ready for review February 1, 2023 05:05
@dd32
Copy link
Member Author

dd32 commented Feb 2, 2023

There's a number of other variants of this in use on WordPress.org, all of which are the same as this one, just in a different namespace.

I'm going to promote this to being \WordPressdotorg\Autoload and move it out of the Utilities folder in the process.

plugins/rosetta/rosetta.php:if ( ! class_exists( '\WordPressdotorg\Autoload\Autoloader', false ) ) {
plugins/rosetta/rosetta.php-	include __DIR__ . '/vendor/wordpressdotorg/autoload/class-autoloader.php';
plugins/rosetta/rosetta.php-}
plugins/rosetta/rosetta.php-
plugins/rosetta/rosetta.php-// Register an Autoloader for all files.
plugins/rosetta/rosetta.php-Autoload\register_class_path( __NAMESPACE__, __DIR__ . '/inc' );
--
plugins/wporg-gp-translation-suggestions/wporg-gp-translation-suggestions.php:if ( ! class_exists( '\WordPressdotorg\Autoload\Autoloader', false ) ) {
plugins/wporg-gp-translation-suggestions/wporg-gp-translation-suggestions.php-	include __DIR__ . '/vendor/wordpressdotorg/autoload/class-autoloader.php';
plugins/wporg-gp-translation-suggestions/wporg-gp-translation-suggestions.php-}
plugins/wporg-gp-translation-suggestions/wporg-gp-translation-suggestions.php-
plugins/wporg-gp-translation-suggestions/wporg-gp-translation-suggestions.php-// Register an Autoloader for all files.
plugins/wporg-gp-translation-suggestions/wporg-gp-translation-suggestions.php-Autoload\register_class_path( __NAMESPACE__, __DIR__ . '/inc' );
--
plugins/wporg-gp-routes/wporg-gp-routes.php:if ( ! class_exists( '\WordPressdotorg\Autoload\Autoloader', false ) ) {
plugins/wporg-gp-routes/wporg-gp-routes.php-	include __DIR__ . '/vendor/wordpressdotorg/autoload/class-autoloader.php';
plugins/wporg-gp-routes/wporg-gp-routes.php-}
plugins/wporg-gp-routes/wporg-gp-routes.php-
plugins/wporg-gp-routes/wporg-gp-routes.php-// Register an Autoloader for all files.
plugins/wporg-gp-routes/wporg-gp-routes.php-Autoload\register_class_path( __NAMESPACE__, __DIR__ . '/inc' );
--
plugins/wporg-gp-theme-directory/wporg-gp-theme-directory.php:if ( ! class_exists( '\WordPressdotorg\Autoload\Autoloader', false ) ) {
plugins/wporg-gp-theme-directory/wporg-gp-theme-directory.php-	include __DIR__ . '/vendor/wordpressdotorg/autoload/class-autoloader.php';
plugins/wporg-gp-theme-directory/wporg-gp-theme-directory.php-}
plugins/wporg-gp-theme-directory/wporg-gp-theme-directory.php-
plugins/wporg-gp-theme-directory/wporg-gp-theme-directory.php-// Register an Autoloader for all files.
plugins/wporg-gp-theme-directory/wporg-gp-theme-directory.php-Autoload\register_class_path( __NAMESPACE__, __DIR__ . '/inc' );
--
plugins/wporg-gp-plugin-directory/wporg-gp-plugin-directory.php:if ( ! class_exists( '\WordPressdotorg\Autoload\Autoloader', false ) ) {
plugins/wporg-gp-plugin-directory/wporg-gp-plugin-directory.php-	include __DIR__ . '/vendor/wordpressdotorg/autoload/class-autoloader.php';
plugins/wporg-gp-plugin-directory/wporg-gp-plugin-directory.php-}
plugins/wporg-gp-plugin-directory/wporg-gp-plugin-directory.php-
plugins/wporg-gp-plugin-directory/wporg-gp-plugin-directory.php-// Register an Autoloader for all files.
plugins/wporg-gp-plugin-directory/wporg-gp-plugin-directory.php-Autoload\register_class_path( __NAMESPACE__, __DIR__ . '/inc' );
--
plugins/wporg-gp-rosetta-roles/wporg-gp-rosetta-roles.php:if ( ! class_exists( '\WordPressdotorg\Autoload\Autoloader', false ) ) {
plugins/wporg-gp-rosetta-roles/wporg-gp-rosetta-roles.php-	include __DIR__ . '/vendor/wordpressdotorg/autoload/class-autoloader.php';
plugins/wporg-gp-rosetta-roles/wporg-gp-rosetta-roles.php-}
plugins/wporg-gp-rosetta-roles/wporg-gp-rosetta-roles.php-
plugins/wporg-gp-rosetta-roles/wporg-gp-rosetta-roles.php-// Register an Autoloader for all files.
plugins/wporg-gp-rosetta-roles/wporg-gp-rosetta-roles.php-Autoload\register_class_path( __NAMESPACE__, __DIR__ . '/inc' );
--
plugins/wporg-gp-customizations/wporg-gp-customizations.php:if ( ! class_exists( '\WordPressdotorg\Autoload\Autoloader', false ) ) {
plugins/wporg-gp-customizations/wporg-gp-customizations.php-	include __DIR__ . '/vendor/wordpressdotorg/autoload/class-autoloader.php';
plugins/wporg-gp-customizations/wporg-gp-customizations.php-}
plugins/wporg-gp-customizations/wporg-gp-customizations.php-
plugins/wporg-gp-customizations/wporg-gp-customizations.php-// Register an Autoloader for all files.
plugins/wporg-gp-customizations/wporg-gp-customizations.php-Autoload\register_class_path( __NAMESPACE__, __DIR__ . '/inc' );

@dd32 dd32 merged commit 3e4fb24 into trunk Feb 24, 2023
@dd32 dd32 deleted the add/autoloader branch February 24, 2023 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant