A Week in Core – September 20, 2021

Welcome back to a new issue of Week in CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress.. Let’s take a look at what changed on TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress. between September 13 and September 20, 2021.

  • 21 commits
  • 42 contributors
  • 31 tickets created
  • 0 tickets reopened
  • 23 tickets closed

The Core team is currently working on the next point (5.8.2) and major (5.9) releases 🛠

Ticketticket Created for both bug reports and feature development on the bug tracker. numbers are based on the Trac timeline for the period above. The following is a summary of commits, organized by component and/or focus.

Code changes

BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. editor

  • Cache global stylesheet by theme key – #53175

Build/Test Tools

  • Expect an absolute path in WP_TESTS_PHPUNIT_POLYFILLS_PATH constant – #46149
  • Improve messaging when PHPUnit Polyfills cannot be found – #46149
  • Improve messaging when PHPUnit Polyfills do not comply with version requirements – #46149
  • Make WP_TESTS_PHPUNIT_POLYFILLS_PATH more flexible – #46149
  • Reworks Tests_Option_Option::test_bad_option_names() into data provider – #53635

Bundled Themes

  • Twenty Eleven: Set a fixed height for search form when headerHeader The header of your site is typically the first thing people will experience. The masthead or header art located across the top of your page is part of the look and feel of your website. It can influence a visitor’s opinion about your content and you/ your organization’s brand. It may also look different on different screen sizes. image is added – #40398
  • Twenty Seventeen: Make blogblog (versus network, site) header margin more specific on front page – #43628
  • Twenty Twenty-One: Add missing escaping for the “Secondary menu” label – #54127

Coding Standards

  • Code Modernization: Fix “passing null to non-nullable” deprecation notice in WP_Comment_Query::get_comment_ids()#53635
  • Rename the $arrURL variable to $parsed_url in WP_Http::request()#53359
  • Rename the $arrURL variable to $parsed_url in WP_Http_Cookie::__construct()#53359
  • Rename the $arrURL variable to $parsed_url in WP_Http_Streams::request()#53359
  • Rename the $processedHeaders variable to $processed_headers in WP_Http::request()#53359
  • Use strict comparison in wp-inclues/class-wp-http-cookie.php#53359

Documentation

  • Update description for the $wp_version global – #53413

Embeds

  • Add Pinterest as a trusted oEmbed provider – #53448

Internationalization

  • Add a translator comment to clarify the “Block HTMLHTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers.” string in the Block widgetWidget A WordPress Widget is a small block that performs a specific function. You can add these widgets in sidebars also known as widget-ready areas on your web page. WordPress widgets were originally created to provide a simple and easy-to-use way of giving design and structure control of the WordPress theme to the user. settings form – #54110

Media

  • Fix $content parameter default value in img_caption_shortcode()#53635

Options, MetaMeta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. APIs

  • Fix “passing null to non-nullable” deprecations to (get|add|update|delete)_option()#53635

Upgrade/Install

  • Create a temporary backup of plugins and themes before updating – #51857

Props

Thanks to the 42 people who contributed to WordPress Core on Trac last week: @hellofromTonya (9), @jrf (8), @lucatume (4), @schlessera (4), @jeherve (4), @sabernhardt (3), @mukesh27 (3), @SergeyBiryukov (3), @pbearne (2), @azaozz (2), @dd32 (2), @muhammadfaizanhaidar (2), @NekoJonez (1), @Amieiro (1), @knutsp (1), @johnbillion (1), @namith.jawahar (1), @ayeshrajans (1), @laurelfulford (1), @hirofumi2012 (1), @jainnidhi (1), @mai21 (1), @fedepia (1), @Soean (1), @francina (1), @a2hosting (1), @Boniu91 (1), @richards1052 (1), @galbaras (1), @KZeni (1), @pento (1), @mikeschroder (1), @audrasjb (1), @TimothyBlynJacobs (1), @poena (1), @pbiron (1), @afragen (1), @aristath (1), @joedolson (1), @oandregal (1), @teucrium (1), @lukecavanagh (1).

