Skip to content

SEO: add Organization schema settings (option, REST route, and form)#50111

Open
gmjuhasz wants to merge 6 commits into
trunkfrom
jetpack-1779-organization-schema-settings
Open

SEO: add Organization schema settings (option, REST route, and form)#50111
gmjuhasz wants to merge 6 commits into
trunkfrom
jetpack-1779-organization-schema-settings

Conversation

@gmjuhasz

@gmjuhasz gmjuhasz commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

  • New normalized, versioned option jetpack_seo_schema_settings_v1, shaped as a container keyed by schema type (only organization today).
  • Schema_Settings store: 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 for sameAs via wp_http_validate_url + http/https-only filtering so stored profiles match emitted schema output.
  • Schema_Settings_Controller: a dedicated jetpack/v4/seo/schema-settings route (GET + write, manage_options), deliberately not on /jetpack/v4/settings because that endpoint rejects the nested container.
  • Schema_Builder feeds stored settings into the Organization node, so configured sameAs, contact email, and overrides appear in the emitted @graph.

Client

  • useSchemaSettings hook seeds from the Settings bootstrap when present (fallback GET when absent) and saves through the schema route only.
  • Organization form: name, description, repeatable social-profile (sameAs) URLs, and optional contact email.
  • Name / description use placeholders, not pre-filled values — the field shows Site Title / Tagline as a grey placeholder and stays empty unless overridden. Clearing a field and saving resets it to tracking site identity.
  • Social profile validation catches malformed, scheme-less, and duplicate URLs before save. Empty rows are ignored and are not saved.
  • Header count badge renders from bootstrapped settings: "Not set" when nothing is configured, otherwise "X of 4 set" (name and description count as set when overridden here or present in site settings; sameAs when 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 need composer dump-autoload in projects/plugins/jetpack before manual plugin testing.

  1. Go to Jetpack -> SEO -> Settings and open the Schema card. The header shows a count badge immediately (for example, "2 of 4 set" if the site has a Site Title + Tagline).
  2. Name / Description: empty with Site Title / Tagline shown as placeholders. Leave blank -> Organization schema uses site identity. Type a value -> it overrides. Clear it and save -> it tracks site identity again.
  3. Social profiles: add profile rows. Empty rows do not enable Save and are not saved. Malformed, scheme-less, or duplicate URLs show inline errors and disable Save. Valid full URLs such as https://bsky.app/profile/example.com save normally.
  4. Remove profile: remove a row and confirm the button stays aligned with the input row, including when another row has an error message.
  5. Contact email: optionally enter a public contact email.
  6. Save, then view-source a published post (or run it through the Rich Results Test): the Organization node's sameAs, contact email, and overrides appear in the @graph, and the badge updates.
CleanShot 2026-07-01 at 14 56 51@2x

Automated checks run:

  • pnpm jetpack test php packages/seo
  • pnpm --dir projects/packages/seo test --runInBand
  • pnpm --dir projects/packages/seo typecheck
  • pnpm jetpack phan packages/seo
  • pnpm jetpack build packages/seo
  • git diff --check
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the jetpack-1779-organization-schema-settings branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack jetpack-1779-organization-schema-settings

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 1, 2026
@jp-launch-control

jp-launch-control Bot commented Jul 1, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/seo/src/class-initializer.php 146/252 (57.94%) 0.34% 0 💚
projects/packages/seo/src/class-organization-schema-node.php 48/48 (100.00%) 1.56% -1 💚

2 files are newly checked for coverage.

File Coverage
projects/packages/seo/src/class-schema-settings.php 60/63 (95.24%) 💚
projects/packages/seo/src/class-schema-settings-controller.php 21/22 (95.45%) 💚

Full summary · PHP report · JS report

Base automatically changed from jetpack-1779-schema-site-level-organization-node-multi-node-graph to trunk July 1, 2026 09:42
@gmjuhasz gmjuhasz force-pushed the jetpack-1779-organization-schema-settings branch from e8e08bb to 7b22bdd Compare July 1, 2026 10:53
@gmjuhasz gmjuhasz self-assigned this Jul 1, 2026
@gmjuhasz gmjuhasz added the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Jul 1, 2026
@gmjuhasz gmjuhasz requested a review from Copilot July 1, 2026 12:18

Copilot AI left a comment

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.

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) and Schema_Settings_Controller (jetpack/v4/seo/schema-settings) and wires settings into schema emission.
  • Adds the “Organization / Business info” form and useSchemaSettings hook 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).
Comment thread projects/packages/seo/src/class-schema-settings-controller.php
@gmjuhasz gmjuhasz marked this pull request as ready for review July 1, 2026 12:56
@gmjuhasz gmjuhasz requested review from a team and angelablake July 1, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Seo [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] Needs Team Review Obsolete. Use Needs Review instead. [Tests] Includes Tests

2 participants