Areas to Explore
Opened this issue · 3 comments
- Creating Wordpress environment from exported
json
- Advanced Custom Fields
- Custom Post Types
- Custom Taxonomy
- Generating
json
fromconfig.yaml
- Advanced Custom Fields
- Custom Post Types
- Custom Taxonomies
- Adding more field support
- Chokidar to build models after YAML change
- ACF Fields updating on the fly
- CPTUI types updating on the fly
- Testing performance of direct SQL queries with
knex
- Good outcome: Create
get
,find
,count
API around wordpress tables. - Bad outcome: Look into MySQL triggers, or efficient means of normalizing tables for performance, and build a (simpler) API around normalized tables.
- Good outcome: Create
- Hosting with Docker Swarm
Creating Wordpress environment from exported json
2 hours
Advanced Custom Fields
I was able to automatically sync field groups by using the Local JSON feature of Advanced Custom Fields.
Unfortunately, there is currently no support for automatically syncing fields on plugin init, but I was able to create a custom theme with this function.
Still need to generate custom post types and taxonomies until this item is complete.
Custom Post Type UI
It was a bit tricky to find documentation online on how to import the json
files exported from the Wordpress UI.
So I began to look through the plugin code to see how the CPTUI team implemented, and ran into a file called wp-cli.php
with a class at the top of it conveniently called CPTUI_Import_JSON
.
Then I realized that I could run wp cptui import
and provide my json files to and it would automatically load them up!
Generating json
from config.yaml
2 hours
Though I still need to add documentation and more field types, I was able to update the parser to convert the config.yaml
into json
files!
From there, Wordpress could spin up an entire backend UI with our custom models! 🎉
I also disabled the admin user, so that it isn't possible to generate models from Wordpress UI (and handle all the issues that come along with that feature)
Dynamic updates
2 hours
Chokidar to build models after YAML change
When a user spins up Docker, changes to the config.yaml
file will cause the JSON to be generated in a dist
folder. The docker-compose
file will automatically map that generated JSON to the wordpress container, so that the changes are available in the PHP server.
ACF Fields updating on the fly
Fortunately, Advanced Custom Fields treats the acf-export
folder as the source of truth for all the field settings. This means as soon as the JSON is updated, the fields are up-to-date on the CMS.
Things to note
- Running
docker-compose up
with the wordpress servicevolumes
causes a permissions issue. For now, commenting out the volumes until after initialization is the only way to get the custom theme to load. - CPTUI does not update on the fly, so using the
wp cli
is likely necessary after the JSON is updated.