Since 1.6.0 an enquiry’s page shows the enquirer’s details (avatar linked to their BuddyPress profile, the date the enquiry was created, a contact card link and a Text link) with a block, not by adding them to the enquiry’s content. Before 1.6.0 a the_content filter prepended them, so they also appeared wherever the content was used: REST, feeds, the Markdown version of the page and MCP get-post results. The code is in includes/lh-crm-enquiry-template-class.php (LH_Crm_enquiry_template_class).
Enquiry Details block
lh-crm/enquiry-details is a dynamic block in the Theme category that uses the postId and postType context. It renders nothing unless the post is an enquiry and the current user can view enquiries (edit_others_posts). The Contact card link comes from LH Contacts (LH Vcard before 1.6.6) and only appears for users with LH Contacts’ view capability, since its signed URL can be redeemed by anyone holding it for a day; the Text link appears when LH Profile Page holds a phone number for the enquirer. The output is a div.lh_crm-enquiry-details.
Single enquiry template
The plugin registers lh-crm//single-lh_crm_enquiry_post with register_block_template() on every site, since any site can take enquiries: the theme’s header part, Post Title, Enquiry Details, Post Content, comments with the comment form, and the theme’s footer part, inside a constrained main.lh_crm-enquiry group. A theme’s own single-lh_crm_enquiry_post template, or a copy edited in the Site Editor, takes precedence over it. It is used by block and hybrid themes; classic themes never render block templates.
Classic themes
On a classic theme, LH_Crm_enquiry_post_type_class::add_relevant_info_to_enquiry() still prepends the same details to the content, but only for the queried enquiry, only while the page body is being built (in_body()), only for users who can view enquiries, and only once. It skips any enquiry the block has already rendered for in the request (mark_details_rendered() and is_details_rendered(), the pattern lh-portfolio uses for its entry meta), so a template that contains the block never shows the details twice. Both paths build the details with LH_Crm_enquiry_template_class::return_details_html(). Feeds are not filtered.
Marking the enquiry’s BuddyPress notification as read when staff view it is unchanged: it runs on wp_footer, which fires for block templates too.
Filters
| Hook | Arguments | Effect |
|---|---|---|
lh_crm_return_enquiry_details_html |
$html, $post |
The details markup (without its wrapper) for both the block and the classic-theme filter. Return an empty string to show nothing. |
lh_crm_return_enquiry_template_content |
$content |
The block markup of the Single enquiry template. |
Method names in component classes
Every component class extends LH_Crm_plugin, so a component method with the same name as a main-class method overrides it. PHP 8 treats an override whose signature is incompatible (for example one with more required parameters) as a fatal error when the class is declared, which happens on every request. 1.6.0 shipped the block’s render callback as render_block( $attributes, $content, $block ), clashing with the contact form block’s LH_Crm_plugin::render_block( $attributes ), and took every site on the network down until the plugin was deactivated. 1.6.1 renamed the methods to register_details_block() and render_details_block(). Give component methods names of their own. php -l does not catch this, since it checks one file without its parent class.
History
- 1.5.20 set up the enquiry details, the contact form’s thank-you message and notification marking before a block template renders, so they worked on block-template pages.
- 1.6.0 moved the details into the Enquiry Details block and Single enquiry template, kept the content filter as the classic-theme fallback, removed
partials/enquiry-template.php(which replaced the filtered content with the unfiltered post content), removed a strayremove_filter()call in that filter, and madeplugin_version()read the Version header. - 1.6.1 fixed the 1.6.0 fatal error described above.
- 1.6.6 took the contact card link from LH Contacts instead of LH Vcard.