Digital Sovereignty for everyone

Menus, template parts and synced patterns

Since 1.20.0, create-post and update-post can write a block theme’s menus (wp_navigation), template parts (wp_template_part) and synced patterns (wp_block). Before that both abilities were hard-coded to drafts, which left no way to edit a block theme’s menus or header from MCP: these types do nothing until they are published.

Per-type rules

What each ability may do is set per post type by LH_MCP_General_Abilities_Post_Type_Rules, filterable through lh_mcp_general_abilities_post_type_rules. A type with no rule cannot be written at all. Types added through the older lh_mcp_general_abilities_return_writable_post_types filter still work and get the default rule.

Type create-post update-post Extra
post, page, others draft, pending draft, pending Default rule
wp_navigation draft, publish draft, publish Fallback guard; navigation blocks only
wp_block draft, publish draft
wp_template_part draft, publish draft Override guard; slug required

The design types need edit_theme_options, and publishing anything needs the type’s publish_posts. Menu content may only hold navigation-link, navigation-submenu, page-list and home-link blocks. A published menu can be revised in place; a published template part or synced pattern cannot, because the change would be live everywhere it is used. Live template parts go through lh-mcp-site-design’s propose, preview and apply flow instead.

Guards

A guard runs only when a write would leave the post published, and a refusal writes nothing.

  • Navigation fallback. A Navigation block with no menu of its own, or one pointing at a menu that is missing or not published, renders the most recently published menu. Publishing a new menu would take over all such blocks silently, so it is refused while any rendered template or template part has one. A block pointing at the menu being published is not counted, and editing a menu that is already published is always allowed. Blocks with their own inline links, and blocks in synced patterns or post content, are not counted.
  • Template part override. Publishing a template part whose slug the active theme (or its parent) ships is refused, because it would replace the theme’s part live. Create it under a new slug and point the template at it. create-post also refuses a slug the theme already has in the database, and assigns the active theme and the chosen area to every part it creates.

update-post refuses a date change on anything published or being published, since on a menu the date decides which menu is the fallback.

Audit trail

Every write to a design type is recorded in LH Audit Trail as site_design.post_saved (staff only, kept 730 days), with the action, statuses before and after, the fields changed and replaced_revision_id: a revision holding the content as it was before the write, saved first if one did not already exist. The ability returns the entry as audit_entry_id.

If you like this plugin please consider making a donation to further development

Install LHero.org

lhero.org

Open it straight from your home screen, full screen and quicker to load.

  1. Tap the Share button . If you cannot see it, tap ••• first.
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add.
  1. Tap the browser menu â‹®.
  2. Tap Install app or Add to Home screen.
  1. In the menu bar, choose File, then Add to Dock.

Use your browser's menu to install this site or add it to your home screen.