WordPress: Make Major Page and Post Edits Safely

If you’re like me, since the Gutenberg editor came out with WordPress 5.0, every time you edit an old page or post and see that “Classic Block,” you have trouble resisting the temptation to click the “Convert to Blocks” link.

Maybe you just have some major edits to do on an old page, or you want to convert a post with a whole slew of individual images to a Gallery Block.

If you leave WordPress’ revisions enabled, you’re already in pretty good shape; however, in order to keep my WordPress’ databases as small and streamlined as possible, one of the first things I do when installing WordPress is to disable revisions. I needed another way to prevent major edits from becoming major hassles.

Fortunately, WordPress makes it easy to create a backup of a single page or post, and you don’t even need an extra plugin to do it.

Continue reading “WordPress: Make Major Page and Post Edits Safely”

WordPress Twenty Sixteen Search Widget Slider

Twenty Sixteen Search Widget Slider

I really like WordPress’ Twenty Sixteen default theme. It’s clean, well-designed, and versatile. With a child theme based on Twenty Sixteen, customizations are easily accomplished. I’ve used it as the basis for several sites. There is one thing I like to change.

Most sites need a Search widget. The logical place to put a Search widget on a Twenty Sixteen site is at the top of the Sidebar widget position. However, on mobile devices, all the widgets in the Sidebar position, including the Search widget, are inconveniently moved below the main content. That’s actually a good thing for a blog; it’s best to have the freshest content up top. It’s not so good for a site whose visitors rely heavily on search results to navigate the site.

Continue reading “WordPress Twenty Sixteen Search Widget Slider”

Send a Notification Email When a Woocommerce Customer Changes Their Address

Envelope

Note: There is a newer version of the code in this post tested with WordPress 5.2.4 and WooCommerce 3.8 in the post WooCommerce 3.8: Send a Notification Email When a Customer Changes Their Address.

I have a client who runs a subscription-based business on a WordPress site using WooCommerce. Since some of his subscriptions last a year or more, increasing the likelihood that a customer’s address might change, he wanted to be notified by email if the customer used the WooCommerce change-of-address form.

While it’s possible to add a custom email notification class so that the email notification will show up in WooCommerce -> Settings -> Emails, I really just needed something simple, and didn’t mind that the recipient email address would be hard-coded. I came up with the following code snippet, which does the trick in WordPress 4.6 and WooCommerce 2.6.4.

Continue reading “Send a Notification Email When a Woocommerce Customer Changes Their Address”

Undefined Index: SCRIPT_NAME

Which PHP

A WordPress plugin on one of my client’s sites was filling up the error log with a PHP error “undefined index” for the server variable SCRIPT_NAME. The error persisted through a number of plugin updates. I found that I could work around it by editing the plugin’s code and substituting the server variable PHP_SELF instead of SCRIPT_NAME, but it was a hassle to modify the code for the plugin every time there was an update, and I wanted to find a permanent fix.

Continue reading “Undefined Index: SCRIPT_NAME”

This Is Somewhat Embarrassing, Isn’t It?

Title Variable

It was not only embarrassing; it was puzzling.

I was contacted by a client whose site was returning the dreaded WordPress “this is somewhat embarrassing, isn’t it?” 404 not found error message whenever he tried to access some of his pages. The affected pages all included custom variables in the URL following pretty permalinks based on the post name.

Continue reading “This Is Somewhat Embarrassing, Isn’t It?”