CNHSA Content Federation

This article documents how content gets published from the CNO site to the CNHSA site. It is quite technical.

Hey, look! Pictures!

Technical diagrams can be seen in the CNO Site Figma Folder. This is a multi-page Figjam that leans heavily on UML-style Sequence Diagrams (watch a quick Udemy lecture here).

Plugins Overview

  • CNO to CNHSA Plugin
  • CNHSA to CNO Plugin

Both share the following conventions / architecture:

Terms

  • inc/WP has files (and subdirectories) related to WordPress actions (hooks, cron events, post/payload creation, etc)
  • inc/Transport is for files related to sending/receiving data over HTTP
    • HTTP_Gateway class is for sending (outbound) data
    • Rest_Router class is for receiving (inbound) data

General Overview:

  • inc/ is where PHP lives
  • tests/ is where the PHPUnit tests live
  • src/ is where the React code (for Admin Screen) lives

Plugin Lifecycle

*-content-federation.php is required by WordPress. It instantiates a new ChoctawNation\*_Federation\Plugin_Loader class and wires its methods to the necessary WordPress hooks:

  • register_activation_hook
    • On activate, the plugin tries to grab any stored options from the DB.
  • register_uninstsall_hook
    • On uninstall, the plugin will delete any stored options.
  • add_action( 'plugins_loaded', array( $plugin, 'load_plugin' ) )

load_plugin is the hook/callback pair that does all the heavy lifting:

  1. Registers rest routes
  2. Loads admin screen for configuring federation
  3. Wires up cron hook callbacks and other business
    • This is where all the necessary classes and their dependencies are created, injected and called.

How it works: CNO to CNHSA

Traffic scope: CNO Services & Locations posts -> CNHSA Services & [Clinic/Additional-Facility] posts

Outbound traffic

When a user updates a services/locations post, the save_post_{$post_type} hook is fired by WordPress and a cron event is scheduled to run. This allows content editors to move on with their life and not have to wait for content to get federated over to the CNHSA site.

Why a cron event?[Click to expand]

Without this step, saving a post would have to wait until federation was complete before the post was saved.

Posts are linked via id stored in post_meta (not necessarily registered as an ACF field). If an ID doesn’t exist, chances are you’re creating a new resource. If it does exist, you’re updating a resource.

When the cron event fires, the plugin:

  1. Builds the payload
  2. Sends the payload (Transport\Http_Gateway)
  3. Sends emails on error
  4. Updates the post_meta with the returned CNHSA post id

Inbound traffic: CNHSA

  1. Post is created
  2. ACF fields are updated
  3. canonical tag is updated
  4. Successful id is returned
  5. Emails on error

How it works: CNHSA to CNO

Basically the same as above, but instead of going ACF to ACF, we’re going Blocks to ACF, so the payload is parsed a bit differently.

Also, right now [03/04/2026] this direction is only for the “CNHSA Eligibility Guidelines”

See something inaccurate?