In this workshop we learn how to build a small vanilla JavaScript application. We then connect it to the WordPress REST API. From there we import our application into WordPress as a plugin. Finally we refactor our application to run on React rather than vanilla JavaScript.
- Start with the
01-javascript-starter
folder - Follow along to add a button to the page
- Then call a function when the button is clicked
- Install and Activate the
02-likes-starter
plugin on your WordPress site - Have the button update the likes on your WordPress site via the REST API
- Display the like count in the button
- Connect to local storage to prevent voting multiple times
- Go over the code for the
02-likes-starter
plugin. Focus on JS and CSS enqueuing, metabox setup and REST API customization - Setup localize script to provide
postID
and likescount
- Import and modify code from vanilla JS example to work in WordPress
- Install and activate the
03-likes-react-starter
plugin - Look over the code. Focus on React dependency, package.json
- Install and setup WP Scripts
- Convert the plugin to React