Category: wordpress
-
How to generate a temporary file in PHP / WordPress with an extension
When you use tempnam or wp_tempnam it generates something like /private/tmp/FOOp8eRnX or /var/tmp/63c6a7da1e1ed-fKMNGh.tmp It is standard to want to have an extension in the end of the temporary path. For example if you want to manipulate images with wp_get_image_editor it will not work if the extension is not good. In this case, just use $tmpfname…
-
Weird side effect of innerHML plus equal (+=) : use .insertAdjacentHTML instead
I was using pure HTML and Javascript, adding some <select> or <input> to an element, using element.innerHTML += “<div><select>…</select></div>” There was a weird bug, it was resetting other input in the list, I don’t understand why. Well I did not find why, but I found that it is better to use insertAdjacentHTML instead, because innerHTML…
-
Block validation: Block validation failed
I had this error in a WordPress, editing a custom plugin block. It was because I removed an attribute, and then the element was not working. Just remove the element from your page, reload, and add a new one, it works.