-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12125fc
commit 6c1b514
Showing
1 changed file
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,10 @@ | |
"name": "Josh Cunningham", | ||
"email": "[email protected]" | ||
} | ||
] | ||
} | ||
], | ||
"autoload": { | ||
"files": [ | ||
"wp-rest-api-auth0.php" | ||
] | ||
} | ||
} |
6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshcanhelp Composer's autoloader is/should be required from
wp-config.php
where MU plugins are unable to start.Please see https://github.com/joshcanhelp/wp-rest-api-auth0/blob/main/wp-rest-api-auth0-loader.php#L5
6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
composer require johnpbloch/wordpress composer/installers joshcanhelp/wp-rest-api-auth0 cp wp-content/mu-plugins/wp-rest-api-auth0/wp-rest-api-auth0-loader.php wp-content/mu-plugins/ # 🎉
6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@szepeviktor - Without this, the
wp-rest-api-auth0.php
is not being loaded when using Composer. How would it know about that file?6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually
wp-rest-api-auth0-loader.php
should committed to the WordPress installation/project repo.And there are mu plugin loaders out there.
With Composer/autoload/files it loads too early, e.g. there is no
add_action
function.6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I follow here. On my local setup using Composer (and I could be doing it wrong but it looks ok to me and works), I have a
wp-content/mu-plugins/load.php
file that simply requiresvendor/autoload.php
. Then I add acomposer.json
right next to that to requirejoshcanhelp/wp-rest-api-auth0
. Without thatautoload
property, the autoloader would not get built including the right file. How would it know to include it?Using the loader file, we're running
composer install
in the package itself and then including the 2 necessary files manually.Am I missing something here? Not sure of what use case this would break.
Appreciate your input here, BTW 👍
6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. That is late enough.
If you move
require vendor/autoload.php
towp-config.php
the problem will arise.https://github.com/szepeviktor/debian-server-tools/blob/master/webserver/wp-install/wp-config.php#L54-L56
6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems too early to start loading plugins. Whenever you load this code, you'll need to have
add_action
available, otherwise it won't work. I'm guessing if this was not throwing an error before then the autoload was not including the right file, which this commit fixes.6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the thing is, Composer autoloader is first thing in all applications, e.g. https://github.com/laravel/laravel/blob/8.x/public/index.php#L34
There are two ways: the WordPressy and the OOP. I choose the later. But it is not a must for you!
6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, in most cases. But, whether you include or autoload the main file here, you need to have
add_action
defined. I don't really see a way around that.6c1b514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... is the loader file
wp-rest-api-auth0-loader.php
but it needs manual action and 99.999% of WordPress users are unable to take manual actions.