Skip to content

Instantly share code, notes, and snippets.

@ravewebdev
Last active October 11, 2020 07:30
Show Gist options
  • Save ravewebdev/496e6e19e67606e5558e09a2d80058b3 to your computer and use it in GitHub Desktop.
Save ravewebdev/496e6e19e67606e5558e09a2d80058b3 to your computer and use it in GitHub Desktop.
2.2. Static Block Replacement
const trackerClass = '.wp-block-rave-initiative-tracker',
trackers = document.querySelectorAll( trackerClass );
trackers.forEach( ( tracker ) => {
const attributes = {
block_id: tracker.dataset.id,
post_id: parseInt( tracker.dataset.post_id, 10 ),
};
render(
<FrontendTracker dataAttributes={ attributes } />,
tracker
);
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment