WordPress Child Theme: Easy Mistakes

How to set up a child theme There are a number of tutorials that go over how to set up a child theme. I should know by this point, but there are a few frequent mistakes that are both crucial to the setup process and that other tutorials fail to make explicit. Short-hand list for … Read more

Interface & Abstract Class Comparison Cheat Sheet

Class Abstract Class Interface Instantiated ✔ X X Extend/Implement Multiple X X ✔ Contract X ✔ ✔ Implementation ✔ ✔ X Single Place Versioning ✔ ✔ X All Methods Public (Access Modifiers) X X ✔ Properties ✔ ✔ X Constants ✔ ✔ ✔ Overridable Constant ✔ ✔ X Type Checked ✔ ✔ ✔ Abstract Class … Read more

PHP File Handling Cheat Sheet

Accessing Directory Read Directory Files into Array $dir = ‘example’; $files = scandir($dir, ‘w’) or die(‘Cannot read directory: ‘.$dir); //implicitly creates file foreach ($files as $file) { //do something with $file } Open and Close Directory $dir = ‘example’; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) … Read more

Contact Form 7 Ticketing Plugin

The CF7 Ticketing Plugin is an incomplete plugin made for a client that needs a ticketing system for building maintenance. It utilizes the Contact Form 7 plugin for form validation and stores the input as a custom post type that can be searched and organized. CF7-Support-Ticket Plugin The plugin includes a custom backend menu, “Tickets”, … Read more

Simple Regex Reference

A simple regex reference sheet for all your regex needs. [abc]     A single character: a, b or c[^abc]     Any single character but a, b, or c[a-z]     Any single character in the range a-z[a-zA-Z]     Any single character in the range a-z or A-Z^     Start of line$     End of line\A     … Read more

Using Prepared Placeholders with Wildcards in PDO

When using SQL wildcards with PDO placeholders, include the wildcard in the variable and not the query. Use this: $search = ‘%’ . $search_term . ‘%’; $sql = “SELECT * FROM posts WHERE content LIKE :search”; $stmt = $pdo->prepare($sql); $stmt->bindParam(‘:search’, $search, PDO::PARAM_STR); $stmt->execute();