WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 30 of 35

PHP: Two Ways to Check if Remote File Exists

Working on my free WordPress plugin, Simple Download Counter, I needed a quick way to check if a remote file exists. As in, requesting the file returns a 200 “OK” response. Here are a couple of ways to do it via PHP.

Note about date and time

Just a quick note about how WordPress handles dates and times.

Add Custom Info to PHP System Log

Here is a quick function for adding custom information to the system log via PHP.

Private URLs with .htaccess

With WordPress and other publishing software, you can create “private” and “password-protected” posts, but the URL is still going to be discoverable via search engines and visitors. This technique using .htaccess makes the post and URL accessible only to the specified IP addresses.

Site online but can’t access

Here are a few steps to take if a website is online but you are not able to access it.

PHP Geo IP Lookup

Here is a nice PHP snippet for GeoIP lookups. As written the script uses api.hostip.info for the lookup service, but that is easily changed as needed (GeoIP lookup services change or go offline constantly). So for what it’s worth, figured it was worth sharing rather than complete and utter deletion. Yes I am a code […]

Responsive CSS for Simple Ajax Chat

Thank you to Benjamin S. for sharing this CSS snippet for my free WordPress plugin, Simple Ajax Chat. Simple Ajax Chat (SAC) provides a setting that makes it easy to add your own custom CSS/styles. So today we’re going to take advantage of that option to customize the appearance of the SAC chat box so […]

CSS Vertical Center Block

Here are two ways to vertically center a block-level element using CSS. The first method uses CSS flexbox, while the second method uses CSS transform.

WordPress Post Navigation Enlightenment

For some reason, I am fascinated by how post navigation is handled by WordPress and others CMSs. For example, what is the correct order of the “previous” and “next” post-navigation links? Is it different for single posts versus archive views? Should the arrow point right or left? And so forth. After pondering these questions periodically […]

Some Useful WordPress Shortcodes

Here is a nice collection of useful WordPress shortcodes, including cool functionality like displaying author lists, automatic links, subscribe links, current date, and more!

Check for PHP cURL

Quick snippet for checking whether or not PHP’s cURL is available on the server.

PHP foreach loop

I am always using this PHP code snippet, which basically loops through an array that may or may not include nested arrays. So to make things easier, I am posting here for quick reference.