Skip to content

View config schema: centralize in PHP - #81169

Draft
oandregal wants to merge 2 commits into
trunkfrom
update/schema-from-php
Draft

View config schema: centralize in PHP#81169
oandregal wants to merge 2 commits into
trunkfrom
update/schema-from-php

Conversation

@oandregal

Copy link
Copy Markdown
Member

Alternative to #81168

What?

This PR centralizes the schema for the view config API into PHP. Then, everything is derived from it (docs, schema/json).

Why?

To have a single place to define the schema.

How?

  • Centralize the schema into PHP.
  • Generate the docs (view config reference) from the PHP schema.
  • Generate a JSON Scheam file to be stored under schemas/json from the PHP schema.

Testing Instructions

TBD

oandregal and others added 2 commits August 4, 2026 18:11
Adds property descriptions to the view config REST controller schema,
a PHP dump script that extracts the schema without a WordPress
runtime, and a docs generator (npm run docs:view-config-ref) that
fills the property tables in view-config-reference.md between
autogenerated tokens.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Moves the REST controller's item schema into
lib/compat/wordpress-7.1/view-config-schema.php, consumed
independently by the controller (require + memoize) and by the docs
dump script, which no longer needs to stub WP_REST_Controller or load
the controller class.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.81 MB

compressed-size-action

@oandregal oandregal changed the title Update/schema from php View config schema: centralize in PHP Aug 4, 2026
| Property | Description | Type |
| -------- | ----------- | ---- |
| layout | The default layout for the form fields. | `{ type: regular \| panel \| card \| row \| details, … }` |
| fields | The fields of the form, in display order. Each entry is a field id, or an object for further configuration. | `[ string \| { id, label, description, layout, children } ]` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vertical pipe char inside code tag is being escaped:

-| `[ string \| { id, label, description
+| `[ string | { id, label, description

Comment on lines +33 to +44
if ( ! function_exists( '__' ) ) {
/**
* Stub for the WordPress translation function: returns the text untranslated.
*
* @param string $text Text to translate.
* @param string $domain Text domain (unused).
* @return string The original text.
*/
function __( $text, $domain = 'default' ) {
return $text;
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The requisite here is that the PHP schema file remains as WordPress agnostic as possible. The __ function is used by it so property descriptions are picked up for translation, so we need to stub it. This requisite seems a bit fragile and disconnected (someone adding other functions in the file may discover this connection only when the build docs process fails).

async function main() {
let stdout;
try {
( { stdout } = await execa( 'php', [ DUMP_SCRIPT_PATH ] ) );

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This script requires the PHP binary on path to extract the schema (see dump-view-config-schema.php.

@oandregal

Copy link
Copy Markdown
Member Author

I'm favoring #81168 over this one.

@mcsf

mcsf commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

I'm favoring #81168 over this one.

It's not a strong opinion, but I agree with your take!

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.

2 participants