A Quick Explanation of PHP Ternary Operators.

A Quick Explanation of PHP Ternary Operators.

Mr JoshersSep 27, 2023
Ternary operators in PHP are shorthand conditional statements that allow you to write a simple if-else statement in a single line of code. The syntax for a ternary operator is: If the condition is true, the true_value is returned. Otherwise, the false_value is returned. For example, the following code: will output “less than or equal […]
Understanding Vue.js Components and Props: A Practical Example

Understanding Vue.js Components and Props: A Practical Example

Mr JoshersSep 23, 2023
In the world of web development, Vue.js has rapidly gained popularity as a progressive JavaScript framework for building interactive and dynamic user interfaces. With its simplicity and versatility, Vue.js has become a developer favorite. To illustrate how Vue.js works and how components and props function, let’s dissect a simple Vue.js code snippet. Example Code In […]
Why is Mac Better for Web Dev?

Why is Mac Better for Web Dev?

Mr JoshersSep 12, 2023
An objective case for why some web and WordPress developers prefer using Macintosh (Mac) computers for their work
Turn a string into an array in PHP

Turn a string into an array in PHP

Mr JoshersAug 31, 2023
Ah, PHP and string manipulations, good ol’ stuff! To turn a comma-separated string into an array in PHP, you can use the explode() function. This function splits a string by a string separator (in our case, a comma) and returns an array. Here’s a quick example: This will output: And just like that, you’ve got […]
Remove Global Install of PHPCS

Remove Global Install of PHPCS

Mr JoshersAug 25, 2023
If you want to wipe the slate clean and remove all global installs of PHPCS and WordPress standards, you can follow these steps: For PHPCS (PHP CodeSniffer): For WordPress Coding Standards: Look for a line mentioning installed_paths. Replace /path/to/wpcs with the actual path you found. These commands should remove the global installations of both PHPCS […]
PHPCS set up for just one specific WordPress project

PHPCS set up for just one specific WordPress project

Mr JoshersAug 25, 2023
Let’s get PHPCS set up for just one specific WordPress project. You can do this using Composer, which is a great way to manage dependencies on a per-project basis. This installs PHPCS in the project’s vendor directory. This should show WordPress among the available coding standards. By following these steps, PHPCS and the WordPress Coding […]
Install PHP 8.2 on Mac with homebrew

Install PHP 8.2 on Mac with homebrew

Mr JoshersAug 23, 2023
Installing PHP 8.2 on your Mac using Homebrew is pretty straightforward. As a WordPress developer, you’ll probably find this handy for your local development environment. Here’s a step-by-step guide: You should see information about PHP 8.2, indicating that the installation was successful. If you run into any issues, Homebrew’s error messages are usually pretty informative, […]
Scope Resolution Operator ::

Scope Resolution Operator ::

Mr JoshersAug 21, 2023
The scope resolution operator, also known as the double colon (::), is a token that allows access to static, constant, and overridden properties or methods of a class in PHP. Here’s a bit more detail on how it’s used: 1. Accessing Static Members You can use the scope resolution operator to access static methods and […]
What is a Canonical URL?

What is a Canonical URL?

Mr JoshersAug 10, 2023
You’ve probably come across a Canonical URL in web development, especially in the SEO world. Imagine you have the same content accessible through multiple URLs. This can confuse search engines like Google, making them unsure of which URL represents the original content. It’s kind of like having several paths to the same destination. A Canonical […]
Typical .ajax call in jQuery

Typical .ajax call in jQuery

Mr JoshersAug 7, 2023
Here’s what each part does: Remember, these are just some of the options available in a jQuery AJAX call. There are many other options and methods available, which can provide more control and flexibility over your AJAX requests. You can find more details in the jQuery AJAX documentation.
Animate an SVG Part

Animate an SVG Part

Mr JoshersJul 26, 2023
Animating a small part of an SVG with CSS involves manipulating the SVG’s properties using CSS animations. You can target specific elements or attributes within the SVG to animate them. Here’s a step-by-step guide to help you achieve this: Remember that not all SVG elements or attributes can be animated with CSS alone. More complex […]
Deactivate WordPress Plugins with WP-CLI

Deactivate WordPress Plugins with WP-CLI

Mr JoshersJul 16, 2023
WP-CLI is a command line interface for WordPress. You can use it to manage your WordPress sites from the command line, including plugin management. Here is the command you can use to deactivate a plugin: Replace plugin-name with the actual name of the plugin you want to deactivate. If you want to deactivate all plugins, […]
Multisite Blog URL Replacement using bash

