Skip to content

Instantly share code, notes, and snippets.

@steffenz
Created May 7, 2019 07:19
Show Gist options
  • Save steffenz/cca5b6e29bc410e7f14e5c405dbef5b3 to your computer and use it in GitHub Desktop.
Save steffenz/cca5b6e29bc410e7f14e5c405dbef5b3 to your computer and use it in GitHub Desktop.
Embedding React application inside a WordPress plugin
<?php
$scripts = preg_grep('~\.(js)$~', scandir(__DIR__. '/../react-frontend/build/static/js'));
foreach($scripts as $script){
wp_enqueue_script("react-{$script}", plugin_dir_url( __FILE__ ). "./../react-frontend/build/static/js/{$script}");
}
echo "<div id="root">Enabled JavaScript to see this page</div>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment