Skip to content

Added: HTML custom field editor#2721

Open
RabbiIslamRony wants to merge 2 commits intosovware:developmentfrom
RabbiIslamRony:add/html-block
Open

Added: HTML custom field editor#2721
RabbiIslamRony wants to merge 2 commits intosovware:developmentfrom
RabbiIslamRony:add/html-block

Conversation

@RabbiIslamRony
Copy link
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Text changes
  • Other

Description

This PR introduces and stabilizes HTML custom field behavior across Add Listing, Edit Listing, and Single Listing render paths.

It fixes an issue in the admin Edit Listing screen where the HTML editor initially loaded and then disappeared due to automatic listing field re-rendering.

It improves HTML content consistency between editor and frontend by refining sanitization and rendering flow, preserving formatting-related attributes, and ensuring media support within the HTML editor context.

Template files were also cleaned by removing unnecessary inline CSS and redundant logic. https://prnt.sc/u0EnQRCyynu-

Summary

  • Introduced and stabilized HTML custom field behavior across Add Listing, Edit Listing, and Single Listing.
  • Fixed editor disappearing issue in Edit Listing caused by unintended re-render.
  • Improved frontend rendering consistency for formatted HTML content.
  • Ensured media support in HTML editor context.
  • Cleaned up template structure and removed inline CSS.

Key Changes

templates/listing-form/custom-fields/html.php

  • Improved editor initialization and value handling.
  • Ensured media button compatibility in add/edit contexts.
  • Removed unnecessary inline CSS for cleaner structure.

templates/single/custom-fields/html.php

  • Updated output pipeline to preserve paragraph spacing and alignment on frontend.
  • Simplified duplicate sanitization flow.

includes/fields/class-directorist-html-field.php

  • Expanded safe allowlist support for formatting and alignment attributes (class, style, id) on common content tags.

assets/src/js/admin/components/block-3.js

  • Prevented unnecessary initial admin_listing_form() re-render on edit screen when fields already exist.

assets/js/admin-main.js

  • Synced compiled admin logic with the same edit-screen re-render guard.

includes/asset-loader/init.php

  • Ensured media assets are properly loaded for HTML editor usage.

Why This Change

Previously, HTML field content behaved inconsistently between the editor and frontend. The Edit Listing screen also experienced editor instability due to a second dynamic field render.

This update ensures predictable and consistent HTML field behavior without affecting existing field types.

Test Plan

  • Add a new HTML custom field from the builder and save.
  • In Add Listing, input formatted content (paragraphs, aligned image, iframe embed) and save.
  • Verify Single Listing output preserves paragraph spacing and alignment correctly.
  • Open the same listing in Edit Listing and confirm the editor remains visible (no load-and-disappear issue).
  • Confirm existing non-HTML custom fields still render and save normally.
  • Confirm media insertion works inside the HTML editor.

…nd formatting

Add full HTML custom-field editor support with media button, improve admin edit stability by preventing unnecessary field re-render on initial load, and align single-listing HTML rendering with editor formatting. Also streamline templates by removing inline CSS and redundant sanitization paths while keeping safe allowlisted output.
@RabbiIslamRony RabbiIslamRony added this to the v8.6 milestone Feb 26, 2026
@RabbiIslamRony RabbiIslamRony self-assigned this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant