enable markdown on wordpress with wp-cli
I’m using wp-markdown plugin inside an auto generated wordpress site on docker.
Regularly, when I regenerate the site, I’m obligated to login each time to activate markdown manually.
To enable programmatically markdown features of this plugin, it’s so easy as update a worpdress option with wp-cli:
- Inline command
wp option update markdown --format=json '{ "post_types" : { "0" : "post", "1" : "page", "2" : "comment" }, "markdownbar" : { "0" : "posteditor", "1" : "comment" }, "prettify" : "0" }'
- Using external file
wp option update markdown --format=json < markdown-option.txt
While markdown-option.txt
contains:
{
"post_types" :
{
"0" : "post",
"1" : "page",
"2" : "comment"
},
"markdownbar" :
{
"0" : "posteditor",
"1" : "comment"
},
"prettify" : "0"
}
- With docker exec (just skip double-quotes)
docker exec -ti --user www-data wordpress bash -c "wp option update markdown --format=json '{ \"post_types\" : { \"0\" : \"post\", \"1\" : \"page\", \"2\" : \"comment\" }, \"markdownbar\" : { \"0\" : \"posteditor\", \"1\" : \"comment\" }, \"prettify\" : \"0\" }'"