Congrats and welcome to our 7 new contributors of the week: @NekoJonez, @Amieiro, @namith.jawahar, @mai21, @richards1052, @KZeni, and @teucrium ♥️

Core committers: @sergeybiryukov (11), @hellofromtonya (8), @pento (1), @jorgefilipecosta (1).

#5-8-2, #5-9, #core, #week-in-core

On layout and content width in WordPress 5.8

WordPress 5.8 introduces Global Settings and Global Styles. They allow theme authors to control and style the available features in the editor and the different blocks using a theme.jsonJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML..

By using a theme.json file, in addition to the Global styles and settings capabilities, theme authors opt-in into the layout feature for blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. containers.

Layout config

Historically, themes had the responsibility to provide CSSCSS Cascading Style Sheets. styles in order to support aligning content (left, right). With the introduction of the block editor in WordPress 5.0, new alignments has been added to the mix (wide, full). In addition to that, the block editor allowed users to use container blocks (group, columns blocks) which potentially can change how their inner blocks are positioned and aligned. Taking all these variations into consideration has become a very difficult task for theme authors. To address these issues, WordPress 5.8 introduces the layout feature and config.

How do I migrate my theme

Themes that have a centered content area, need to define a layout setting in their `theme.json` file:

{
   "settings": {
       "layout": {
           "contentSize": "800px",
           "wideSize": "1000px"
       }
   }
}  

The block-editor will automatically read this config and provide the corresponding styles in the editor. It will allow all alignments to work properly without requiring the `add_theme_support( ‘align-wide’ )` call.

Themes are still required to provide the corresponding styles in the frontend of their sites, something like:

.entry-content > * {
    max-width: 800px;
    margin-left: auto !important;
    margin-right: auto !important;
}

.entry-content > .alignwide {
    max-width: 1000px;
}

.entry-content > .alignfull {
    max-width: none;
}

.entry-content > .alignleft {
    float: left;
	margin-right: 2em;
}

.entry-content > .alignright {
    float: right;
	margin-right: 2em;
}

Note:

It’s not possible for WordPress to generate these styles automatically for all themes because the entry-content className in the example above is not mandatory and may not exist. In the future, with the introduction of the upcoming block themes, these styles won’t be needed anymore.

Nested Blocks

For themes with the layout config enabled, container blocks (like group blocks) do not automatically inherit the layout config. Meaning the blocks added inside the containers will by default take all the available space and not have any wide/full alignments options unless the user defines the wide and content sizes for that particular container block or “inherits” the config from the default layout.

This also means that themers can drop any alignment specific CSS that was added specifically to support nested blocks.

#5-8, #dev-notes, #gutenberg

Upgrade/Install component meeting agenda for September 21, 2021

The next meeting is scheduled on Tuesday, September 21, 2021, at 17:00 UTC and will take place on the #core-auto-updates SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. channel.

The aim of the meeting is to discuss the four years old ticketticket Created for both bug reports and feature development on the bug tracker. #22316 and two PRs that have been proposed to solve it.

Let’s try something different! A Zoom call 🙂 I will drop the link to it in the Slack channel at the start of the meeting.

Got something to propose for the agenda? Please leave a comment below.

See you there!

#core-auto-updates, #updater, #upgrade-install

Navigation Editor Hallway Hangout: compare/contrast the old and new screens

Date: August 24, 2021, at 09:00 UTC

Format: Zoom (recorded). A link will be shared in the #feature-navigation-block-editor slack channel shortly before the meeting is due to commence.

Length: 45 – 60mins. No more.

Topic: comparing and contrasting the classic menu screen with the experimental blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience.-based navigation screen.

Goal: derive a list of tasks that are required in order for the two screens to have feature parity (from both UXUX User experience and UIUI User interface perspectives).

Facilitator(s): 

Intended Audience: past and future contributors to the navigation editor and block. Contributors to other related parts of WordPress.

Note Taker: any volunteers to be the official note keeper?

Preparation:

Please could participants test drive the old and new screens. Try creating the same menus on both screens.

Then come prepared with features they feel are missing from the block-based Navigation screen that are present in the classic Menu screen, or any bugs encountered.

Image showing both the new and current navigation experiences with text saying "A new navigation editing experience is coming...".

Agenda

Introduction

  • Facilitator introductions.
  • Welcome to attendees.
  • Recap hangout topic and goal.
  • Terminology – block-based vs classic Navigation screens.

Format

  • Explain the format.
  • Facilitator will share screen to demonstrate which parts of the experience are being discussed.
  • Questions to consider about the new screen:
    • Where is it lacking polish?
    • What bugs are in evidence?
    • What steps are harder to achieve?
    • What steps are not possible to achieve?
    • What steps are easier to achieve?
    • What features are entirely missing?

Summary

  • Brief summary of key discussion points from notetaker.
  • Summary of action points including Issues to be created or further explorations required.
  • Next steps.
  • Thanks.

#block-editor, #feature-navigation-block-editor, #gutenberg, #menus

Editor Chat Agenda: 15 September 2021

Facilitator and notetaker @ajitbohra

This is the agenda for the weekly editor chat scheduled for Wednesday, 15 September 2021, 14:00 UTC.

This meeting is held in the #core-editor channel in the Making WordPress SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/..

  • WordPress 5.9 Preliminary Roadmap.
  • GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ 11.5.0.
  • Whats next in Gutenberg? (Will be posted after 11.5.0 release)
  • Updates based on updated scope for site editing projects and WP 5.8:Navigation BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. & Navigation Editor.
    • Template editor.
    • Patterns.
    • Styling.
    • Mobile Team.
  • Task Coordination.
  • Open Floor.

Even if you can’t make the meeting, you’re encouraged to share anything relevant for the meeting in the comments below:

  • If you have anything to share for the Task Coordination section, please leave it as a comment on this post.
  • If you have anything to propose for the agenda or other specific items related to those listed above, please leave a comment below.

#core-editor #core-editor-agenda #agenda #meetings

Core Editor Improvement: Cascading impact of improvements to featured images

When a new feature is added, it’s easy to see what the feature does right now rather than the many things it allows you to do, particularly when combined with other tools. This is especially true as design tools continue to evolve! This post offers a quick dive into how improvements to the Featured ImageFeatured image A featured image is the main image used on your blog archive page and is pulled when the post or page is shared on social media. The image can be used to display in widget areas on your site or in a summary list of posts. blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. lead to more possibilities for content creation. 

Greater control of posts layout

Thanks to some recent changes to the Featured Image block, the Query LoopLoop The Loop is PHP code used by WordPress to display posts. Using The Loop, WordPress processes each post to be displayed on the current page, and formats it according to how it matches specified criteria within The Loop tags. Any HTML or PHP code in the Loop will be processed on each post. https://codex.wordpress.org/The_Loop. block just got even more powerful. As a reminder, the Query Loop block is an advanced block that allows you to display posts based on various parameters and was released in WordPress 5.8. Within the Query Loop block, different blocks, like the Featured Image block, can be placed within it to show the Featured Images for each post listed. While you’ve been able to control the general placement of the Featured Image, until GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ 11.3, you couldn’t control the basics of the resulting image. This came up a few times during testing with the FSE Outreach Program as a pain point with folks wanting deeper customization options. Now, you can control the sizing and scale of the image to your liking opening up the beginnings of a new world of layout options!

Video showing the new Featured Image Block options within the Query Loop block.

More options when creating templates

