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

Improve core/latestposts block PHP code #1095

Merged
merged 1 commit into from
Jun 9, 2017
Merged

Conversation

nylen
Copy link
Member

@nylen nylen commented Jun 9, 2017

Addresses https://github.com/WordPress/gutenberg/pull/870/files#r120894090 and https://github.com/WordPress/gutenberg/pull/870/files#r121213401:

  • Removes unneeded PHP constants.
  • Simplifies server-side block registration logic. Currently there should be no need to defer this until init, at least in our main plugin.
  • Moves the new PHP code for this block under the lib/ directory so that it will be scanned by phpcs (also broken currently, another PR coming up for this).
  • Adds the new PHP code to the plugin zip. This fixes npm run package-plugin - currently it generates broken builds.

Placing PHP code inline with its block code in the blocks/library directory makes these last two steps in particular a good bit more difficult. I think all PHP code should live under lib/ and all JavaScript code should live elsewhere (under the already-defined Webpack entry points); given that we have to do path manipulation every time we mix the two, it doesn't seem like a good idea.

@nylen nylen requested review from aduth and lamosty June 9, 2017 20:31
Copy link
Member

@lamosty lamosty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

@nylen nylen merged commit 630ff85 into master Jun 9, 2017
@nylen nylen deleted the fix/latest-posts-php branch June 9, 2017 20:52
@nylen
Copy link
Member Author

nylen commented Jun 9, 2017

No problem. I created #1097 to discuss the server-side initialization further.

@westonruter
Copy link
Member

@nylen I think the PHP logic for blocks should be placed in the same directory as the JS logic. I've proposed this in #2014. By keeping all of the related logic for a block in the same directory, it will be easier to locate the relevant files to edit when hacking.

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.

3 participants