humanmade / humanmade/aws-analytics

Documentation: Call to wp_body_open() is necessary for Audience preview to work

Open
#275 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
19
Forks
1
PR merge metrics
No merged PRs in 30d

Description

When viewing an Altis site on the frontend, the audience preview in the WP Admin Bar does not work as expected unless you use `wp_body_open()` which will render the admin bar at the top of the `` instead of appending it before the end of the `` element.

Specifically, [here](https://github.com/humanmade/aws-analytics/blob/master/src/audiences/preview/index.js#L7) is where we are getting the element by ID to then render the React components.

On the Altis demo site, the admin bar is output as the first child element of the body, so when this script is run the admin bar is already able to be selected. On two client sites, the admin bar is output as part of `wp_footer()` in the footer and therefore this selector is run before the admin bar is rendered and therefore returns without rendering the menu correctly.

I think we should document somewhere that in order for audience previews to work, it is required to use `wp_open_body()` so the admin bar is rendered before the audience preview script is included.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.