Understanding WordPress Filters & Hooks for Drupal Developers As a Drupal developer, you’re likely familiar with Drupal’s hook system, which allows modules to interact with and alter the core functionality of Drupal without modifying the core files directly. WordPress offers a similar feature known as Hooks, which are divided into two categories: Actions and Filters. Let’s dive into what they are, how they compare to Drupal’s hooks, and how to use them effectively.
Imagine you want to render our text in your form. In the past, I would pass in the #markup index in my render array with some HTML as value. For example
1 2 3 4 5 6 $output['my_button'] = [ '#markup' => '<div> <button id="generate-images">Generate Images</button></div>', '#allowed_tags' => ['div', 'button'], ]; This works for the most part. Especially when all you need is to render out a straightforward markup.
So, I went to a meditation retreat in late November – 1-hour daily meditation twice a day, noble silence in the mornings, and no phone or electronics for a whole week. Well, it was more like 4.5 days, but you get the idea. I had minimal expectations and an open mind coming into this. I expected it to be challenging, especially not having my phone.
Some of the things I learned that week:
I remember celebrating my 18’s birthday in Pretoria, South Africa. I moved there a few months earlier, and I had a pretty small social circle. I was not planning to do anything really, then a family friend called, and we went out that night, and I still remember that day with a lot of fondness. The next day, my friend called me and asked me: “so, how does it feel?” I replied, what?
A reflection on new years resolutions This year has been one of the most exciting years of my life. For the first time in my adult life, I didn’t set up unrealistic new years resolutions. Instead, it was easy for me to look at the things my wife and I had pretty much planned for the year ahead. Then, everything personally and professionally was evaluated based on how close it got us to achieving the plan.
How I lost and recovered 3 hours' worth of work using Git
Prologue
So, imagine you sit down in front of your computer; you start a new project in your favourite editor, and you’re flowing. Four hours later, you’ve ticked every item on your to-do list and it’s time to commit and push your project to git. You add your files, commit and push. Go on the remote server and what? Half your files are not there. You go back to your local project; you check the head and nothing. Oh sh.t! you say to yourself; the git ignore excluded a bunch of files, and some files that shouldn’t have been committed were added. We’ll fix it, you think to yourself. Delete the .gitignore, then git rm
the files to remove, then you’ve removed the wrong files. Oh sh.t, again!. You decide to reset the branch to the origin: git reset --hard origin/master
. As soon as you type enter, you realise your uncommitted files are gone. Disappeared. Never to be found again. Oh f#ck!