webdev

Order Posts via

A request we are getting more often is to show a list of posts, to elevate some of those posts above others, and to show the posts in a random order. Imagine a post type called "Sponsors". Sponsors are tiered, like "Platinum", "Gold", "Silver", etc. We want the Platinum sponsors to appear before Gold, Gold before Silver, and so on. We don't want to favor one particular Platinum sponsor though, we want them to be randomized but ordered by the tier.

Continue reading →

Regular Expression of the day

(?!(([1,2,3,4,5,6,8,9,0])\2{9}))(?!((1234567890|0987654321)))(((\+?\d{1,2}[\s.-])?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4})|(\d{10,})) Match generic US phone numbers. Ignore 1-9 repeating (ie: 4444444444, 1111111111, (except 7, we want 7777777777 for testing)). Allow for spaces, no spaces, dashes, or period delimiters. Of course we _should_ use a standard phone number regex, but of course this project calls for something unique. RegEx is weird, but fun.

Technical Documentation for a Web Development Project

Working on a large web development project requires that you have clear direction and good technical documentation. The designer needs to understand the functional requirements and the data model in order to deliver a successful design. The themer need to understand the UI/UX spec in order to deliver accurate and functional markup. The developers need to understand the functional requirements and data model in order to build out the CMS backend.

Continue reading →

TLS Peer Verification w/PHP 5.6 and WordPress SMTP Email plugin

We ran into an issue after upgrading from PHP 5.5 to 5.6. We were no longer able to send email via the awesome WordPress SMTP Email plugin. Turns out that PHP 5.6 introduced some enhancements to its OpenSSL implementation. Stream wrappers now verify peer certificates and hostnames by default. This was causing the form submissions on our site to fail. Clearly there are some issues with our Postfix config and certs.

Continue reading →

Capistrano tasks for Magento

Custom tasks for Capistrano that I am using to help manage a Magento website. set :linked_files, %w{app/etc/local.xml .htaccess robots.txt} set :linked_dirs, %w{sitemap var media} namespace :mage do task :restart do on roles(:app) do execute "cd #{current_path} && rm -f maintenance.flag" end end task :disable do on roles(:app) do execute "cd #{current_path} && touch maintenance.flag" end end task :enable do on roles(:app) do execute "cd #{current_path} && rm -f maintenance.flag" end end task :clear_cache do on roles(:app) do execute "

Continue reading →

Creating link tags with hreflang attributes in CraftCMS

I want to preface this with the following; I think CraftCMS is a poor CMS. I dislike many things that it does and cannot recommend it as a professional CMS. Having said, that, I am working with it a lot these days at work and recently had to add link tags with hreflang attributes to the head. For some reason the CMS does not do this for you. SproutSEO does not do this either.

Continue reading →

A WordPress ajax handler for custom themes

Something I have been noodling on is a better way to handle ajax requests in my custom themes. Seems to me that a relatively complex theme ends up with a lot of add_action calls for custom ajax handlers, and this could be simplified/reduced. Every time a new endpoint is required we have to add two new add_action calls to our theme. Maybe a better approach is to write a single ajax endpoint that will route requests to the proper classes/methods?

Continue reading →

What to do when your website is hacked/exploited

So your website has been "hacked"? You load your website in your browser, and are redirected to some spammers website, or maybe you google'd yourself (naughty), and found a few thousand indexed pages for knock off prada gear? Ok, so how do you fix this, and more importantly, how do you learn how they did it so you can defend against it later. Secure the scene The first thing I do is take a snapshot of the hacked web site.

Continue reading →

Virtualbox Bug related to SendFile

I have been doing more web development with Vagrant and VirtualBox. It's a nice way to keep my dev environment nearly the same as my production environments. Recently I was doing some front-end coding and was running into the most bizarre errors with my JavaScript. It pays to read the documentation. Had I read it more thoroughly, I would have known about this before debugging it and wasting time. Oops!

Continue reading →