I’ve heard many times that PHP doesn’t really do Unicode, or not properly. In seven years of working primarily in PHP, always in UTF-8, I’ve never really hit a problem, so I always figured it was something esoteric and unimportant for me. But already this year I’ve seen this problem twice, in different ways.
SWMBO has a pile of PDF documents to process and extract information from, and over 50 of them are scanned which means — NO COPY/PASTE! Unless we rescan with OCR of course. On Windows, she’d probably just use Acrobat, but on Linux…
Running a blog, even a low-volume out-of-the-way blog like mine, attracts spammers. It’s a simple fact of life. If you have comments turned on, you will get spam. There’s lots of ways to deal with that, but no way to stop it coming. Lately, it’s been hammering the server hosting my blog, so I decided to change how I was dealing with spam by essentially outsourcing most of the problem to Disqus.
WordPress custom post types can be very useful for storing all sorts of different types of data in WordPress — and I should really write a post about that some time. But the date a post was published, i.e. its post_date, isn’t important for many custom post types. So why have a drop-down list of dates to filter your custom posts types by if you don’t need it?
Session storage is a very handy tool for caching content fragments retrieved via AJAX. Once we’ve pulled the content once, and stuffed it into session storage, we can access it again quickly without the overhead of a round trip to the server. But what if we want to limit the age of that content, so that it expires before it gets too stale?
WooCommerce uses HTML5 number fields for shop quantities, because they restrict the characters you can enter, and Safari on iPad/iPhone conveniently shows the number keyboard. Webkit and Opera/Presto add spinners (up/down arrows) to HTML5 number fields. WooCommerce also adds +/- buttons surrounding qty fields, because IE and Firefox don’t add spinners. WooCommerce then uses CSS to hide the spinners on Webkit:
I’ve been using the fabulous WP Migrate DB Pro since June; it makes it really easy to duplicate the data from one WordPress website onto another, something that developers need to do frequently, and it handles the problems of moving serialised data from one server to another without breaking it. When pulling data from a production server to a development or test environment, it also (by design) replaces all your settings, which might mean that test emails go to your clients — can anyone say, “Dear Rich Bastard?” Thankfully, it also offers a couple of save-your-backside solutions.
I struck an odd problem recently with some code using closures. I use closures extensively for WordPress filter and action hooks when building custom plugins and themes for websites, and all usually works well on any version of PHP from 5.3 up. But I was finding that my closures weren’t being called on some PHP 5.4 websites. The problem was eAccelerator.
When integrating non-WordPress PHP software into WordPress, sometimes the two butt heads over little things; pagination is one such thing. WordPress likes to move pagination into the pretty URL and out of query parameters. If your non-WordPress software generates content with URLs that have page= in query parameters, that means a redirect each time such a URL is fetched. A little regular expression magic can help fix that, with some assembly required.
Gravity Forms plus its PayPal add-on make for a very easy donations form (and so does my Gravity Forms eWAY add-on). But the PayPal item description is pretty formulaic, and probably doesn’t represent the donation very well especially when there are multiple options. A simple filter hook with a few lines of code can easily fix that though.