Skip to Main Content

PHP

Disable Attachment Pages the WordPress Way

One of the oddest remnants of the early versions of WordPress are attachment pages. I can count on one finger the number of times I’ve thought “I’d like a dedicated page for every image on my site”. Normally, unused and illogical features like this can just be ignored. However, attachment pages aren’t just a harmless remnant of a bygone era.

Attachment pages have dedicated urls, that are based on the name of the image, and overlap with the slugs you can set for posts, pages, and custom post types. Because of this, if you upload an image named faq.jpg, you may find yourself unable to add a page at the address /faq. This can negatively impact your SEO, and is an incredibly frustrating issue to try to identify and explain to clients. Beyond the URL issue, they are another template that needs to be fully themed and branded, just in case a client runs across the page by accident. As such, they need to die. read more »

The Gutenberg that could have been

I have been very vocal in the WordPress community about the fundamental issues I see with the new visual editor being bundled with version 5.0. One response I keep hearing is “how would you do it differently?” So, I thought I’d outline a hypothetical roadmap for the Gutenberg that might have been. read more »

Use Carbon Fields on Cloudways

I recently attempted to use Carbon Fields to generate custom metaboxes for a site hosted on Cloudways with PHP 7. I discovered, much to my dismay, that cloudways doesn’t support some of the multi-byte string functions in PHP (namely mb_strtolower) which is required for Carbon Fields.

For the benefit of those googling for answers, the site shows a blank white screen, and the error log contains PHP Fatal error: Uncaught Error: Call to undefined function Carbon_Fields\\Field\\mb_strtolower()

I’ve had no luck so far working with the CloudWays support team, but I will update this post if I hear back from their tier 3 technicians. I also reached out to HTMLburger, the makers of Carbon  Fields, to see if they can implement a workaround internally.

In the mean time, I was able to get the plugin running by importing the mb_string shim class from Patchwork Framework, by Nicolas Grekas. I’ve included a modified single file version of the shim with support checking added for each function, that you can import into your project to get Carbon Fields working, until Cloudways resolves the problem properly.

This is not a perfect replacement, as it is UTF-8 centric, so may behave unexpectedly with other character encodings, but it will at least get you up and running. Please, Cloudways, fix this.

read more »

Improving WordPress Part 3 – SoC & The Editor (A suggestion to Core)

If you already know all about the WordPress editor, you can skip directly to the section on separation of concern.

The WordPress editor is a curious beast. It’s oddly tied down into the core codebase, despite being a completely external project (TinyMCE), and it has given rise to a significant number of hacks and workarounds, to try to support the various workflows of different WordPress users. Since 2017 is the year for WordPress core to focus on the editor, I thought I’d put down some thoughts, in the hopes that I might help inform some decisions. read more »