Archive April 2019

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\" }'"

curl in updated ubuntu Bionic does not work

curl stopped working properly after updates installed on ubuntu 18.04 with following error:

curl: /usr/local/lib/libcurl.so.4: no version information available (required by curl)
curl: (1) Protocol "https" not supported or disabled in libcurl

Check libcurl (locate) and then change symlink of usr/local libcurl to usr/lib libcurl :

sudo rm /usr/local/lib/libcurl.so.4
sudo ln -s /usr/lib/x86_64-linux-gnu/libcurl.so.4.5.0 /usr/local/lib/libcurl.so.4

This fixed the problem for me

script bash waiting for http server

How-To

Waiting for http server responding on http://localhost:8080

while [ "$(HEAD http://localhost:8080 | grep '200\ OK' | wc -l)" = "0" ]; do echo -n "."; sleep 1; done;

Explanation:

While http server is not ready, HEAD receives http code 500 with conection refused error

HEAD http://localhost:8080
500 Can't connect to localhost:8080 (Connection refused)
Content-Type: text/plain
Client-Date: Fri, 05 Apr 2019 07:11:06 GMT
Client-Warning: Internal response

When the server is ready, HEAD receives http code 200 (OK)

HEAD http://localhost:8080
200 OK
Cache-Control: no-cache, must-revalidate, max-age=0
Connection: close
Date: Fri, 05 Apr 2019 07:09:47 GMT
Server: Apache/2.4.25 (Debian)
...etc