Discussion: How to handle custom settings screens in block themes

In 2015, the Themes Team implemented a guideline that required all theme settings pages to use the Customize 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.. This was after the API had been in WordPress and stable for nearly three years.

There were two primary reasons for this:

  • It meant that users could expect a standard options interface from any theme in the WordPress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/ theme directory.
  • It simplified the review process because all the code was built on top of the exact same API. This made it easier to check for security issues, in particular, and shorten the time it took to review a theme.

Over the years, this guideline was generally accepted as the best path forward by members of the Themes Team.

In large part, the decision single-handedly cut out the vast majority of insecure settings pages that were being implemented in themes (mostly from a couple of copy-paste scripts that were popular around the web). That was a big win for theme authors, reviewers, and users. The importance of this change is not to be taken lightly and is very much at the forefront of any discussion around theme settings.

Fast forward to today—now eight years later. The Themes Team is at another pivotal moment that could partially shape what the theming landscape looks like for years to come.

A new era: 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 and custom settings screens

When the customizerCustomizer Tool built into WordPress core that hooks into most modern themes. You can use it to preview and modify many of your site’s appearance settings. guideline was introduced, it was during the classic theming era. There was no concept of block themes at the time. While it is possible for a block theme to use the Customize API today, it is no longer part of the expected user experience for users who have activated a block theme.

In fact, there’s no real expectation that a block theme will have any settings screen at all outside of what’s possible via Appearance > Editor in the admin.

Now that the block theming system and the Site Editor are about seven months out of 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., it means that theme authors will continue building more and more block themes. And with that, the Themes Team should expect to see more experimentation around this new paradigm. There really is no guidebook on what to expect as theme authors try to solve both old and new problems in a world that is heavily based on the block system and modern JavaScriptJavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/..

In particular, the expectation is that theme authors will begin trying new things with ReactReact React is a JavaScript library that makes it easy to reason about, construct, and maintain stateless and stateful user interfaces. https://reactjs.org/.-based JavaScript components that are bundled with WordPress. Not only are interfaces changing, but the underlying programming language now involves much more JavaScript.

The discussion: feedback wanted

In the October 10, 2023 meeting, the Themes Team began the discussion on what to do about the settings page requirement going forward. The decision from that meeting was to open the discussion up for feedback from the wider community.

The Customize API requirement is well established for classic themes, so this discussion is solely focused on block themes.

The questions:

  • Should the team loosen the requirement on the current settings page requirement for block themes, allowing experimentation with React components?
  • If so, what guardrails—if any—should be put in place on what themes can do?

It’s also important to frame this conversation within the overall guidelines and not get into the weeds of unrelated topics. For example, settings would still need to fall within “theme territory” (i.e., they should be related to design). The decision that needs to be made is focused solely on the settings page guideline:

Use the Customizer for implementing theme options.

The other thing to be aware of is that any decision to loosen that specific guideline can impact active reviewers. That means making sure that they are up to date on modern WordPress JavaScript coding standards and can handle an upward trend of more themes with heavier JavaScript code bases. Otherwise, the progress over the last few years to have a faster review queue could also be lost. With that in mind, it’s important for any active reviewer to voice any concerns about any potential changes.

Now the floor is yours. How would you handle the settings page guideline for block themes going forward?

Props to @kafleg and @ndiego for feedback and review on this post.

#discussion-topic, #guidelines

Themes Team Meeting Notes – October 10, 2023

Howdy Mates! 

The meeting notes are from the themes review team discussion.

Attendees:

:one:Weekly updates


In the past 7 days
,

  • 625 tickets were opened
  • 637 tickets were closed
    • 626 tickets were made live.
      • 32 new Themes were made live.
      • 594 Theme updates were made live.
      • 3 more were approved but are waiting to be made live.
    • 11 tickets were not-approved.
    • 0 tickets were closed-newer-version-uploaded.

Note: These stats include both the new theme tickets and updated theme tickets as well.

For now, 12 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 are currently being reviewed. In the last 7 days, 9 block themes are live.

Note: These stats include both the new theme tickets and updated theme tickets as well.

The themes team published weekly updates about tickets and HelpScout emails. Here is the theme statistic for the past 7 days. The most current stats can be found here.

Thank you @acosmin@fahimmurshed@vowelweb for reviewing themes this week.

:two:Handle the themes settings page requirement

During the meeting, we talked about various things about this. You can read the entire conversation here. During the meeting, @shivashankerbhatta said, “We could greatly simplify the process of using WordPress by assisting users in selecting and configuring themes for their websites. :slightly_smiling_face:

@greenshady is interested in helping theme reviewers to review the JS part of the theme setting/onboarding page if necessary. Also, he is interested in running mentorship for theme reviewers.

@kafleg was worried on, “All of us saying that theme settings page will add value to the theme users. How we can track that? It is really adding user experience of just adding extra workload for reviewing themes?”

@poena added, “I will repeat that it is not up to a theme developer or pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party developer to solve the onboarding issues. CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. issues should be fixed in core.”

Before deciding to allow or disallow the theme setting page, @greenshady will write a blog post to get feedback from everyone and the themes team will decide after checking the input.

