How can we help?

Shortcodes

Mindspun payments can be configured with shortcodes. But while not deprecated, shortcodes should definitely be considered the old way of doing things. New development should use Gutenberg blocks – which provide more functionality and can be styled without coding.

How shortcodes work in Mindspun Payments

The shortcodes in Mindspun Payment work in a way that might not be familiar. Shortcodes are designed using Gutenberg blocks, and the resulting content is copied into the shortcode body. This new approach allows the shortcode to have all the power of blocks without requiring a PHP template.

WARNING: Empty shortcodes won’t work! You must use the following process.

How to generate a shortcode

The process works like this:

  • Create a standard page, post, etc., in Gutenberg and add the relevant block. This page doesn’t need to be live or on the same site as the shortcode will be used.
  • Configure the block as you’d like it to look. You can use any child blocks that you so choose or accept the default layout,
  • Click on the top-level block that you just created. A button in the block controls panel will be marked ‘Shortcode’ – all ‘Payments’ blocks have this option.
  • Copy the contents of the shortcode and paste it where you want to use it.

Clicking the ‘Shortcode’ button displays a modal containing the shortcode contents.

Again, this process should only be used when there is a good, known reason to do so (and reluctance to use Gutenberg doesn’t count).

Shortcodes may be added directly into any theme via the do_shortcode() function.

The shortcode block

The generated shortcode will contain block grammar – a bunch of HTML that can be parsed as block objects. If you copy and paste that into the shortcode block, it will work and correctly display on the front end, but when you reload the editor page, the contents will disappear. They’re still there; they just aren’t displayed. Gutenberg incorrectly interprets the contents as other blocks and doesn’t know what to do.

While this clearly isn’t the desired behavior – you could argue it’s either a Gutenberg bug or just a non-standard approach – it shouldn’t be an issue. You’re using blocks anyway. Specifically, the shortcode blocks itself, so instead, use the Mindspun Payments blocks directly.