Posted on Leave a comment

Give me a Gist — #2019AWPChallenge

The #2019AWPChallenge continues in our AWP Facebook group. Contributions are coming in consistently, everything from plugins and themes to more complex headless apps and everything in between. 

In this round-up, we’re going to take a look at some great code snippets that have been shared. These code snippets are a great way to quickly and easily perform a function or add functionality to your WordPress site in minutes. Without further ado, let’s jump in!

NOTE: AWP members can click on the image links to see the original posts, which have much more detail and great conversations. Another reason to join if you haven’t already.

Extending Site Health With cURL Information

Matt's post says:
I really like the SIte Health tests coming in WP 5.2. But for eCommerce/Donations your site really needs an updated cURL. So I added this snippet that extends the Site Health tests to include that. I like how easy to extend the tests and info panels are.

Trying to get information from your customers about which cURL version they are using can be a frustrating experience. Our very own Matt Cromwell contributed this useful snippet to add cURL information directly into Site Health.

Add a hash to Your Assets to Beat the Cache

Piotr's post says:
Do you have a problem when you are sending the website to the client with a sentence: "If you do not see the changes please refresh browser" ;-) ? This is so much frustrating for both the client and the developer. You can use the function below to generate scripts and styles with content hash attached after any change.

Ever released a plugin update for a user to message and say something along the lines of “Your latest update broke my site! The interface of your plugin is all messed up”. And then you say, “Please clear your browser cache, and everything should work fine.”

To save you the hassle in the first place, Pitor shared a snippet to add a hash to your assets to prevent the browser from caching and serving old assets. Thank him over on the AWP post. 

No More Messy Menus

Ynot's post says:
Spent the night playing with this idea (inspired by a post here complaining about messy admin menus). My solution? Automatically split the admin menu into three sections: A. Dashboard and Post Type Menus B. All Other Default WordPress Menus C. Any Other Added Menu Items.

A pain point for many is how confusing and messy the WordPress admin menu system can get. I think we can probably all agree that it can be a bit of a mess. 

That’s why Ynot created a handy snippet for splitting the admin menu into three sections. 

  1. Dashboard and Post Type menus
  2. All other default WordPress menus
  3. Any other added menu items

Want your menus to be cleaner? Then check out the snippet.

WooCommerce Variable Pricing Display

Chris' post says:
Our client does a significant about of both PPC and broadcast marketing around very specific combinations of attributes in variable products. The default treatment of variable product displays in WooCommerce is to show the range of prices possible with the variable selections. However, when the client wants to target a specific combination, they want only that variant's specific price to be output in the landing page their marketing is driving traffic to.

Chris Jenkins needed a solution, how to display the pricing of a specific variable product based on its attributes? 

His client didn’t need the range of prices showing like how WooCommerce does it out the box, no. He needed to show that variables price specifically. 
He found the solution and shared the gist with the AWP group to use in your own projects; I’m sure this will come in handy for many stores.

Password Migration Made Easy

Piotr's post says:
Script to migrate passwords from old password hash algorithm to WordPress algorithm. When your client has existing and working application with database of users and you want to import them to your brand new WordPress application, you can not import passwords because they are probably hashed using different algorithm.

We conclude this round-up with another share from Pitor. This time it’s an easy way to migrate from an old password hash algorithm to the WordPress hash password algorithm.

What exactly does it do? It’ll allow you to use an old systems password and login using the old password hashed with the WordPress algorithm without having to reset the password. 

Check out the snippet and use it in your next, “I’m coming from an ancient system to WordPress site” build.  

Inspired to share?

Don’t be shy! The #2019AWPChallenge is running all year long, and we’d love to see what you’ve been up to, whether it’s a useful code snippet. An interesting use of WordPress, the latest in Gutenberg, and everything in between. Share your post in the AWP Facebook group with the hashtag #2019AWPChallenge.

Write for us!

Are you an AWP member? Would you like to write about the awesome advanced things you’re working on? We’re taking author submissions now and would love to hear from you. Find out more here:

Leave a Reply