Core Blocks Enhancer

WordPress core blocks, with the options they are missing

Core Blocks Enhancer is a free WordPress plugin that adds accessibility, SEO and performance options to the Gutenberg blocks you already use. No new blocks to learn, nothing changes until you turn an option on.

What the plugin adds to each block

Each option lives in the sidebar of the block it applies to.

SEOPerformance

Image SEO and lazy loading

Image and Media & Text blocks, "SEO & Performance" panel

Use for ranking adds aria-hidden="true" to an illustrative image, so its alt text can be written for search engines without being read by assistive technologies.

Lazy load, on the Image block, forces loading="lazy" and removes any fetchpriority attribute.

The Use for ranking toggle in the image block sidebar
SEO

Link obfuscation

Button and Paragraph blocks, "SEO Options" panel

Removes the links from the markup served to robots. Each href is replaced with a base64 encoded attribute, and a small front script opens the URL on click or on Enter.

<a is="obf-link" role="link" tabindex="0"
   encoded-url="aHR0cHM6Ly9leGFtcGxlLmNvbQ==">Link</a>
  • Links stay focusable, and Ctrl/Cmd + click opens them in a new tab.
  • On a paragraph, the option applies to every link it contains.
  • The front script is disallowed in robots.txt.
The Obfuscate toggle in the block sidebar
DesignAccessibility

Button icons and aria-label

Button block, "Button icon" and "Accessibility" panels

Pick any image from the media library and place it left or right of the button text.

  • SVG icons are used as a mask, so they can take a color or a gradient from the theme palette. "Don't replace colors" keeps the colors of the file.
  • Other images are cropped to the icon size, with a 2x version for high density screens.
  • Size is 16, 24 or 32px, or any custom value.
  • The gap between icon and text is the --button-gap custom property, 8px by default.

Button label adds an aria-label to the button link.

The Button icon panel with placement, color and size settings
Accessibility

Aria heading level

Heading block, "Accessibility Options" panel

Overrides the level announced to assistive technologies with role="heading" and aria-level, so a heading can look like an h2 and be announced as an h4.

"None" sets role="presentation" to take the heading out of the document outline.

The heading level select in the heading block sidebar
AccessibilityAutomatic

Accessible table headers

Every <th> of the Table block gets scope="col".

PerformanceAutomatic

Lazy YouTube embeds

The YouTube iframe is replaced with a link showing the video thumbnail. The player is only loaded when the visitor clicks it, so nothing from the YouTube player is downloaded on page load.

  • Supports youtu.be/ID, youtube.com/watch?v=ID, /embed/ID, /shorts/ID and /live/ID URLs.
  • On connections slower than 4G, when the browser reports it, a low resolution thumbnail is used and the link opens YouTube in a new tab.
  • Ctrl/Cmd + click always opens the video on YouTube.

To run something before the player loads, such as asking for consent, define window.onYoutubePlaceholderClick. It receives the click event and must return a promise. The player loads when it resolves, and nothing happens if it rejects.

window.onYoutubePlaceholderClick = (event) => new Promise((resolve, reject) => {
  hasConsent('youtube') ? resolve() : askConsent('youtube').then(resolve, reject);
});
Accessibility

Text language

Setting the lang and dir of a text selection is handled by the core "Language" format since 1.9.0. Content created with the plugin's previous toolbar button keeps its attributes when edited.

Install the WordPress plugin

Requires PHP 7.4 or later. The built files are in the repository, so there is no build step.

  1. With Composer. The package is not on Packagist, so declare the GitHub repository first.

    composer config repositories.core-blocks-enhancer vcs https://github.com/corentin-gautier/core-blocks-enhancer
    composer require cgsoft/core-blocks-enhancer

    The package type is wordpress-plugin. It lands in your plugins folder if the project uses composer/installers, as Bedrock does, and in vendor/ otherwise.

    Or with Git. Clone the plugin into your plugins folder.

    cd wp-content/plugins
    git clone https://github.com/corentin-gautier/core-blocks-enhancer.git
  2. Activate Core Blocks Enhancer in the Plugins screen.

  3. Open a post and select an image, button, paragraph or heading. The new panels are in the block sidebar.

The robots.txt rule that hides the front script from robots targets /wp-content/plugins/core-blocks-enhancer/. If the plugin is installed elsewhere, as with Bedrock's app/plugins, add your own rule for build/front.min.js.