The beautiful function wp_localize_script() was built for l11n, however its found as a method for carrying over server-side values into client-side JS. Your values are now available in your .js file: Currently using this in a React theme I’m building for WordPress. This can also be done with something like:
I had a project where every single media library image URL needed to be filtered, backend and front end. As far as I’ve found these were the filters for every area: The myplugin_filter_html_image_urls() function peals out images with regex from areas where it’s not just the URL being sent. This function may require verification of […]
Passing variables into WordPress hooks using an anonymous function I thought was impossible. I always worked around this and rewrote the logic. Today I found out anonymous functions support a use keyword, allowing passing: So simple and easy. Shaves hours of troubleshooting.
When switching localhost php versions for testing, nothing interrupts the workflow more than phpMyAdmin failing because you’re on php 5.4. The single line of code, to be your index.php in /phpmyadmin/ simply routes you to either the phpmyadmin/new/ (v4.7 – supports php 5.5-7.2) and phpmyadmin/old/ (4.0 – supporting php 5.2 – 5.4): Simple.
I get the meaning of this app local.getflywheel.com – I just spent about 2 hours troubleshooting my local server setup after macOS 10.13 High Sierra update. Despite the annoyance, I do like having a local Apache to test, break, & fix – so I wont be replacing my local server with an app – but […]
This little function allows a form to have reCAPTCHA hidden until a user begins entering form values.
I used to manually do everything for the Images section of my site. Adding an image would involve: save photo after editing, renaming it, uploading, creating new post, setting the title and date, assigning the featured image as the upload, then setting the category to Images so it’s added to the page. So, 8 steps, […]
As the lengthy title says, the follow simple script allows you to use a shortcode to dynamically output the number of years since a specified date. I wrote this for my own bio, which I used to have to update the number of years since the start of my employment once a year. The simple’r […]
For demo/home sites of a theme/plugin that wish to include the projects main readme files as part of the website, this quick snippet loads the folders README.md file, and parses the MarkDown (to githubs flavour) with a awesome jQuery plugin, all with the simple call of a [readme] shortcode.
One of the most annoying features of WordPress Multisites (besides domain mapping) is adding a Super Admin a few years after your network is established and grown. Sure, being a Super Admin allows said user to access any site on the network, but the user is technically not added to the site – so the […]
Building a PHP app that communicates with Slack a lot, I found it was much cleaner to tuck everything away in a function and call it in a single function that resembles the attributes of mail(). This makes for changing your apps icon andor color easy, as well as staying consistent with the Title and […]
I remember all the custom solutions and plugins needed before this was supported in WordPress 4.4. A great snippet to have in your toolbox. I’ve reduced it to the bare basics.