This change also impacts anyone using the Template Editor as you can now customize how the Featured Image shows up in a template you created. This is just a start too with more size tooling planned for the Featured Image block. Most recently too, the ability to add duotone filters to spruce up your images with endless color options was included in Gutenberg 11.4. Just like with the Query Loop block example above, this allows you to add a Featured Image block with a duotone filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. added and then apply that to any post or page you’d like so all posts have the same duotone shading:

Video showing the new Featured Image Block options within the Template Editor.

Thank you @shaunandrews for the design assist & @kellychoffman for help with the copy.

#core-editor, #core-editor-improvement

Editor Chat Agenda: 8 September 2021

Facilitator and notetaker: @andraganescu

This is the agenda for the weekly editor chat scheduled for Wednesday, September 8 2021, 04:00 PM GMT+1.

This meeting is held in the #core-editor channel in the Making WordPress SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/..

  • What’s new in Gutenberg (11.4).
  • GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ 11.5 RC will be released Wednesday.
  • Whats next in Gutenberg: July and August. (September version has not been posted yet.)
  • Updates based on updated scope for site editing projects and WP 5.8:
    • Navigation BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. & Navigation Editor.
    • Template editor.
    • Patterns.
    • Styling.
    • Mobile Team.
  • Task Coordination.
  • Open Floor.

If you are not able to attend the meeting, you are encouraged to share anything relevant for the discussion:

  • If you have an update for the main site editing projects, please feel free to share as a comment or come prepared for the meeting itself.
  • If you have anything to share for the Task Coordination section, please leave it as a comment on this post.
  • If you have anything to propose for the agenda or other specific items related to those listed above, please leave a comment below.

#agenda, #core-editor, #core-editor-agenda, #meeting

Preliminary Road to 5.9

This is a quick overview of the main areas and features currently underway for 5.9 in GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/. Some are in more advanced stages than others, but together they paint a picture of what we are looking forwards to.

To dive deeper into concrete tasks and areas of work, this tracking issue is the best place to follow.

Blocks + intrinsic web design

Collection of various patterns displayed at mobile resolutions.
  • One of the biggest points of friction for pattern and theme builders are the lack of responsive tools available at a blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. level. This needs to be solved in a way that doesn’t disproportionally increase interface complexity.
  • The block model is a good case to apply some intrinsic design principles, since a block can occupy a place in many different layouts and containers, for which prescriptive media queries that don’t take context into account are inflexible.
  • Each block area should be intrinsically responsive allowing blocks to compose together, wrap, stack, and organize themselves to fit the different spaces and screens. For this to work well, container blocks need to absorb more layout controls. (Container queries might help expand this further in the future.)
  • Typography tools need to become more fluid and internally support algorithmic clamping. Whenever possible, patterns should just work and accommodate themselves.

Patterns

Mosaic galleries showing different design patterns.
  • With the initial rollout of the new directory there’s a growing need to expand the inserter integration to accommodate broader categories of patterns and the experience of browsing them.
  • There’s more work to be done within the setup flow of single and multi-block selections. This also includes improving the mechanisms for transforming to and from patterns, which are still nascent.
  • Creation flows with patterns also need expanding from template parts and blocks to pages and templates.

Navigation Menus

  • The navigation block and navigation screen projects have been underway for quite some time and are a main target for 5.9. With the principal tracking issue about to be completed, a large part of the remaining work is to improve the user experience, reduce complexity, and test as much as possible on themes.

An interface for theme.jsonJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML..

Global Styles panel showing the main area and the background color section.
  • 5.8 introduced the scaffolding necessary for themes to take the reins over how various aspects of blocks render and how the interface is controlled. The natural next step ahead is to develop the user interface that will allow users to interact with these style properties. This goes by the project name “global styles” and an updated design is currently in prototype stage.
  • It should be appreciated how important it is to leverage the global reach of CSSCSS Cascading Style Sheets. rules as we combine it with the power of blocks. The current structure deals with two large groups of design targets: blocks and elements. Elements represent things that can be styled globally and across blocks (such as “text”, “links”, “captions”, etc).

