NX Bar: show the actual Elementor design in the admin Design preview#129
Open
AmitPaul-akp wants to merge 1 commit into
Open
Conversation
The admin Design preview (top PREVIEW pane + THEMES → Custom card) showed a
static starter-theme thumbnail keyed on `elementor_bar_theme` instead of the
Elementor-built design. The design was saved correctly and rendered fine on the
frontend; only the admin preview was wrong.
- PressBar: add `render_elementor_bar_preview()` (template_redirect, served at
`?nx_bar_preview={id}&_wpnonce=`, nonce `nx_bar_preview` + cap
`edit_notificationx`). It renders the same `get_builder_content_for_display()`
as the live bar, but prints only Elementor stylesheets and no scripts /
wp_head()/wp_footer() — so the preview shows the bar and nothing else (no admin
toolbar, no chat widgets, no other notifications).
- PostType: localize site `home` URL + `bar_preview_nonce` for the iframe URL.
- Admin source (PressbarAdminPreview.jsx, NxBarPresets.jsx): render an <iframe>
to the preview endpoint for Elementor bars instead of the static <img>.
Desktop/tablet/phone tabs drive the iframe width (real responsive); height
auto-fits (collapse-then-measure, no blank space when switching devices).
Gutenberg/preset previews are unchanged.
Source-only change; built `assets/admin/js/admin.js` is regenerated at release
per the repo's "npm build" convention.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an NX Bar (Notification Bar / PressBar) is designed with Edit With Elementor, the admin Design tab never showed the Elementor-built design. Both the top PREVIEW pane and the THEMES → Custom card kept showing a static starter-theme thumbnail (
bar-elementor/{elementor_bar_theme}.jpg) keyed on the theme name, not on the Elementor content.The design itself is fine — it's stored as
elementor_id→ a publishednx_barpost and renders correctly on the frontend viaPressBar::print_bar_notice()→get_builder_content_for_display(). This was an admin-preview-only bug (reported by a client).Root cause
The admin preview components (
PressbarAdminPreview.jsx,NxBarPresets.jsx) rendered a static<img>whose URL was derived from the starter theme name. There was no code path that rendered the live Elementor output in the admin.Changes
includes/Extensions/PressBar/PressBar.php— newrender_elementor_bar_preview()(hooked ontemplate_redirect, served at?nx_bar_preview={id}&_wpnonce=, guarded by noncenx_bar_preview+ capabilityedit_notificationx). It renders the sameget_builder_content_for_display()as the live bar, so the preview always matches the front end. It deliberately:wp_head()/wp_footer(), andso the preview shows the bar and nothing else — no WP admin toolbar, no third-party chat widgets, no other notifications.
includes/Core/PostType.php— localizes the sitehomeURL + abar_preview_nonceinto the admin data so the iframe URL can be built.nxdev/notificationx/fields/helpers/PressbarAdminPreview.jsx&nxdev/notificationx/fields/NxBarPresets.jsx— for Elementor bars, render an<iframe>to the preview endpoint instead of the static<img>:Build note
This is a source-only change. The built
assets/admin/js/admin.jsis intentionally not included — per this repo's convention it's regenerated in a separate "npm build" commit at release (npm run build). Runnpm run adminto produce the bundle for testing.Testing