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
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:
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 the current domain incase bad practices of using external images is being done.
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
/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):
This little function allows a form to have reCAPTCHA hidden until a user begins entering form values.