Ship a Panel as Code — Tutorials — Pure Metafields

Docs/Tutorials/Ship a Panel as Code

Ship a Panel as Code

Turn a panel you built visually into a plain PHP file you can commit to your theme or plugin — for when a database row isn't the right way to ship a release.

  1. Open the panel

    In the Option Builder, open the panel you want to ship.

  2. Bake to PHP

    Choose Bake to PHP in the top toolbar. The generated file uses TPMeta_Options::set_args() / set_section() exactly as a hand-written panel would (see Developer Guide → Creating Field Groups), preserving switch data_type, image return_format, dimension slider bounds, post-select query config and repeater sub-fields.

  3. Commit it

    Copy the generated code into your theme's functions.php or a dedicated options file, and commit it to version control. It has no dependency on the builder — it keeps working even if the builder is later deactivated.

Bake vs. Export/Import

Bake is for code you ship in a theme/plugin release — structure only, no saved values, safe to commit. Export/Import (see Move Data Between Sites) moves a live configuration, including saved values, between running sites as JSON.