Skip to content

Commit

Permalink
Merge branch 'trunk' into try/toc-store-headings-in-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Sep 13, 2023
2 parents b0935ab + b05bee7 commit 825578e
Show file tree
Hide file tree
Showing 267 changed files with 2,937 additions and 3,021 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
node-version: ${{ matrix.node }}

- name: Cache NPM packages
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # v2.8.0

- name: AVD cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
id: avd-cache
with:
path: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ jobs:
run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt

- name: Restore build cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app
packages/react-native-editor/ios/build/WDA
key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ matrix.device }}-${{ hashFiles('ios-checksums.txt') }}

- name: Restore pods cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
packages/react-native-editor/ios/Pods
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ jobs:
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT

- name: Cache PHPCS scan cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: .cache/phpcs.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}
Expand Down
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
}
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"squizlabs/php_codesniffer": "^3.5",
"phpcompatibility/phpcompatibility-wp": "^2.1.3",
"wp-coding-standards/wpcs": "^2.2",
"wp-coding-standards/wpcs": "^3.0",
"sirbrillig/phpcs-variable-analysis": "^2.8",
"spatie/phpunit-watcher": "^1.23",
"yoast/phpunit-polyfills": "^1.0",
Expand Down
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,12 @@
"markdown_source": "../packages/token-list/README.md",
"parent": "packages"
},
{
"title": "@wordpress/undo-manager",
"slug": "packages-undo-manager",
"markdown_source": "../packages/undo-manager/README.md",
"parent": "packages"
},
{
"title": "@wordpress/url",
"slug": "packages-url",
Expand Down
33 changes: 0 additions & 33 deletions docs/reference-guides/block-api/block-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,39 +305,6 @@ Attribute available in the block:
{ "content": "The inner text of the <strong>figcaption</strong> element" }
```

Use the `multiline` property to extract the inner HTML of matching tag names for the use in `RichText` with the `multiline` prop.

_Example_: Extract the `content` attribute from a blockquote element found in the block's markup.

Saved content:
```html
<div>
Block Content

<blockquote>
<p>First line</p>
<p>Second line</p>
</blockquote>
</div>
```

Attribute definition:
```js
{
content: {
type: 'string',
source: 'html',
multiline: 'p',
selector: 'blockquote',
}
}
```

Attribute available in the block:
```js
{ "content": "<p>First line</p><p>Second line</p>" }
```

### `query` source

Use `query` to extract an array of values from markup. Entries of the array are determined by the `selector` argument, where each matched element within the block will have an entry structured corresponding to the second argument, an object of attribute sources.
Expand Down
4 changes: 2 additions & 2 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ Displays the contents of a post or page. ([Source](https://github.com/WordPress/

- **Name:** core/post-content
- **Category:** theme
- **Supports:** align (full, wide), color (background, gradients, link, text), dimensions (minHeight), layout, typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, wide), color (background, gradients, link, text), dimensions (minHeight), layout, spacing (blockGap), typography (fontSize, lineHeight), ~~html~~
- **Attributes:**

## Date
Expand Down Expand Up @@ -759,7 +759,7 @@ Help visitors find your content. ([Source](https://github.com/WordPress/gutenber

- **Name:** core/search
- **Category:** widgets
- **Supports:** align (center, left, right), color (background, gradients, text), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (center, left, right), color (background, gradients, text), interactivity, typography (fontSize, lineHeight), ~~html~~
- **Attributes:** buttonBehavior, buttonPosition, buttonText, buttonUseIcon, isSearchFieldHidden, label, placeholder, query, showLabel, width, widthUnit

## Separator
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-edit-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ _Parameters_

_Returns_

- `number`: The resolved template ID for the page route.
- `Object`: Action object.

### setHasPageContentFocus

Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ _Usage_

_Parameters_

- _state_ `State`: Editor state.
- _state_ Editor state.

_Returns_

Expand Down
12 changes: 6 additions & 6 deletions lib/block-supports/border.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,24 @@ function gutenberg_apply_border_support( $block_type, $block_attributes ) {
* flag nested under `experimentalBorder` must be enabled for the feature
* to be opted into.
*
* @param WP_Block_Type $block_type Block type to check for support.
* @param string $feature Name of the feature to check support for.
* @param mixed $default Fallback value for feature support, defaults to false.
* @param WP_Block_Type $block_type Block type to check for support.
* @param string $feature Name of the feature to check support for.
* @param mixed $default_value Fallback value for feature support, defaults to false.
*
* @return boolean Whether or not the feature is supported.
*/
function gutenberg_has_border_feature_support( $block_type, $feature, $default = false ) {
function gutenberg_has_border_feature_support( $block_type, $feature, $default_value = false ) {
// Check if all border support features have been opted into via `"__experimentalBorder": true`.
if (
property_exists( $block_type, 'supports' ) &&
( true === _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), $default ) )
( true === _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), $default_value ) )
) {
return true;
}

// Check if the specific feature has been opted into individually
// via nested flag under `__experimentalBorder`.
return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default );
return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default_value );
}

// Register the block support.
Expand Down
2 changes: 1 addition & 1 deletion lib/block-supports/elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function gutenberg_render_elements_support( $block_content, $block ) {

foreach ( $element_config['paths'] as $path ) {
if ( null !== _wp_array_get( $block['attrs'], explode( '.', $path ), null ) ) {
$element_colors_set++;
++$element_colors_set;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ function gutenberg_restore_group_inner_container( $block_content, $block ) {
);
$updated_content = preg_replace_callback(
$replace_regex,
static function( $matches ) {
static function ( $matches ) {
return $matches[1] . '<div class="wp-block-group__inner-container">' . $matches[2] . '</div>' . $matches[3];
},
$block_content
Expand Down
1 change: 0 additions & 1 deletion lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ function gutenberg_render_typography_support( $block_content, $block ) {
}

return $block_content;

}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function gutenberg_register_core_block_assets( $block_name ) {
if ( ! $stylesheet_removed ) {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
wp_dequeue_style( 'wp-block-library-theme' );
}
);
Expand Down
4 changes: 2 additions & 2 deletions lib/class-wp-duotone-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ private static function is_preset( $duotone_attr ) {
* @return string The CSS variable name.
*/
private static function get_css_custom_property_name( $slug ) {
return "--wp--preset--duotone--$slug";
return "--wp--preset--duotone--$slug";
}

/**
Expand All @@ -492,7 +492,7 @@ private static function get_css_custom_property_name( $slug ) {
* @return string The ID of the duotone filter.
*/
private static function get_filter_id( $slug ) {
return "wp-duotone-$slug";
return "wp-duotone-$slug";
}

/**
Expand Down
1 change: 0 additions & 1 deletion lib/class-wp-theme-json-data-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,4 @@ public function update_with( $new_data ) {
public function get_data() {
return $this->theme_json->get_raw_data();
}

}
13 changes: 6 additions & 7 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -2345,7 +2345,7 @@ public function get_styles_for_block( $block_metadata ) {
// Prepend the variation selector to the current selector.
$split_selectors = explode( ',', $shortened_selector );
$updated_selectors = array_map(
static function( $split_selector ) use ( $clean_style_variation_selector ) {
static function ( $split_selector ) use ( $clean_style_variation_selector ) {
return $clean_style_variation_selector . $split_selector;
},
$split_selectors
Expand Down Expand Up @@ -2384,7 +2384,7 @@ static function( $split_selector ) use ( $clean_style_variation_selector ) {
$pseudo_matches = array_values(
array_filter(
$element_pseudo_allowed,
static function( $pseudo_selector ) use ( $selector ) {
static function ( $pseudo_selector ) use ( $selector ) {
return str_contains( $selector, $pseudo_selector );
}
)
Expand Down Expand Up @@ -3415,7 +3415,7 @@ public function set_spacing_sizes() {
}

if ( $below_midpoint_count < $steps_mid_point - 2 ) {
$x_small_count++;
++$x_small_count;
}

$slug -= 10;
Expand Down Expand Up @@ -3452,7 +3452,7 @@ public function set_spacing_sizes() {
}

if ( $above_midpoint_count > 1 ) {
$x_large_count++;
++$x_large_count;
}

$slug += 10;
Expand Down Expand Up @@ -3728,16 +3728,15 @@ public static function resolve_variables( $theme_json ) {
$theme_vars = static::compute_theme_vars( $settings );
$vars = array_reduce(
array_merge( $preset_vars, $theme_vars ),
function( $carry, $item ) {
function ( $carry, $item ) {
$name = $item['name'];
$carry[ "var({$name})" ] = $item['value'];
return $carry;
return $carry;
},
array()
);

$theme_json->theme_json['styles'] = self::convert_variables_to_value( $styles, $vars );
return $theme_json;
}

}
22 changes: 12 additions & 10 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ public static function get_theme_data( $deprecated = array(), $options = array()
$options = wp_parse_args( $options, array( 'with_supports' => true ) );

if ( null === static::$theme || ! static::has_same_registered_blocks( 'theme' ) ) {
$theme_json_file = static::get_file_path_from_theme( 'theme.json' );
$wp_theme = wp_get_theme();
if ( '' !== $theme_json_file ) {
$theme_json_file = $wp_theme->get_file_path( 'theme.json' );
if ( is_readable( $theme_json_file ) ) {
$theme_json_data = static::read_json_file( $theme_json_file );
$theme_json_data = static::translate( $theme_json_data, $wp_theme->get( 'TextDomain' ) );
} else {
Expand All @@ -263,8 +263,8 @@ public static function get_theme_data( $deprecated = array(), $options = array()

if ( $wp_theme->parent() ) {
// Get parent theme.json.
$parent_theme_json_file = static::get_file_path_from_theme( 'theme.json', true );
if ( '' !== $parent_theme_json_file ) {
$parent_theme_json_file = $wp_theme->parent()->get_file_path( 'theme.json' );
if ( $theme_json_file !== $parent_theme_json_file && is_readable( $parent_theme_json_file ) ) {
$parent_theme_json_data = static::read_json_file( $parent_theme_json_file );
$parent_theme_json_data = static::translate( $parent_theme_json_data, $wp_theme->parent()->get( 'TextDomain' ) );
$parent_theme = new WP_Theme_JSON_Gutenberg( $parent_theme_json_data );
Expand Down Expand Up @@ -408,18 +408,18 @@ public static function get_block_data() {
/**
* When given an array, this will remove any keys with the name `//`.
*
* @param array $array The array to filter.
* @param array $json_array The array to filter.
* @return array The filtered array.
*/
private static function remove_json_comments( $array ) {
unset( $array['//'] );
foreach ( $array as $k => $v ) {
private static function remove_json_comments( $json_array ) {
unset( $json_array['//'] );
foreach ( $json_array as $k => $v ) {
if ( is_array( $v ) ) {
$array[ $k ] = static::remove_json_comments( $v );
$json_array[ $k ] = static::remove_json_comments( $v );
}
}

return $array;
return $json_array;
}

/**
Expand Down Expand Up @@ -670,6 +670,8 @@ public static function theme_has_support() {
* @return string The whole file path or empty if the file doesn't exist.
*/
protected static function get_file_path_from_theme( $file_name, $template = false ) {
// TODO: Remove this method from core on 6.3 release.
_deprecated_function( __METHOD__, '6.3.0' );
$path = $template ? get_template_directory() : get_stylesheet_directory();
$candidate = $path . '/' . $file_name;

Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.3/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function gutenberg_wp_block_register_post_meta() {
$post_type,
'wp_pattern_sync_status',
array(
'auth_callback' => function() {
'auth_callback' => function () {
return current_user_can( 'edit_posts' );
},
'sanitize_callback' => 'sanitize_text_field',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static function get_fallback_classic_menu() {
private static function get_most_recently_created_nav_menu( $classic_nav_menus ) {
usort(
$classic_nav_menus,
static function( $a, $b ) {
static function ( $a, $b ) {
return $b->term_id - $a->term_id;
}
);
Expand Down
Loading

0 comments on commit 825578e

Please sign in to comment.