Design Tools: Colors, Typography, Spacing, Layout

Series of panels showing different configurations of the typography tools.
  • The effort to bring better and more consistent design tools continues to progress. These tools need to integrate smoothly with both the block APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. (through the “supports” mechanism) and theme.json. One of the main goals is consistent access to similar tools across blocks, including third-party ones.
  • Running parallel to this effort comes the work on the WordPress components system, refinements to color tools, interactivity, accessibilityAccessibility Accessibility (commonly shortened to a11y) refers to the design of products, devices, services, or environments for people with disabilities. The concept of accessible design ensures both “direct access” (i.e. unassisted) and “indirect access” meaning compatibility with a person’s assistive technology (for example, computer screen readers). (https://en.wikipedia.org/wiki/Accessibility), etc.

Formalize editing flows for block themes

Displays templates as small cards in a mosaic, connecting diagrams with the different flows.
  • A large percentage of the infrastructure and features needed to build block themes are established. The UXUX User experience and design needs the most attention, though, starting by mapping into a clearer information architecture all the possible flows that are to be supported (editing templates, parts, styles, pages, etc).
  • Continue to process and take into the design process all the feedback gathered from users and theme builders.
  • Begin defining transition flows from existing widgetWidget A WordPress Widget is a small block that performs a specific function. You can add these widgets in sidebars also known as widget-ready areas on your web page. WordPress widgets were originally created to provide a simple and easy-to-use way of giving design and structure control of the WordPress theme to the user. areas to block areas when appropriate, and explore the various aspects of theme switching.
  • Finalize and commit all remaining blocks under the “theme” categoryCategory The 'category' taxonomy lets you group posts / content together that share a common bond. Categories are pre-defined and broad ranging..

#5-9, #gutenberg

WordPress 5.9 Planning Roundup

Happy September no matter where you are in the world! Since we’re halfway through the alpha period for the next big release of WordPress, it’s time to gather all the pieces of planning into one place. This post will include all the best guesses and targets for dates, features, and squads.

This release will follow the same general cadence as the other releases this year, with a long alpha period (132 days) and a short betaBeta A pre-release of software that is given out to a large group of users to trial under real conditions. Beta versions have gone through alpha testing in-house and are generally fairly close in look, feel and function to the final product; however, design changes often occur as part of the process. period (14 days) before the release candidaterelease candidate One of the final stages in the version release cycle, this version signals the potential to be a final release to the public. Also see alpha (beta). phase.

Proposed WordPress 5.9 Schedule

These are my best guesses at the milestones:

MilestoneDateDays from
Alpha (trunktrunk A directory in Subversion containing the latest development code in preparation for the next major release cycle. If you are running "trunk", then you are on the latest revision. open for 5.9 release)June 30, 2021
Go/no go DateOctober 12, 2021104 days after Alpha
Feature freeze/Bug FixesNovember 9, 202142 days after go/no go
Beta 1November 16, 20217 days after Feature Freeze
Release Candidate 1November 30, 202114 days after Beta 1
General releaseDecember 14, 202114 days after RC1
WP5.9 Schedule

This schedule puts Beta 1 the week of a major US holiday and a few major commerce dates worldwide. It does avoid putting RC1 during that week.

Proposed WordPress 5.9 Scope

The main goal for 2021 is getting full site editing to all WordPress users. For WP5.9 the following features are in the suggested roadmap:

  • Blocks + intrinsic web design
  • Navigation menus
  • Interface for theme.jsonJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML.
  • Refining editing flows for blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. themes
  • New default theme
  • Additional design tools

There are also a few roadmap hopefuls out there.

  • Pattern insertion + creation
  • Unzip/Rollback Failsafes
  • PHPUnit Tests
  • Improved compatibility with PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher 8.0 and 8.1

Proposed WordPress 5.9 Leads

  • Release LeadRelease Lead The community member ultimately responsible for the Release.: Matt Mullenweg
  • Release Coordinators:
  • Triagetriage The act of evaluating and sorting bug reports, in order to decide priority, severity, and other factors. Lead:
  • Editor Tech:
  • Editor Design:
  • CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. Tech:
  • Theme Lead:
  • Technical Writer: Jonathan Bossenger
  • Docs Lead:
  • Marketing & Comms: Josepha Haden
  • AccessibilityAccessibility Accessibility (commonly shortened to a11y) refers to the design of products, devices, services, or environments for people with disabilities. The concept of accessible design ensures both “direct access” (i.e. unassisted) and “indirect access” meaning compatibility with a person’s assistive technology (for example, computer screen readers). (https://en.wikipedia.org/wiki/Accessibility) Lead:
  • Test Lead:

How to help!

I think we will need a slightly larger release squad for this final release of the year, so I’m opening calls for volunteers. As we approach the go/no go date and get a better idea of what features will really land in the release, we’ll get more squad leads assigned.

However, there are a couple of roles we really could use some volunteers for right now:

  1. Triage Lead
  2. Release Coordinators

If you’re interested in lending a hand, please share your interest in the comments!

Props to @francina for early versions of this post, and @jeffpaul + @desrosj for wrestling calendars with me.

#5-9, #planning

Introducing theme.json in WordPress 5.8

WordPress 5.8 comes with a new mechanism to configure the editor that enables a finer-grained control and introduces the first step in managing styles for future WordPress releases.

Controlling settings globally and per blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience.

The introduction of blocks has increased the number of settings agencies and developers may need control over. Having a central point of configuration aims to provide a more consistent and complete experience.

By creating a theme.json file in the theme’s top-level directory, themes can configure the existing editor settings (the font sizes preset, whether custom colors are enabled, etc.) as well as the new ones as they are introduced (the duotone preset, whether margin and padding controls are enabled, etc.).

This new mechanism aims to take over and consolidate all the various add_theme_support calls that were previously required for controlling the editor.

The example below shows how to disable custom colors for all blocks:

{
    "version": 1,
    "settings": {
        "color": {
            "custom": false
        }
    }
}

The addition of the theme.json file also provides a way for theme authors to control these settings on a per-block basis ― something that wasn’t possible before. The example below shows how to disable custom colors for all blocks but enable them for the paragraph block:

{
    "version": 1,
    "settings": {
        "color": {
            "custom": false
        },
        "blocks": {
            "core/paragraph": {
                "color": {
                    "custom": true
                }
            }
        }
    }
}

Top-level settings will apply to all blocks that support the relevant setting. However, block-level settings can also override the top-level settings for a specific block. Blocks are addressed by their block name and settings can be added for coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. as well as third-party blocks.

Note: to retain backward compatibility, the existing add_theme_support declarations from the theme are retrofitted in the proper categories for the top-level section. For example, if a theme uses add_theme_support('disable-custom-colors'), the result will be the same as setting settings.color.custom to false. If a setting is declared in theme.json that setting will take precedence over the values declared via add_theme_support.

See the specification document for a complete list of features and backcompatibility with add_theme_support.

Blocks can access theme settings with useSetting

Core blocks have been updated to respect the new settings coming from a theme via theme.json. For example, if a block supports a UIUI User interface margin control but the theme has disabled margin across the board, the UI control will not be displayed in the editor.

Third-party blocks can also tap into this mechanism by using the useSetting ReactReact React is a JavaScript library that makes it easy to reason about, construct, and maintain stateless and stateful user interfaces. https://reactjs.org/. hook in its edit function:

import { useSetting } from '@wordpress/block-editor';
// Somewhere in the block's edit function.

const isEnabled = useSetting( 'spacing.margin' );

if ( ! isEnabled ) {
    return null;
} else {
    return <ToggleControl ... />
}

See the API docs for useSetting.

CSSCSS Cascading Style Sheets. classes for presets are automatically created and enqueued

Previously, themes had to declare presets for the editor and also enqueue the corresponding classes separately.

In the functions.php file, they’d do:

add_theme_support(
  'editor-color-palette',
  array(  /* define color presets, including translations */
) );

And then, in the style.css:

.has-<value>-color { /* ... */ }
.has-<value>-background-color { /* ... */ }
/* etc */

By using a theme.json, the theme only has to declare their presets. The engine will set up the translations and will take care of creating and enqueuing the corresponding styles to both the editor and the front-end:

{
    "version": 1,
    "settings": {
        "color": {
            "palette": [
                {
                    "name": "Color name",
                    "slug": "color-slug",
                    "color": "<color-value>"
                },
                {
                    "name": "...",
                    "slug": "...",
                    "color": "..."
                }
            ]
        }
    }
}

See the specification document for a list of classes generated by preset.

CSS Custom Properties

By phasing out IE11 support, many CSS features become available. One of these now available features is CSS Custom Properties. When a theme adds presets via theme.json, the engine will enqueue both classes and CSS Custom Properties for them.

The example below:

{
    "version": 1,
    "settings": {
        "color": {
            "palette": [
                {
                    "name": "Black",
                    "slug": "black",
                    "color": "#000000"
                },
                {
                    "name": "White",
                    "slug": "white",
                    "color": "#ffffff"
                }
            ]
        }
    }
}

will create this output in CSS:

/* One CSS Custom Property per preset value. */
body {
  --wp--preset--color--black: #000000;
  --wp--preset--color--white: #ffffff;
}

/* The corresponding classes for each preset value. */

.has-black-color { color: var(--wp--preset--color--black) !important; }
.has-black-background-color { background-color: var(--wp--preset--color--black) !important;  }

.has-white-color { color: var(--wp--preset--color--white) !important; }
.has-white-background-color { background-color: var(--wp--preset--color--white) !important;  }

See the specification document for more examples, how to add and use custom properties unrelated to presets, etc.

Managed styles for improved coordination

One of the struggles theme authors face is the conflicts that appear in an environment with core, theme, and user styles as well as the wide design area that comes with multiple blocks that can be combined indefinitely.

The theme.json file absorbs most of the common use cases for styling blocks with the goal of reducing the amount of CSS shipped to the browser, mitigating specificity wars, and providing current style info in the UI controls for users. This is the first step in having a mechanism that consolidates all the three origins of styles (core, theme, user) and that will become more important once users can provide global styles in later phases of the project.

In the example below, a theme provides styles for the top-level and a couple of blocks:

{
    "version": 1,
    "styles": {
        "color": {
            "text": "var(--wp--preset--color--primary)"
        },
        "blocks": {
            "core/paragraph": {
                "color": {
                    "text": "var(--wp--preset--color--secondary)"
                }
            },
            "core/group": {
                "color": {
                    "text": "var(--wp--preset--color--tertiary)"
                }
            }
        }
    }
}

It results in the following CSS output:

/* Top-level styles resolve to the body selector. */
body {
  color: var(--wp--preset--color--primary);
}

/* Block styles resolve to the block selector. */
p {
  color: var(--wp--preset--color--secondary);
}
.wp-block-group {
  color: var(--wp--preset--color-tertiary);
}

Any block, both core and third-party, can be targeted by its name.

See the specification document for a complete list of supported styles.

Access to other features

There are some features that are enabled or disabled when a theme has support for a theme.json file:

  • The template editor is enabled.
  • The default layout and margin styles for themes are not enqueued and the new layout options are enabled instead (see related dev note for layout).
  • The inner div for the group block (wp-block-group__inner-container) is removed.
  • The default font-family styles for the editor are not enqueued.

#5-8 #dev-notes #gutenberg