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

Consistently name properties and keep structure as flat as possible #5

Closed
wpscholar opened this issue Aug 16, 2023 · 1 comment
Closed
Assignees

Comments

@wpscholar
Copy link
Member

This is the current state of our prepareRuntime() method: https://github.com/newfold-labs/wp-module-runtime/blob/trunk/includes/Runtime.php#L39-L52

There are a few things missing:

  • restUrl
  • restNonce

Given that all these properties are going to be used in JavaScript, we should use camel-case as the naming convention:

  • Rename admin_url to adminUrl (we can keep the old for backward compatibility until references are all removed)
  • Rename base_url to homeUrl (this is what it is actually referencing, but we shouldn't append the index.php part)
  • Rename site.url to siteUrl

We should also strive to flatten the structure where possible. For example, we should remove the sdk property and just let its contents live at the top level. Additionally, site.title should just become siteTitle.

It is okay to nest things, but only where it makes logical sense and doesn't over-complicate data fetching. For example, having a capabilities property that contains an object of capability mappings is fine.

@aulisius
Copy link
Contributor

Closed by #7

@aratidgr8 aratidgr8 mentioned this issue Apr 18, 2024
8 tasks
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

No branches or pull requests

2 participants