:three:Evaluate requirements of themes

@poena said, “It has been two years. I think the team should evaluate them regularly.” So, during the meeting we all agreed that, we need to evaluate the theme requirements.

Once we get into the #2 agenda final, at that time, we need to work on this #3 as well. Some requirements are really outdated or some need to be added.

:four: Create a skills inventory for reviewers

During the meeting, there were questions:

  • How to create a skill inventory of reviewers’ skills and find and address areas of improvement?
  • How to do it in a way that reviewers are comfortable with it and don’t feel bad if they are not experts on everything?

@greenshady is interested to work alongside folks and help build any training system we might need. He would like to see a Make Themes post to discuss what such a system might look like.

@kafleg added, “We can also divide the work based on the reviewer expertise. Like we are doing for code review and 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) review.”. Also, he added, And we can also run mentorship sessions for reviewers?

We’ll discuss about this idea in next meeting as well.

:five:Open Floor

A few events happening over the next month that will be related to theming:

  • Hallway Hangout on block themes on October 12.
  • Hallway Hangout on WP 6.4 features October 12. Sign up here.
  • Developer Hours on November 2 will cover the Twenty Twenty-Four theme

#meeting-notes, #themes-team

New color-alpha package available

A few months ago we started creating a new color-alpha package for themes that want to use a color picker in the customizerCustomizer Tool built into WordPress core that hooks into most modern themes. You can use it to preview and modify many of your site’s appearance settings. capable of handling rgba colors with opacity.

During the course of these months the concept we were working on evolved and today we’re glad to announce it’s finally available for themes.

RGBA Colorpicker control screenshot

This control uses the react-color color picker, and can serve as an example of how developers can build reactReact React is a JavaScript library that makes it easy to reason about, construct, and maintain stateless and stateful user interfaces. https://reactjs.org/.-based controls for the Customizer.
It is lighter than the default Customizer color picker scripts based on Iris, and there were further performance improvements – namely regarding the instantiation of the control. By default, color pickers get instantiated when the customizer loads. This control, however, will only get instantiated when the section containing it opens, significantly improving performance for themes that use many color pickers in the customizer.

By default, the control works just like any other control and saves a string with the selected color. The format of the saved value will depend on the opacity of the selected color. If the color is completely opaque, then it will save a HEX value (#000000). If the selected color is not completely opaque (has an alpha value smaller than 1) then the value will be saved as RGBA (rgba(0,0,0,0.9)).

Installation

You can find installation instructions in the repository’s readme file.

Usage

This is a control containing a JS template. As such, it should be whitelisted in the Customizer. To do that we can use the WP_Customize_Manager::register_control_type method:

add_action( 'customize_register', function( $wp_customize ) {
	$wp_customize->register_control_type( '\WPTRT\Customize\Control\ColorAlpha' );
} );

After the control is registered with the above snippet, we can use it in the customizer using the Customizer API:

use \WPTRT\Customize\Control\ColorAlpha;

add_action( 'customize_register', function( $wp_customize ) {

	// Add Setting.
	$wp_customize->add_setting( 'your_setting_id' , [
		'default'           => 'rgba(0,0,0,0.5)', // Use any HEX or RGBA value.
		'transport'         => 'refresh',
		'sanitize_callback' => 'my_custom_sanitization_callback'
	] );

	// Add Control.
	$wp_customize->add_control( new ColorAlpha( $wp_customize, 'your_setting_id', [
		'label'      => __( 'My Color', 'mytheme' ),
		'section'    => 'my_section',
		'settings'   => 'your_setting_id',
	] ) );
} );

Sanitization

All controls should be sanitized in the customizer. Since the color-alpha control can save either a hex or an rgba value, we built a custom sanitization callback you can use.

Available filters

By default, the control will work out of the box for any plugins and themes installed in wp-content/themes and wp-content/plugins respectively. If however, the control is not inside the wp-content folder, then you can use the wptrt_color_picker_alpha_url 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. to define its URLURL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org. You can see an example of that in the repository’s readme file.


Everything described above is the default behavior of the control. However, if developers wish, this control can handle a lot more. We added the option to save the value as an array and expose more tools that you can use.

If you want to automate things and do more advanced color calculations, continue reading the section below.

Saving value as an array

Though the default behavior of the control is to save a simple string, developers have the option to save the value as an array. The saved array contains the color properties as well as some extra items that can be used to enhance a theme’s (or pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party’s) 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).

To change the behavior of the control and make it save an array instead of string, users can add 'save_as' => 'array' under the control’s choices:

$wp_customize->add_control( new ColorAlpha( $wp_customize, 'your_setting_id', [
	'label'    => __( 'My Color', 'mytheme' ),
	'section'  => 'my_section',
	'settings' => 'your_setting_id',
	'choices'  => [
		'save_as' => 'array',
	]
] ) );

The value saved will then have the following format:

