Porchy Web Development

WordPress Category

Updating Webpack to use WordPress editor blocks (Gutenberg blocks) on the front end (part 4 of 4)

Getting blocks running on the front end is, or should be, mainly a matter of updating Webpack to create the script to run on the front end, then enqueuing it so it does. However, I’ve always found it requires some fixing of things that don’t work quite right together, that I’ve misnamed or otherwise mismatched …

Setting up wp-browser with WPWebDriver for full site acceptance testing (notes for my future self)

These are my notes on getting WPWebDriver in wp-browser set up to work for me. They supplement rather than replace the wp-browser documentation. If you are having issues and haven’t started there and followed the directions, I highly recommend doing that first. Inifinum also has a super helpful section on setting up wp-browser.

Using a scaffold to build Gutenberg blocks for the WordPress editor (part 1 of 4)

Block scaffolds are being created, updated or going out of date at a regular rate these days as developers figure out what works best for them. So instead of making a recommendation on which one you should use, I’m going to tell you what I looked for – what was important to *me at the …

WooCommerce Subscriptions: not able to purchase subscription after failed payment [edited on 2021-01-27]

This is a workaround and fix for the following situation which occurs in recent versions (<3.0.12) of WooCommerce Subscriptions. When purchasing a subscription which is limited to “any” (ie a user can only have one subscription of any status), the user cannot pay for a failed order as the subscription product gets removed from their …

Adding Gutenberg / WordPress editor blocks to the front end

People love to play with a little web app on a site. Quizzes, small games, anything to take a break for a minute or two. Wouldn’t it be great to be able to add and edit these in the WordPress editor then reuse the React components on the front end? Yes! The answer is yes. …

WordPress Editor blocks as web apps in Gatsby

This is a proof of concept web app, completely editable in WordPress using the block editor. I think it’s more fun to do it first. (Please let me know if these don’t work, they’re version 0.1. Saving them will save to your browser only.) Fill in the blanks then click “your poem” to see your …

Adding conditional menu items to WordPress menus

Here’s what I wanted to do: give clients the ability to add conditional items to menus and be clear about which users will see which items on the front end menu. For example, I want some menu items which only show for logged in users and some which only show for users who have bought …

What use is anything without columns

As expected, Gutenberg blocks with inner blocks, eg columns, weren’t working. Like other bits, this was somewhat straightforward once I figured out how. It took me a while and with more than a few infinite loops thrown in to make it that much more frustrating. What I ended up is copying the render_blocks function from …

Gutenberg and Gatsby sitting in a tree…

This is about WordPress and the static site generator Gatsby, not the Gutenberg and Gatsby you might know. I’m not sure where that post would go. Anyway. Parsing Gutenberg blocks in Gatsby turns out to be much more straightforward than I thought it would be. Not that it’s completely straightforward, but I didn’t find it …

WP blocks, raw data and the auths

I’m at the point now where I want to try parsing the raw content of the posts with the new editor / Gutenberg block data. The endpoints with posts in both the REST API and wp_graphql contain a field with the data needed but that’s only accessible to users with the edit_posts and maybe a …

Shortcodes? WP Blocks? Server side rendering?

I have a Prism.js block that I quite like, it’s part of a series of goofy ass Gutenberg blocks I made so long ago they probably don’t even work anymore. They’re working again. Most of it was Gutenberg backwards compat breaks, some was other back compat breaks, some was forgetting what I did in the …

Using Gutenberg blocks in place of custom metaboxes in WordPress

Custom metaboxes are used extensively in WordPress for layout purposes as well as data structure. However, they don’t necessarily — in fact they rarely — save to the meta key’s array of objects when they’re added to the WordPress REST API and can’t be used by Gutenberg’s built in meta attribute. How can we use Gutenberg with …

register_meta(), register_rest_field() and the WP REST API

There are two standard ways to add additional data into a post’s object in the WP REST API: register_meta() for post meta which is a string, number or boolean and register_rest_field()for everything else. There’s a bit on the difference between the two in the REST API docs. With Gutenberg, register_meta() is being used more widely and there’s …

Using Select2 with ajax with CMB2 repeating groups

No idea if the title makes sense. I wanted a Select2 which uses a remote data source queried via ajax with a CMB2 repeating group so made a plugin to understand it better. It’s pretty heavily commented so I don’t forget why I did what I did. There are definitely a few if not many …

Using custom tables with CMB2

This is more straightforward than I expected (yay thank you @jtsternberg). The short of it is to add a filter to cmb2_override_meta_value or cmb2_override_{$a[‘field_id’]}_meta_value to get the data and cmb2_override_meta_save to save it. But what if I have a repeatable group huh? What then?

Gutenberg wish list

Ok, this is without really looking at it so maybe it has these. identifiable non-global blocks (so not these: https://github.com/WordPress/gutenberg/issues/2081) because I want to maybe use postmeta with a block? I don’t know, I have this vague idea that I’m too lazy to articulate atm. ok this wasn’t bad, I’ve done this. the ability to limit …

Improving Gravatar (the service)

The problem: Gravatar hashes are somewhat easy to crack. Websites are super easy to scrape. Sites with Gravatar urls in the img-src or profile link make it trivial to generate lists of hashes to crack. Other data available on sites and in Gravatar profiles can be used to generate targeted wordlists which make cracking a …

A Slack bot that gets the last three posts from a WordPress site

This Glitch project grabs the latest three posts for WordPress sites which are using either the WP REST API or the WP.com version via Jetpack. It uses MongoDB for persistence. It’s not super exciting or well written but a fairly effective way to mindlessly try sites on Slack and see if they have the WP …

So what’s the difference between WordPress filters and hooks?

Understanding what filters and actions do took me forever, ok, maybe not but longer than I’d care to admit at any rate. It wasn’t the fault of the resources I found, it was just that I couldn’t get my head around it. But one day, PING! I got it. Here is how I understand them. …

Porchy Ltd is a company registered in England, no. 12035925

VAT Registration no. 331196421

Built with WPGraphQL and Gatsby

© 2019 - 2021