Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Made it clear where the origin prioritization comes from in the comme…
…nts.

Made it clear where the origin prioritization comes from in the comments.
  • Loading branch information
ramonjd committed Feb 22, 2024
commit 46b3d1b911a9e0a37af4dc1f93054a04dd3f4f76
3 changes: 3 additions & 0 deletions packages/block-editor/src/hooks/font-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export function useIsFontSizeDisabled( { name: blockName } = {} ) {

/**
* Given a font size slug preset, returns the matching preset.
* The reference for the fontSizes preset array depends on the origin.
* Font sizes are sourced from either 'typography.fontSizes.custom' || 'typography.fontSizes.theme' || 'typography.fontSizes.default'.
* See: `useSettings() -> getBlockSettings() -> overrideOrigins()`.
*
* @param {string} slug The slug of the font size preset
* @return {object|undefined} The font size object, if found.
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ function render_block_core_search( $attributes ) {
} elseif ( ! empty( $attributes['fontSize'] ) ) {
$font_size_presets = wp_get_global_settings( array( 'typography', 'fontSizes' ) );
if ( ! empty( $font_size_presets ) ) {
/*
* The prioritization of origins matches the order in which the block editor fetches settings.
* Font sizes are sourced from either 'typography.fontSizes.custom' || 'typography.fontSizes.theme' || 'typography.fontSizes.default'.
* See: `getBlockSettings()` packages/block-editor/src/store/get-block-settings.js
*/
$font_size_presets = $font_size_presets['custom'] ?? $font_size_presets['theme'] ?? $font_size_presets['default'];
$font_size_from_preset = array_column( $font_size_presets, null, 'slug' )[ $attributes['fontSize'] ] ?? false;
if ( isset( $font_size_from_preset['size'] ) ) {
Expand Down