[
	'r'    => 107, // Red.
	'g'    => 55, // Green.
	'b'    => 119, // Blue.
	'h'    => 289, // Hue.
	's'    => 37, // Saturation.
	'l'    => 34, // Lightness.
	'a'    => 0.82, // Alpha
	'hex'  => '#6b3777', // The HEX code of the color (alpha = 1)
	'css'  => 'rgba(107,55,119,0.82)', // The CSS value of the selected color.
	'a11y' => [ // An array of accessibility-related properties.

		'luminance'                         => 0.0719,

		// Contrast with white (value 0 - 21).
		'distanceFromWhite'                 => 8.613,

		// Contrast with black (value 0 - 21).
		'distanceFromBlack'                 => 2.438,

		// Maximum contrasting color. Use this to get the text-color
		// if the colorpicker is used to select a background-color.
		'maxContrastColor'                  => '#ffffff',

		// Readable text-colors on white background preserving the hue.
		// The 1st value has a minimum contrast of 7:1 with white.
		// The 2nd value has a minimum contrast of 4.5:1 with white.
		'readableContrastingColorFromWhite' => [ '#6b3777', '#6b3777' ],

		// Readable text-colors on black background preserving the hue.
		// The 1st value has a minimum contrast of 7:1 with black.
		// The 2nd value has a minimum contrast of 4.5:1 with black.

		'readableContrastingColorFromBlack' => [ '#bc83c7', '#a458b5' ],

		// True if the color is dark.
		'isDark'                            => true
	],
]

The saved value contains all the properties needed to automate a lot of processes, and we hope it will encourage developers to do more things without the need to provide multiple controls.

Sanitizing the control when saving an array

If you choose to save the value as an array, we have an example sanitization callback you can use in the repository.

Using the array value

You can use these properties however you like. Below are some simple examples:

Get the cssvalue

This will get the value that the control would normally save if not saving as an array:

$rgba = $value['css']

Get the text-color from a background-color

Using the code below we can get the optimum text-color when our selected color is used for the background. Text color, in this case, will be either #000000 or #ffffff:

$text_color = $value['a11y']['maxContrastColor'];

Get readable color from background color:

$color = $value['a11y']['readableContrastingColorFromWhite'][0];
if ( $value['isDark'] ) {
	$color = $value['a11y']['readableContrastingColorFromBlack'][0];
}

Get a complementary color

Here we’re using the saved color properties. We’ll rotate the hue by 180 degrees, and build an hsla color that can then be used in our CSSCSS CSS is an acronym for cascading style sheets. This is what controls the design or look and feel of a site.:

$h = ( $value['h'] > 180 ) ? $value['h'] - 180 : $value['h'] + 180;
$s = $value['s'];
$l = $value['l'];
$a = $value['a'];
$color = 'hsla(' . $h . ',' . $s . '%,' . $l . '%,' . $a . ')';

You can use the same logic to build color triads or your own custom palette from a single control by rotating the hue (usually by 30, 45, 60, 90, 120, or 180 degrees)

Contributing

This control is developed on its own GitHub repository. All contributions are welcomed there.

#color-alpha-package, #customizer-api, #open-source

Themes team meeting agenda for September 12, 2023

The themes team convenes on the second and fourth Tuesdays of each month. The first meeting for this month is scheduled for September 12.

The meeting takes place in the #themereview channel on 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/. and you need an account to participate.

Channel: #themereview | Time: Tuesday, September 12, 2023, 15:00 UTC

In addition to the predetermined agendas, we allocate time at the end for an open floor session where you are welcome to ask questions or share any themes-related information.

We highly encourage all members, as well as anyone with an interest, to participate. If you have specific agenda items you would like to include, please feel free to add them in the comment section below.

Meeting Agendas

  • Weekly updates
  • Community Summit Discussion – Building trust in WordPress CMS security
  • WordPress Default theme Twenty Twenty-Four contribution
  • Open Floor

See you at the meeting!

#agenda, #meeting, #themes-team

Blue Note: The second community theme is released

Blue Note, the second WordPress community theme is live on the WordPress themes directory. This theme is perfect for writers and bloggers. It is an elegant and fun 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. theme inspired by jazz and the record label “Blue Note Records”.

Community Theme Blue Note

Blue Note comes with 14 different patterns. It can be easily added to the post and page. It also includes 7 page templates and 4 template parts. The design of the patterns was inspired by Jazz record covers.

The theme was mainly developed during WCEU contributor dayContributor Day Contributor Days are standalone days, frequently held before or after WordCamps but they can also happen at any time. They are events where people get together to work on various areas of https://make.wordpress.org/ There are many teams that people can participate in, each with a different focus. https://2017.us.wordcamp.org/contributor-day/ https://make.wordpress.org/support/handbook/getting-started/getting-started-at-a-contributor-day/.. During the keynote, it also got a shoutout from Josepha. The remaining work of the theme is finished by contributors afterward.

As per the designer @beafialho, the idea for the design comes after working on the State of Words slide 2020. There was plenty of inspiration around the Blue Note aesthetic and jazzy style, which gave us the idea of designing a theme that essentially had a very simple structure, and offered many styled patterns.

Community Themes

Community themes are a new initiative to provide high-quality themes for free. Everyone is welcome and encouraged to contribute to this effort on the Community Themes GitHub repository.

Credits

Thank you @beafialho for the nice design. And also thank you all contributors.

#community-themes, #themes