Developer documentation for the field renderer of the WPResidence real estate CRM. Lives in libs/field-renderer.php and libs/metaboxes.php.
Field Type Registry
Supported types:
input— short texttextarea— long textpicklist— dropdown from a settings keydate— formatted viaget_option('date_format')number— locale-formatted vianumber_format_i18n()taxonomy— references a taxonomy term by ID, displays the term namepost_type— references another post by ID, displays title + linkcontent— read-only HTML (legacy lead message display)
Field Registries
Each CPT/entity defines its fields as an array:
wpestate_return_contact_post_array()— 31+ contact fields.wpestate_leads_post_array()— 6 lead fields.
Field Definition Shape
[
'type' => 'input' | 'textarea' | 'picklist' | ...,
'label' => 'Human label',
'db_col' => 'database_column',
'section' => 'personal_info' | 'contact_info' | ...,
'source' => 'settings_picklist_key' | taxonomy slug | post type slug, // optional
'required' => true | false,
'length' => 'full', // optional — 100% width on the form grid
'placeholder' => '...',
'editable' => true | false,
]
Contact Form Sections
Section keys: personal_info, contact_info, address, social_profiles, lead_info, buyer_preferences, notes.
The form template loops the registry grouped by section, rendering section headers and fields in order.
Renderers
| Function | Mode |
|---|---|
wpestate_crm_show_details() |
Editable — renders inputs |
wpestate_crm_show_details_readonly() |
Read-only — renders formatted display HTML |
Editable Field Helpers (libs/metaboxes.php)
wpestate_crm_return_input_metabox()wpestate_crm_return_textarea_metabox()wpestate_crm_return_picklist_metabox()wpestate_crm_return_post_type_items()— select dropdown populated from a post type query (e.g., estate_agent).wpestate_crm_return_taxonomy_metabox()
Read-Only Formatting
- Empty values: rendered as the setting
crm_empty_value_text(default —). - Numbers:
number_format_i18n(). - Dates:
date_i18n(get_option('date_format'), $timestamp). - Taxonomy:
get_term()and display the term name. - Post type:
get_the_title()+get_permalink()hyperlink.
Picklist Source Resolution
For a field with type=picklist, source='crm_lead_sources', the renderer calls wpestate_crm_get_setting('crm_lead_sources') and splits on comma. Add options by adding values to the settings string — no code change required.
Adding a Brand-New Field
- Add the column to the table schema in
libs/db-setup.phpviadbDelta-compatible SQL (or add it from a child plugin’s own activation routine). - Bump
wpestate_crm_db_versionso the activation routine re-runsdbDelta. - Add the field definition to the appropriate registry array (
wpestate_return_contact_post_array()or equivalent) — ideally fork via a filter hook in a child plugin rather than editing the CRM plugin. - If the field needs a new picklist, add a default seed value in
libs/settings.php.
Extending Without Editing the Plugin
The registries are plain function calls, so override is awkward. Pragmatic options:
- Store extended data as JSON in an existing
_metalongtext column rather than adding real columns — avoids schema changes. - Render extra fields on the detail page via a theme template override that wraps the CRM template.
- If you must change the registry, fork the specific function in a
wpestate-crm-extensionsplugin that loads before the main CRM.
Non-Latin Input
All text-type inputs go through sanitize_text_field() or sanitize_textarea_field(), both UTF-8 safe. Picklist values are also stored as plain text and display any script correctly.