Output a WYSIWYG Field with ACF
To output a WYSIWYG (What You See Is What You Get) field with Advanced Custom Fields (ACF) in a WordPress template, you need to add a snippet of PHP code to your template file where you want the field’s content to appear. Firstly, you’ll need to create your WYSIWYG field using ACF. In the ACF […]
Now I See You, Now I toggle()
You can use jQuery’s toggle() method to toggle the visibility of an element. Here is a simple example: This line of code will hide the element if it is currently visible and show it if it is currently hidden. Here’s a more complete example with a button that toggles the visibility of a div: In […]
Hide the Outline?
CSS outline is a property that puts a line around the outside of an element, often used to indicate focus on the element, especially for users navigating with a keyboard instead of a mouse. For example, when a button is selected (but not yet activated), the browser might put a dotted line around the button […]
This is the radest screenshot app I’ve ever used. Totally worth the $30 bucks. You can share, annotate, grab text from images, SCROLL CAPTURE (no more need for browser-specific page capture plugins), remove icons from your desktop, GIFS, and video capture. This thing slices and dices!! https://cleanshot.com/
Simple CSS Loading Animation
Quick and dirty but nice looking pure CSS loading animation.
All output should be run through an escaping function in WordPress
To escape output in PHP within WordPress, you can use the esc_html() function to convert special characters to their HTML entities. This is useful for preventing XSS (Cross-Site Scripting) attacks by ensuring that any user-provided data is properly sanitized before being outputted to the webpage
Translation Function for Hard-Coded String in WordPress
In WordPress, the recommended way to handle hard-coded strings that need to be translated is to use the __() function, which is a shorthand for the translate() function.
Remove Text in a String with PHP
You can remove any text, like asterisks (*), for example, from a string using the str_replace() function
Run jQuery after DOM Manipulation
To run a jQuery function after the DOM has been manipulated, you can use the .ready() function or the .on() function with the DOMSubtreeModified event. Here are examples of both approaches: Using .ready(): This function will be called once the DOM has been fully loaded and is ready for manipulation. Any code you place inside […]
Allow HTML Tags while using an escaping function in WordPress
In WordPress, the esc_html() function is used to escape HTML entities in a string, which helps to prevent cross-site scripting (XSS) attacks. By default, this function will convert all HTML tags to their corresponding entities, including the <h1> tag. However, if you want to allow the <h1> tag in esc_html(), you can use the wp_kses() […]
Setup a Block as a Plugin
WordPress made a rad package that sets up webpack, Babel, and all the other packages we need to run React for WordPress Blocks.
Spread Operator …
List All Blocks in the Console
You can get an array of all the blocks used in your editor by going to the inspector console and using this bit of code. In this array, you can see all the attributes for each! So, if you need to approach the editor as a whole, as in, all the blocks and not just […]
Blocks That You Don’t Need to Resave When You Edit Them
Standard WordPress blocks have a problem. If you edit the “save” parameter at all, you have to go to each post and resave it for the changes to be brought to the front end of that post. This is a deal breaker, so let’s see how to make PHP handle this for us. In our […]
Write HTML in PHP with ob_start
The “OB” stands for “output buffer”, and essentially anything that comes after the “ob_start” and before the “ob_get_clean” is what’s returned in the function.
Change a Key Name PHP
I guess it’s pretty simple, but it’s nice to have a reminder in case things aren’t going well. Sanity check. 🙂
Complex Arrays PHP
Arrays can get complicated pretty quickly. Here’s a quick lowdown on how they are made, and how they are accessed.
Pretty Print Array in PHP
Just a quick snippet for printing out an array in a nice way.
Inline if this then that else this other thing. Handy when you need to do this sort of thing in a template literal.
Find that element that goes off page
If an element on the page is wider than the document, it’ll get logged to the console.
Register Rest Field
This will put anything you want into the wp api call for a post, page, or any custom post type.
WP Custom Route API
You can do a lot with the WordPress API, but it gets really good when you can make your own WP API endpoints.
When it comes to testing and Ipsum, Hipsters are the best. hipsum.co If you need an image or two, picsum.photos has some great options built right in.
Just some happy ipsum can live right over here bobrosslipsum.com. Just go back and put one little more happy tree in there.