SEO: add Organization schema settings (option, REST route, and form)#50111
SEO: add Organization schema settings (option, REST route, and form)#50111gmjuhasz wants to merge 6 commits into
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 2 files.
2 files are newly checked for coverage.
|
e8e08bb to
7b22bdd
Compare
There was a problem hiding this comment.
Pull request overview
Adds end-to-end support for site-level Organization schema settings in the Jetpack SEO package: a versioned option store + dedicated REST route on the server, and a settings UI (with persistence) on the client, with saved values flowing into emitted JSON-LD.
Changes:
- Introduces
Schema_Settings(normalized option + sanitization + defaults) andSchema_Settings_Controller(jetpack/v4/seo/schema-settings) and wires settings into schema emission. - Adds the “Organization / Business info” form and
useSchemaSettingshook to fetch/save via the schema-settings route, plus header badge (“Not set” / “X of 4 set”). - Expands PHP/JS tests and fixtures to cover storage, REST, UI behavior, and payload handling.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/seo/tests/php/SchemaSettingsTest.php | Adds unit coverage for defaults, sanitization, persistence, and effective fallback behavior. |
| projects/packages/seo/tests/php/SchemaSettingsControllerTest.php | Adds REST-route registration/read/write tests for schema settings. |
| projects/packages/seo/tests/php/SchemaBuilderTest.php | Adds end-to-end assertion that saved schema settings appear in emitted Organization JSON-LD. |
| projects/packages/seo/tests/php/OrganizationSchemaNodeTest.php | Updates tests to rely on the new shared URL sanitization behavior. |
| projects/packages/seo/tests/php/InitializerTest.php | Ensures settings bootstrap includes schema settings payload. |
| projects/packages/seo/src/class-schema-settings.php | Implements the option-backed schema settings store (defaults, sanitization, effective getters). |
| projects/packages/seo/src/class-schema-settings-controller.php | Implements dedicated REST controller for schema settings (GET + write). |
| projects/packages/seo/src/class-schema-builder.php | Feeds effective Organization settings into Organization schema node build. |
| projects/packages/seo/src/class-organization-schema-node.php | Switches sameAs sanitization to shared store logic. |
| projects/packages/seo/src/class-initializer.php | Registers schema settings route and bootstraps schema settings into Settings payload. |
| projects/packages/seo/changelog/add-seo-schema-organization-settings | Adds changelog entry for new Organization schema settings UI + persistence. |
| projects/packages/seo/_inc/screens/settings/test/schema-card.test.tsx | Updates Schema card tests to cover new form, badge counts, and validation behavior. |
| projects/packages/seo/_inc/screens/settings/style.scss | Adds styling for schema form labels and social-profile row layout/error styling. |
| projects/packages/seo/_inc/screens/settings/schema-settings/organization-business-section.tsx | Adds Organization / Business info form UI (name/description, sameAs repeater, email, Save). |
| projects/packages/seo/_inc/screens/settings/schema-card.tsx | Wires Schema card to hook + renders Organization form + badge count. |
| projects/packages/seo/_inc/screens/settings/index.tsx | Passes schema bootstrap + onSave handler into SchemaCard. |
| projects/packages/seo/_inc/data/use-settings.ts | Adds setSchemaSettings to update saved snapshot when schema saves via separate route. |
| projects/packages/seo/_inc/data/use-schema-settings.ts | Adds hook to manage schema settings state + persistence via schema-settings REST route. |
| projects/packages/seo/_inc/data/test/use-settings.test.ts | Tests that schema saves update baseline snapshot without triggering /jetpack/v4/settings writes. |
| projects/packages/seo/_inc/data/test/use-schema-settings.test.ts | Adds hook tests for dirty tracking, sanitizing sameAs, and POSTing to schema-settings endpoint. |
| projects/packages/seo/_inc/data/test/fixtures/store-fixtures.ts | Adds seeded schema fixture used across store-related tests. |
| projects/packages/seo/_inc/data/test/build-payload.test.ts | Verifies schema settings are ignored by the main settings payload builder (saved elsewhere). |
| projects/packages/seo/_inc/data/settings-types.ts | Extends settings response type to include bootstrapped schema settings. |
| projects/packages/seo/_inc/data/schema-settings-utils.ts | Adds client-side URL normalization/dedup helpers for sameAs. |
| projects/packages/seo/_inc/data/schema-settings-types.ts | Defines TS types for schema settings (organization overrides + placeholder defaults). |
Part of JETPACK-1779
Adds site-level Organization schema settings: a package-owned settings store + REST route, and the "Organization / Business info" form in the Schema settings card. Saved values flow into the JSON-LD the front end emits.
The original stacked base (#50080) is merged; this PR now targets
trunk.Proposed changes
Server
jetpack_seo_schema_settings_v1, shaped as a container keyed by schema type (onlyorganizationtoday).Schema_Settingsstore: site-identity-seeded defaults (Site Title / Tagline, computed live so they don't drift), per-field fallback for the effective values the node reads, and WordPress-core URL sanitization forsameAsviawp_http_validate_url+ http/https-only filtering so stored profiles match emitted schema output.Schema_Settings_Controller: a dedicatedjetpack/v4/seo/schema-settingsroute (GET + write,manage_options), deliberately not on/jetpack/v4/settingsbecause that endpoint rejects the nested container.Schema_Builderfeeds stored settings into the Organization node, so configuredsameAs, contact email, and overrides appear in the emitted@graph.Client
useSchemaSettingshook seeds from the Settings bootstrap when present (fallback GET when absent) and saves through the schema route only.sameAs) URLs, and optional contact email.sameAswhen it has a profile; email when filled).Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Behind the SEO experience flag + module:
add_filter( 'rsm_jetpack_seo', '__return_true' )and the SEO Tools module active. New PHP classes may needcomposer dump-autoloadinprojects/plugins/jetpackbefore manual plugin testing.https://bsky.app/profile/example.comsave normally.sameAs, contact email, and overrides appear in the@graph, and the badge updates.Automated checks run:
pnpm jetpack test php packages/seopnpm --dir projects/packages/seo test --runInBandpnpm --dir projects/packages/seo typecheckpnpm jetpack phan packages/seopnpm jetpack build packages/seogit diff --check