Categories
Web Development

Solved: WordPress Cannot Upload Images (NGINX)

Symptom: WordPress running on NGINX cannot upload images or files. You may see an error message that tells you “permission denied” in the media uploader. Naturally you check permissions on your uploads folder, but the permissions appear correct. You might have even tried setting chmod permissions to 777. However, none of this will help if […]

Categories
Web Development

Truncate a Phrase Using Words, Not Characters (PHP)

Often when people truncate text in their WordPress excerpts or sample text, they simply limit the total number of characters and add an ellipsis. It’s pretty easy to do, but it usually ends up with a word being broken at the end. For exampl… This function will truncate any phrase by the number of words […]

Categories
Web Development

PHP Phone Number Formatting Function

Phone numbers have got to be one of the most commonly gathered bits of information in forms. I created a little PHP function that formats them for the most common US strings, 7 or 10 digits. The Function // FORMAT PHONE NUMBERS function formatPhoneNumber($variableName) { global $$variableName; // Keep numbers only $$variableName = preg_replace(“[^0-9]”, “”, […]

Categories
Web Development

Formatting Phone Numbers with PHP

When adding a phone number field to a form, it’s nice to format it (if it isn’t already). This doesn’t replace anything you would do to validate your form via Javascript. But it does create that little extra bit of uniformity, even if it is slightly redundant.

Categories
Web Development

Using PHP Classes and Functions in WordPress

Creating custom functions in your WordPress template’s function.php file is a regular thing for many of us. What you might not know is how easy it is to wrap them in a class, or even why you would. Wrapping them in a class keeps them both organized and self-contained from other functions that may have […]

Categories
Web Development

Role Based Profile Fields in WordPress

I recently set out to customize WordPress profile fields for a specific role. You may want to have custom fields for users, but have different fields for different roles. For example, Authors may need some additional contact information, while Subscribers need only some basic fields. The concern I had was wether or not an Admin […]

Categories
Web Development

WordPress File Uploads Checked By MIME Type

Building a custom HTML form for WordPress is something I do fairly regularly. When adding an upload form, it’s important to check for allowed file types. You wouldn’t want anyone uploading a malicious PHP script, right? Wouldn’t it be great if WordPress did that for you? Of course it would.

Categories
Web Development

Understanding the WordPress Quick Edit Custom Box

Alright, I have to confess. This took me some time to wrap my head around. It also seemed like a lot of people were having the same problem. The question is “How do I add custom post meta fields to the quick edit function in WordPress?” For some reason, I had a hard time finding […]

Categories
Web Development

Use PHP STRISTR To Stop Comment Form Spammers

It’s not often that spam gets past my defenses. However, when it does, it’s really annoying. So today I set out to stop comment form spammers from submitting forms with one or more links. PHP’s STRISTR searches a string for anything that matches your search. So, searching for “http://” will return true if it is […]

Categories
Web Design Web Development

WordPress Pagination With Bootstrap

I love Bootstrap. I also love WordPress. One issue I came across in my WordPress theme development using Bootstrap was the pagination styling. It wasn’t complete, and some edits needed to be made in order for it to look right.