27. Tools: backups, migration, maintenance and duplicator

For developersVersion 1.0.0Last updated:

Three tools that replace separate plugins: backups and migration (27.1), Maintenance mode / Coming soon (27.2) and the content duplicator (27.3). They belong to the administrator and aren’t part of the package: the AI doesn’t configure them (see the chapter 25 blocks).

In this chapter

27.2 Maintenance mode and Coming soon

A Settings card (option builder_os_maintenance) puts the site in one of three modes: off, Coming soon or Maintenance. Visitors see a default screen with an editable title and message, or a chosen WordPress page (page_id). The indicated roles (by default administrator and editor, bypass_roles) and anyone who opens the secret preview link (?bos_preview=<llave>, which stores the bos_preview_access cookie for 48 hours) pass through without seeing anything. An administrator can see the screen with ?bos_maintenance_preview=1.

  • Headers.
    • Coming soon: 200, X-Robots-Tag: noindex, nofollow and <meta name="robots" content="noindex, nofollow"> on the default screen (the home page isn’t indexed).
    • Maintenance: 503, Retry-After: 3600, Cache-Control: no-store and also noindex.
  • Page cache.
    • The bos_preview_access cookie is in builder_os_page_cache_cookies: a request with that cookie is never served from the cache or stored in it.
    • While the mode is active, no page is stored in the cache (builder_os_page_cache_cacheable returns false, and the screen sends DONOTCACHEPAGE and Cache-Control: no-cache).
    • When the mode changes (from Settings or with any update_option), the page cache is cleared, even if automatic clearing is off.
  • Preview key. Builder_OS_Tools::settings() is read-only and generates nothing on each request. The key is created just once (ensure_key()) when the Settings card is opened or on save. With no stored key there’s no access through the secret link.

27.3 One-click duplicator

In the Pages, Posts, Theme templates (bos_template) and Popups (bos_popup) lists, the Duplicate row action appears. It creates a draft with the title «… (copy)», the same content, excerpt, parent and order, the terms of its taxonomies and the metadata (except locks, old dates and slugs, and the translation map), and notifies with a message on return. It requires permission to edit the original (edit_post) and an active license; the action carries a nonce per content item (admin-post.php?action=bos_duplicate_post).