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
| Subsystem | Class | Role |
|---|---|---|
| Metaboxes | tpmeta_meta_box | Registers metaboxes from the tp_meta_boxes filter, renders and saves fields. |
TPMeta_Metabox_Generic_Output | Shared field output rendering. | |
| Options | TPMeta_Options | Static facade: set_args(), set_section(), get_fields()… |
TPMeta_Options_Store / TPMeta_Options_Render / TPMeta_Options_Ajax | Persistence, rendering and AJAX save handling. | |
| Customizer | TPMeta_Customizer, TPMeta_Customize_Field_Control, TPMeta_Customize_TinyMCE_Control | Mirrors option panels into Appearance → Customize. |
| Option Builder | TPMeta_Builder | Admin UI for the visual builder. |
TPMeta_Builder_Store / TPMeta_Builder_Loader | CRUD for panel JSON; loads JSON into the TPMeta_Options registry. | |
TPMeta_Builder_Codegen | Bake to PHP. | |
| Meta Builder | TPMeta_Metafields_Builder, _Store, _Loader, _Codegen | Visual metabox builder (mirrors the Option Builder's structure). |
| Post Types | TPMeta_Post_Types_Page, _Store, _Loader | Visual custom post type registration. |
| Taxonomies | TPMeta_Taxonomies_Page, _Store, _Loader | Visual custom taxonomy registration. |
| Export/Import | TPMeta_Export_Import | Bulk JSON export/import across all data types. |
Full class list
Every class in the plugin, one line each: Reference → Classes.