Plugin Architecture — Developer Guide — Pure Metafields

Docs/Developer Guide/Plugin Architecture

Plugin Architecture

Where things live on disk, and which class does what. Useful when you need to trace a behavior back to its source, or decide where new code belongs.

Folder layout

Directory tree
pure-metafields/
├── pure-metafields.php          // bootstrap: TPMETA_VERSION / TPMETA_PATH / TPMETA_URL
├── includes/                    // activator, deactivator, loader, shared helpers
├── assets/                      // shared CSS/JS (TPMeta_Assets enqueues them)
├── metaboxes/
│   ├── class-metabox.php        // metabox registration + save
│   ├── functions.php            // tpmeta_field(), tpmeta_get_option(), image/gallery helpers
│   └── fields/                  // one PHP template per field type
├── options/
│   ├── class-tpmeta-options.php        // TPMeta_Options facade
│   ├── class-tpmeta-options-store.php  // persistence + tpmeta_get_repeater_rows()
│   ├── class-tpmeta-customizer.php     // mirrors panels into WP Customizer
│   ├── customizer-fields/              // complex field types in the Customizer sidebar
│   └── builder/                        // visual Option Builder
│       ├── class-tpmeta-builder.php
│       ├── class-tpmeta-builder-store.php    // CRUD for panel JSON in wp_options
│       ├── class-tpmeta-builder-loader.php   // JSON → TPMeta_Options registry
│       └── class-tpmeta-builder-codegen.php  // Bake to PHP
├── metafields-builder/          // visual Meta Builder (separate from the Option Builder)
├── post-types/                  // visual Post Type Builder
├── taxonomies/                  // visual Taxonomy Builder
└── export-import/               // bulk JSON export/import

Data storage

All option panel values are stored as WordPress theme_mods. All metabox values are stored as post_meta. See Introduction → How the plugin works for why that split exists.

Key classes by subsystem

SubsystemClassRole
Metaboxestpmeta_meta_boxRegisters metaboxes from the tp_meta_boxes filter, renders and saves fields.
TPMeta_Metabox_Generic_OutputShared field output rendering.
OptionsTPMeta_OptionsStatic facade: set_args(), set_section(), get_fields()
TPMeta_Options_Store / TPMeta_Options_Render / TPMeta_Options_AjaxPersistence, rendering and AJAX save handling.
CustomizerTPMeta_Customizer, TPMeta_Customize_Field_Control, TPMeta_Customize_TinyMCE_ControlMirrors option panels into Appearance → Customize.
Option BuilderTPMeta_BuilderAdmin UI for the visual builder.
TPMeta_Builder_Store / TPMeta_Builder_LoaderCRUD for panel JSON; loads JSON into the TPMeta_Options registry.
TPMeta_Builder_CodegenBake to PHP.
Meta BuilderTPMeta_Metafields_Builder, _Store, _Loader, _CodegenVisual metabox builder (mirrors the Option Builder's structure).
Post TypesTPMeta_Post_Types_Page, _Store, _LoaderVisual custom post type registration.
TaxonomiesTPMeta_Taxonomies_Page, _Store, _LoaderVisual custom taxonomy registration.
Export/ImportTPMeta_Export_ImportBulk JSON export/import across all data types.
Full class list

Every class in the plugin, one line each: Reference → Classes.