It is common for articles on writing WordPress code to refer to adding the code to the functions.php file in the active theme. This is one location where code can be added but it isn’t always the best. Places to Add WordPress Code a new file in wp-content/mu-plugins a new plugin in wp-content/plugins the functions.php […]
With the prevalence of large monitors, I’ve found I wanted a larger container size than the default in Bootstrap 4, which is 1140px. Fortunately, working with the Bootstrap 4 Sass code it only takes a few lines of code to add an additional container size (and breakpoint to go with it).
Images that appear wider than the text around them are a cool design technique. I do a lot of work with Bootstrap and unfortunately, I’ve found that getting this to work usually ends up with markup that leaves me unsatisfied – at least until now. Using this technique, we can get a full width image without first closing the container element.
WordPress comes with some helper functions for finding a theme’s path and/or URI, which are tremendously useful but I always have to look them up. Therefore, I’m making note of them here so I know where to look them up: get_stylesheet_directory(), get_stylesheet_directory_uri(), get_template_directory(), get_template_directory_uri()
I’ve been using PHP CodeSniffer to help me following coding standards. The WordPress Coding Standards are a great resource and the basis of the rules I follow. I have made a few modifications based on my personal preferences.
When it comes to adding social sharing buttons (e.g. “Share on Facebook”), I’m a big fan of Scriptless Social Sharing by Robin Cornett. The one thing I like to do when using it is add UTM parameters to the links that are shared. Here is the snippet I use to add UTM parameters to my URLs that are being shared.
The editorconfig project provides a powerful tool for standardizing the general coding standards used in a project, specifically in regards to: indent_style, indent_size, end_of_line, charset, trim_trailing_whitespace, and insert_final_newline.
There are a number of different inline conditionals I use when working with PHP (i.e. ternary conditionals and the null coalescing operator). As a reminder of how some of these common inline conditionals work, I put together this table for reference.
These are my reminder notes on how to quickly populate the LICENSE information for one of my projects from the command line.