Skip to content

Choose which post types publish to AT Protocol#41

Merged
kraftbj merged 3 commits intofix/cleanup-gate-splitfrom
add/post-type-support
Apr 29, 2026
Merged

Choose which post types publish to AT Protocol#41
kraftbj merged 3 commits intofix/cleanup-gate-splitfrom
add/post-type-support

Conversation

@pfefferle
Copy link
Copy Markdown
Member

Proposed changes

  • New Post types field in Settings → ATmosphere with a checkbox per public post type. Stored as atmosphere_support_post_types (default ['post']).
  • Plugins and themes can opt their custom post types in via the WordPress-canonical \add_post_type_support( 'book', 'atmosphere' ) — picked up automatically.
  • Replaces Backfill::syncable_post_types() with Atmosphere\Post_Types + bridge functions Atmosphere\get_supported_post_types() and Atmosphere\is_supported_post_type().
  • atmosphere_syncable_post_types filter preserved; now runs after the option and native opt-ins are merged so callers can add or remove from either source.

Other information

  • Have you written new tests for your changes, if applicable?

Testing instructions

  1. Visit Settings → ATmosphere. Confirm a new Post types field appears in the Publishing section with a checkbox per public post type. Posts is checked by default.
  2. Check Pages, save, edit any page. The ATmosphere meta box should appear.
  3. Uncheck everything, save, and confirm no meta box renders on any post-edit screen.
  4. In a small test plugin, add add_post_type_support( 'book', 'atmosphere' ); for a custom book CPT — confirm Atmosphere\get_supported_post_types() includes it even when the option is empty.
  5. composer lint and npm run env-test should pass.

@pfefferle pfefferle self-assigned this Apr 28, 2026
@github-actions github-actions Bot added [Feature] WP Admin Admin UI and settings [Tests] Includes Tests PR includes test changes labels Apr 28, 2026
@pfefferle pfefferle requested a review from Copilot April 28, 2026 16:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a configurable “supported post types” mechanism so ATmosphere publishing can be enabled per post type via Settings, WordPress-native add_post_type_support( ..., 'atmosphere' ), and the existing atmosphere_syncable_post_types filter.

Changes:

  • Introduces Atmosphere\Post_Types plus helper functions Atmosphere\get_supported_post_types() / Atmosphere\is_supported_post_type().
  • Adds a new settings option (atmosphere_support_post_types) and UI field (checkboxes for public post types).
  • Replaces uses of Backfill::syncable_post_types() with the new resolver and adds PHPUnit coverage.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/phpunit/tests/class-test-post-types.php Adds tests for option-driven, native-support, and filter-driven supported post types.
includes/wp-admin/class-admin.php Registers the new option and renders the settings UI; uses supported types for meta box registration.
includes/functions.php Adds bridge helper functions for supported post type queries.
includes/class-post-types.php Implements supported post type resolution + sanitization.
includes/class-backfill.php Switches backfill targeting to the new supported post types list.
includes/class-atmosphere.php Gates frontend link output, preview, and lifecycle hooks using is_supported_post_type().
.github/changelog/add-post-type-support Changelog entry describing the new capability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/wp-admin/class-admin.php
Comment thread includes/class-post-types.php
Comment thread includes/class-backfill.php
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/class-post-types.php Outdated
Comment thread includes/wp-admin/class-admin.php Outdated
Comment thread includes/class-backfill.php
Copy link
Copy Markdown
Contributor

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

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

Combined review comments from the full PR pass, including the FOSSE-specific concerns and the remaining existing review concerns.

Comment thread includes/class-atmosphere.php Outdated
Comment thread includes/class-atmosphere.php Outdated
Comment thread includes/wp-admin/class-admin.php Outdated
Comment thread includes/class-atmosphere.php Outdated
Comment thread includes/class-atmosphere.php Outdated
Comment thread includes/wp-admin/class-admin.php Outdated
Comment thread includes/class-post-types.php Outdated
Comment thread includes/class-backfill.php
@pfefferle
Copy link
Copy Markdown
Member Author

