Entries tagged "PHP"

Add Delay Feature to Newsfeed

The newsfeed feature I developed a few years back works as expected. At times, however, I wish it would let me have a post automatically appear after a specific time. Especially now that I'm used to services like HootSuite that allow me to schedule tweets and other social media postings. [Continue reading]

Use MySQL’s Date Functions Instead of PHP’s

Many of the MySQL queries that I create include a date and / or time. My usual place to get this information was from PHP's date() function. At least until I discovered that MySQL has many built-in functions to do the same thing. Let's look at a quick example. [Continue reading]

Import Login Information for Database Connection Scripts

I'm starting to realize that importing the script used to establish a database connections isn't enough. Being able to import a script wherever the database is needed does simplify the process of changing a database password since it only needs to be changed in one place. However, I keep finding reasons to make major revisions to the connection script which usually results in having multiple versions and I don't always have the time to complete the upgrade process. All of those connection scripts need to be updated when the password changes. [Continue reading]

Calculate Distance Between Zip Codes Part 2: Build the Search Engine

With a database full of zip codes, latitudes, and longitudes, you can get all the entries that are within a given radius using the Haversine formula…and a little help from Google. This week's post will build on the work done last time by developing a search engine where users can enter a zip code and a search radius. The script will then output all the records within the given radius. [Continue reading]

Calculate Distance Between Zip Codes Part 1: Geocode Database Entries with the Google Maps API

A few years back I looked into using the Google Maps API to calculate the distance between two zip codes. The proof of concept seemed to work well enough. But when I attempted to perform larger-scale calculations, the solution began falling apart. And it was slow… So I needed to develop an alternative solution. [Continue reading]

How to Test Submissions from Forms that Use the POST Method

An important part of developing online forms is testing. One area of testing I've always wanted to better with is making sure input types like radio buttons can't accept values which are not allowed. In this week's post, we go over my primary method of testing. That way we can discuss a faster way next time. [Continue reading]

Lessons Learned: Outputting Shortcode and Plugin Results

If you look closely at the documentation for WordPress Shortcodes, there is a specific way to output content to the screen. Of course, this is a part of the documentation I skipped while developing my first plugin which lead to some baffling results. To help save you time, I wanted to share one last lesson learned from writing my plugin. [Continue reading]

Lessons Learned: How Not to Name Shortcode Attributes in WordPress

Developing my first WordPress plugin provided me with many learning opportunities. We already talked about the quicker way of uploading plugin files. In this post, I wanted to share the problem I had with shortcode arguments. Hopefully it will help you avoid the same issue. [Continue reading]

My First WordPress Plugin: Generates a Bulleted List of Clickable Blog Post Titles

I recently helped with a redesign that involved building a website with an out-of-the-box WordPress theme. The theme met our needs for the most part, but we were looking for something to dynamically generate an FAQ page from blog posts tagged with "FAQ". After trying some third-party plugins which didn't quite work for us and attempting to modify the theme files directly, I decided it was time to build my first WordPress plugin. [Continue reading]

Alternate Way to Write PHP Function Arguments Part 3: Manually Throwing Errors

Using associative arrays for function arguments allows for more flexibility. However, we do lose some important features when it comes to building and calling functions. Packing all those arguments into an associative array prevents PHP from automatically detecting when required arguments are not included. But, there is a way to simulate this feature. [Continue reading]