Multisite Blog URL Replacement using bash

Mr JoshersJul 15, 2023
If you have a multisite with lots and lots of blogs, updating the URL’s for each wp_{id}_options table can be difficult if you need to do it manually. Here’s how to use a bash script so you don’t bash in your head doing it table by table.
Parallax Banner

Parallax Banner

Mr JoshersJun 27, 2023
Creating a parallax effect for a banner can be achieved using CSS and JavaScript. The basic idea of the parallax effect is that the background content (e.g., an image) and the foreground content (e.g., text) move at different speeds when the user scrolls, giving the illusion of depth.
Get Post Thumbnail By Post ID

Get Post Thumbnail By Post ID

Mr JoshersJun 21, 2023
You can use the has_post_thumbnail function to retrieve the post thumbnail by post ID in WordPress.
Disable Most Typography & Color Choices in WordPress

Disable Most Typography & Color Choices in WordPress

Mr JoshersJun 14, 2023
In your theme.json file in a Full Site Editor WordPress site, you can control and set up many settings for the site. You can even lock out choices for the site editor.
Output a WYSIWYG Field with ACF

Output a WYSIWYG Field with ACF

Mr JoshersJun 2, 2023
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()

Now I See You, Now I toggle()

Mr JoshersMay 31, 2023
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?

Hide the Outline?

Mr JoshersMay 31, 2023
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 […]
Cleanshot X

Cleanshot X

Mr JoshersMay 28, 2023
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

Simple CSS Loading Animation

Mr JoshersMay 5, 2023
Quick and dirty but nice looking pure CSS loading animation.
A kid escaping out a window with the WordPress logo painted on the wall. Photo by Avi Waxman on Unsplash

All output should be run through an escaping function in WordPress

Mr JoshersApr 30, 2023
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
We Like You Too. Photo by Adam Jang on Unsplash.

Translation Function for Hard-Coded String in WordPress

Mr JoshersApr 29, 2023
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

Remove Text in a String with PHP

Mr JoshersApr 29, 2023
You can remove any text, like asterisks (*), for example, from a string using the str_replace() function
Run jQuery after DOM Manipulation

Run jQuery after DOM Manipulation

Mr JoshersApr 27, 2023
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 […]
A kid escaping out a window with the WordPress logo painted on the wall. Photo by Avi Waxman on Unsplash

Allow HTML Tags while using an escaping function in WordPress

Mr JoshersApr 27, 2023
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() […]
WordPress Blocks

Setup a Block as a Plugin

Mr JoshersApr 15, 2023
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 …

Spread Operator …

Mr JoshersApr 8, 2023
In JavaScript, the … syntax is called the “spread operator.” It is also difficult to Google!
WordPress Blocks

List All Blocks in the Console

Mr JoshersApr 6, 2023
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 […]
WordPress Blocks

Blocks That You Don’t Need to Resave When You Edit Them

Mr JoshersApr 3, 2023
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

Write HTML in PHP with ob_start

Mr JoshersApr 2, 2023
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.
Get Query Parameter PHP

Get Query Parameter PHP

Mr JoshersMar 6, 2023
It’s pretty easy to simply grab a URL Query Parameter, but here’s how to do it safely.
Change a Key Name PHP

Change a Key Name PHP

Mr JoshersMar 6, 2023
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

Complex Arrays PHP

Mr JoshersMar 6, 2023
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

Pretty Print Array in PHP

Mr JoshersMar 6, 2023
Just a quick snippet for printing out an array in a nice way.
Ternary Operator

Ternary Operator

Mr JoshersMar 5, 2023
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

Find that element that goes off page

Mr JoshersMar 5, 2023
If an element on the page is wider than the document, it’ll get logged to the console.
Javascript OOP

Javascript OOP

Mr JoshersMar 5, 2023
Javascript Object Oriented Programming basic setup. And I’m using jQuery because, why not? It’s already in WordPress, anyway.
Register Rest Field

Register Rest Field

Mr JoshersMar 5, 2023
This will put anything you want into the wp api call for a post, page, or any custom post type.
WP Custom Route API

WP Custom Route API

Mr JoshersMar 5, 2023
You can do a lot with the WordPress API, but it gets really good when you can make your own WP API endpoints.
Hipster Ipsum

Hipster Ipsum

Mr JoshersFeb 19, 2023
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.
Bob Ross Painting

Bob Ross

Mr JoshersFeb 19, 2023
Just some happy ipsum can live right over here bobrosslipsum.com. Just go back and put one little more happy tree in there.