-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Restructure PHP code into separate files #985
Conversation
I think this is pretty straightforward, and would probably be comfortable merging it in the next couple days so that I can move forward with this in a separate PR:
Still, review would be welcome. |
While you're at it, what about renaming |
Do you think we could model it as if we were to place it in |
Do you have a specific idea for how to work towards this now? Otherwise, I think this would be better left to a separate set of tasks, because there is a lot to do. For example, some of this code will live in |
Right, I mean mostly just the names of the files themselves if there are any patterns we should be following. |
2f2c6fb
to
5c7d641
Compare
I think we will end up with some files named |
This is the recommended plugin folder structure. Unfortunately, this means that anyone using the plugin will get an error when they upgrade with this change, then attempt to load the editor:
The fix is to visit the
and then re-activate the plugin. If we are going to do this change (it seems good to follow the recommended folder structure), we should do it now, before we release to the plugin directory. At this time it will mostly affect those of us who are developing the plugin. Thoughts? |
8d0367b
to
750a14d
Compare
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
die( 'Silence is golden.' ); |
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.
This is kind of a paradox, if you're actually outputting it. :)
I usually do defined( 'ABSPATH' ) || die;
to keep it short.
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.
Good code should generate paradoxes once in a while.
👍 Yes, the number of people who have the plugin installed once it is in the directory will (hopefully) increase by magnitude(s).
I think I have a fix for this in 750a14d..e949610, although I only tried it with switching branches and not using the plugin updater. |
Thanks! This fix works well. There is currently nothing to test here using the plugin updater:
|
This PR restructures all PHP code from
index.php
intolib/*.php
files. (I am not sold on thelib/
name and open to suggestions there; I also consideredphp/*.php
but this seemed worse somehow.)This restructuring is first something we should do anyway (our
index.php
is getting quite long) and a first step towards addressing asset bundling for the plugin release process, as discussed at #953.In a follow-up PR, the next step for the plugin release process will be to allow the release version of the plugin to contain a different
index.php
file from what we run in development mode, which will change the behavior of the script + stylesheet bundling code.Beyond rearranging the PHP code into separate files, there are very few other changes here:
gutenberg_dir_path
andgutenberg_url
functions that callplugin_dir_path
andplugins_url
respectively with the appropriate arguments.phpcs
.