WooCommerce: Hide a Shipping Method Based On User Role

Sometimes, it’s necessary to hide a shipping method in WooCommerce.

A client of mine offers local pickup only to a select group of customers. His business doesn’t have a showroom. The majority of his sales are on-line; however, he does sell to a few local businesses who prefer to pick up their orders in person. He’d been using a free-shipping coupon for those customers who picked up their orders at his shop, which works, but is more trouble for the customer than a custom user-role capability.

The example below shows how to hide the shipping method “Local Pickup” from all but users granted a specific user role capability using Vladimir Garagulya’s plugin User Role Editor to set and manage the custom user role capability.

Continue reading “WooCommerce: Hide a Shipping Method Based On User Role”

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”

Fix: WordPress 5.0.2 Gallery Block Images Expand to Fill a Row

I haven’t been able to discover the rationale behind it, but the developers of the Gallery Block for WordPress 5.x, at least up until version 5.0.2, decided that images should expand to fill a row in the gallery.

WordPress Gallery Block Images Expand to Fill a Row
Gallery Block: with Flex-Grow Set to One

If, for example, you have a Gallery Block with the columns set to three, and there is a row with less than three images in it, the images will expand proportionally to fill the available space. Two images will expand to fill half the space, and one image will expand to fill the entire width of the column.

As you can see in the image “Gallery Block: with Flex-Grow Set to One,” the bottom row of the Gallery Block is filled with a single image that has expanded to fill the entire row. It’s not a particularly bad effect, but it certainly takes away from the images that aren’t so large.

My clients were not happy.

Continue reading “Fix: WordPress 5.0.2 Gallery Block Images Expand to Fill a Row”

Hide the Contact Form 7 Google v3 reCAPTCHA Badge

Google version 3 reCAPTCHA Badge

With the release of version 5.1 of Contact Form 7, Google’s reCAPTCHA version 3 (v3) became the default. Google’s reCAPTCHA v3 does away with the “I’m not a robot” checkbox on contact form pages, but it loads and runs on every page, adding an obtrusive badge, well, everywhere.

Google explains that the more pages the reCAPTCHA v3 script runs on, the more accurate it will be in determining whether visitors are human or bots. In their FAQ, they also state that the badge can be hidden, but, “You are allowed to hide the badge as long as you include the reCAPTCHA branding visibly in the user flow.”

That seems reasonable. So what’s the best way to hide the badge everywhere but on the contact form page(s)?

Continue reading “Hide the Contact Form 7 Google v3 reCAPTCHA Badge”

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”