pfefferle commented Apr 29, 2026

@kraftbj it was not meant to fix what you fixed with your PR already, this was simply meant to extract the functionality to a dedicated class/function instead of a weird artifact that lives in the Backfill structure (which I am not even sure we need). I am happy to point the PR to your branch instead or directly work on your branch.

Adds an `atmosphere_support_post_types` setting with a checkbox UI in
the Publishing section, and exposes WordPress' canonical
`add_post_type_support($post_type, 'atmosphere')` opt-in for plugins
and themes. Replaces the misnamed `Backfill::syncable_post_types()`
with a small `Atmosphere\Post_Types` class plus
`get_supported_post_types()` / `is_supported_post_type()` bridge
functions. The `atmosphere_syncable_post_types` filter is preserved
and now runs after the option/native sources are merged so callers
can add or remove from either.
- Empty supported list short-circuits backfill count so an unconfigured
  site isn't queried with the default `post` fallback. Eligibility is
  also re-checked per post in the batch handler.
- `get_supported()` normalises the filter result: drops empties /
  non-strings, dedupes after the filter so callbacks can't surface
  duplicates.
- Settings UI now derives checkbox state from the saved option only;
  post types enabled via `add_post_type_support()` or the filter are
  noted under the label as "Enabled by another plugin or theme."
- Publish/update cron callbacks re-check is_supported_post_type so a
  user disabling a post type after queueing prevents the cron firing.
  Delete callback intentionally unchanged so cleanup still runs.
- Post_Types::sanitize uses sanitize_key, drops non-strings/empties,
  and dedupes so the saved option matches get_supported's canonical
  format.
- Backfill::handle_batch resolves get_supported_post_types once per
  batch instead of recomputing per ID.
- Settings UI now also notes saved post types whose effective state
  was removed by a filter, so the page doesn't claim a type publishes
  when runtime would skip it.
@pfefferle pfefferle force-pushed the add/post-type-support branch from 1c34027 to 0685c47 Compare April 29, 2026 16:07
@pfefferle pfefferle changed the base branch from trunk to fix/cleanup-gate-split April 29, 2026 16:07
@pfefferle
Copy link
Copy Markdown
Member Author

I rebased it to your pr.

@pfefferle pfefferle requested a review from kraftbj April 29, 2026 16:12
@kraftbj
Copy link
Copy Markdown
Contributor

kraftbj commented Apr 29, 2026

Verified 0685c47 against all eight unresolved review threads and resolved them. Summary of what I checked against the code at that SHA:

  • P1 cleanup must bypass current allowlist (both threads): on_before_delete() no longer gates on is_supported_post_type() and only checks for existing TIDs; on_status_change() restricts the support check to the publish/update branches and lets unpublish defer to TID metadata. PR 41 is rebased onto fix/cleanup-gate-split (merge-base matches that branch's head), so this depends on PR 38 landing first.
  • P2 cron publish should re-check support (both threads): register_async_hooks() re-checks is_supported_post_type( $post->post_type ) inside both the atmosphere_publish_post and atmosphere_update_post callbacks. The atmosphere_delete_post callback intentionally omits the check so cleanup keeps running.
  • P3 settings UI shows filtered-out types as enabled (both threads): render_support_post_types_field() now distinguishes $is_external and $is_filtered_out and renders "Disabled by another plugin or theme — this post type will not be published." for the saved-but-filtered case.
  • P3 normalize saved post type option: Post_Types::sanitize() drops non-strings, runs sanitize_key, filters empties, and dedupes via array_unique before intersecting against public post types.
  • P3 avoid resolving support once per backfill ID: Backfill::handle_batch() resolves get_supported_post_types() once before the loop and uses in_array( $post->post_type, $supported, true ) per ID.

All eight threads resolved; ready for formal approval.

@kraftbj kraftbj merged commit 47d0259 into fix/cleanup-gate-split Apr 29, 2026
10 checks passed
@kraftbj kraftbj deleted the add/post-type-support branch April 29, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] WP Admin Admin UI and settings [Tests] Includes Tests PR includes test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants