Skip to content

Commit

Permalink
Merge branch 'trunk' into rnmobile/upgrade/react-native-0.71.8
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiddot committed Jul 21, 2023
2 parents 2fad54c + 51774ef commit 44b988a
Show file tree
Hide file tree
Showing 81 changed files with 1,826 additions and 866 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
/packages/scripts @gziolo @ntwb @nerrad @ajitbohra @ryanwelcher
/packages/stylelint-config @ntwb
/test/e2e @kevin940726 @Mamaduka
/test/php/gutenberg-coding-standards @anton-vlasenko

# UI Components
/packages/components @ajitbohra
Expand Down
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,18 @@
"wp-coding-standards/wpcs": "^2.2",
"sirbrillig/phpcs-variable-analysis": "^2.8",
"spatie/phpunit-watcher": "^1.23",
"yoast/phpunit-polyfills": "^1.0"
"yoast/phpunit-polyfills": "^1.0",
"gutenberg/gutenberg-coding-standards": "@dev"
},
"repositories": [
{
"type": "path",
"url": "./test/php/gutenberg-coding-standards",
"options": {
"symlink": false
}
}
],
"require": {
"composer/installers": "~1.0"
},
Expand Down
2 changes: 2 additions & 0 deletions docs/how-to-guides/themes/theme-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ Use this setting to enable the following Global Styles settings:
- color: link
- spacing: blockGap, margin, padding
- typography: lineHeight
- dimensions: minHeight
- position: sticky

```php
add_theme_support( 'appearance-tools' );
Expand Down
23 changes: 0 additions & 23 deletions docs/reference-guides/data/data-core-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,29 +168,6 @@ _Returns_

- `Array?`: The list of allowed block types.

### getBehaviors

Returns the behaviors registered with the editor.

Behaviors are named, reusable pieces of functionality that can be attached to blocks. They are registered with the editor using the `theme.json` file.

_Usage_

```js
const behaviors = select( blockEditorStore ).getBehaviors();
if ( behaviors?.lightbox ) {
// Do something with the lightbox.
}
```
_Parameters_
- _state_ `Object`: Editor state.
_Returns_
- `Object`: The editor behaviors object.
### getBlock

Returns a block given its client ID. This is a parsed copy of the block, containing its `blockName`, `clientId`, and current `attributes` state. This is not the block's registration settings, which must be retrieved from the blocks module registration store.
Expand Down
4 changes: 4 additions & 0 deletions lib/class-wp-duotone-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
* @since 6.3.0
*/

if ( class_exists( 'WP_Duotone_Gutenberg' ) ) {
return;
}

/**
* Manages duotone block supports and global styles.
*
Expand Down
4 changes: 4 additions & 0 deletions lib/class-wp-theme-json-data-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* @since 6.1.0
*/

if ( class_exists( 'WP_Theme_JSON_Data_Gutenberg' ) ) {
return;
}

/**
* Class to provide access to update a theme.json structure.
*/
Expand Down
4 changes: 4 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* @since 5.8.0
*/

if ( class_exists( 'WP_Theme_JSON_Gutenberg' ) ) {
return;
}

/**
* Class that encapsulates the processing of structures that adhere to the theme.json spec.
*
Expand Down
4 changes: 4 additions & 0 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* @since 5.8.0
*/

if ( class_exists( 'WP_Theme_JSON_Resolver_Gutenberg' ) ) {
return;
}

/**
* Class that abstracts the processing of the different data sources
* for site-level config and offers an API to work with them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* @since 6.2.0
*/

if ( class_exists( 'WP_HTML_Attribute_Token' ) ) {
return;
}

/**
* Data structure for the attribute token that allows to drastically improve performance.
*
Expand Down
4 changes: 4 additions & 0 deletions lib/compat/wordpress-6.2/html-api/class-wp-html-span.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* @since 6.2.0
*/

if ( class_exists( 'WP_HTML_Span' ) ) {
return;
}

/**
* Represents a textual span inside an HTML document.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
* @since 6.2.0
*/

if ( class_exists( 'WP_HTML_Tag_Processor' ) ) {
return;
}

/**
* Modifies attributes in an HTML document for tags matching a query.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* @since 6.2.0
*/

if ( class_exists( 'WP_HTML_Text_Replacement' ) ) {
return;
}

/**
* Data structure used to replace existing content from start to end that allows to drastically improve performance.
*
Expand Down
69 changes: 36 additions & 33 deletions lib/compat/wordpress-6.2/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,43 +91,46 @@ function gutenberg_modify_rest_sidebars_response( $response ) {
}
add_filter( 'rest_prepare_sidebar', 'gutenberg_modify_rest_sidebars_response' );


/**
* Add the `block_types` value to the `pattern-directory-item` schema.
*
* @since 6.2.0 Added 'block_types' property.
*/
function add_block_pattern_block_types_schema() {
register_rest_field(
'pattern-directory-item',
'block_types',
array(
'schema' => array(
'description' => __( 'The block types which can use this pattern.', 'gutenberg' ),
'type' => 'array',
'uniqueItems' => true,
'items' => array( 'type' => 'string' ),
'context' => array( 'view', 'embed' ),
),
)
);
if ( ! function_exists( 'add_block_pattern_block_types_schema' ) ) {
/**
* Add the `block_types` value to the `pattern-directory-item` schema.
*
* @since 6.2.0 Added 'block_types' property.
*/
function add_block_pattern_block_types_schema() {
register_rest_field(
'pattern-directory-item',
'block_types',
array(
'schema' => array(
'description' => __( 'The block types which can use this pattern.', 'gutenberg' ),
'type' => 'array',
'uniqueItems' => true,
'items' => array( 'type' => 'string' ),
'context' => array( 'view', 'embed' ),
),
)
);
}
}
add_filter( 'rest_api_init', 'add_block_pattern_block_types_schema' );


/**
* Add the `block_types` value into the API response.
*
* @since 6.2.0 Added 'block_types' property.
*
* @param WP_REST_Response $response The response object.
* @param object $raw_pattern The unprepared pattern.
*/
function filter_block_pattern_response( $response, $raw_pattern ) {
$data = $response->get_data();
$data['block_types'] = array_map( 'sanitize_text_field', $raw_pattern->meta->wpop_block_types );
$response->set_data( $data );
return $response;
if ( ! function_exists( 'filter_block_pattern_response' ) ) {
/**
* Add the `block_types` value into the API response.
*
* @since 6.2.0 Added 'block_types' property.
*
* @param WP_REST_Response $response The response object.
* @param object $raw_pattern The unprepared pattern.
*/
function filter_block_pattern_response( $response, $raw_pattern ) {
$data = $response->get_data();
$data['block_types'] = array_map( 'sanitize_text_field', $raw_pattern->meta->wpop_block_types );
$response->set_data( $data );
return $response;
}
}
add_filter( 'rest_prepare_block_pattern', 'filter_block_pattern_response', 10, 2 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class Gutenberg_REST_Global_Styles_Revisions_Controller_6_3 extends WP_REST_Cont
* @since 6.3.0
* @var string
*/
private $parent_post_type;
protected $parent_post_type;

/**
* The base of the parent controller's route.
*
* @since 6.3.0
* @var string
*/
private $parent_base;
protected $parent_base;

/**
* Constructor.
Expand Down Expand Up @@ -102,7 +102,7 @@ public function get_collection_params() {
* @param string $raw_json Encoded JSON from global styles custom post content.
* @return Array|WP_Error
*/
private function get_decoded_global_styles_json( $raw_json ) {
protected function get_decoded_global_styles_json( $raw_json ) {
$decoded_json = json_decode( $raw_json, true );

if ( is_array( $decoded_json ) && isset( $decoded_json['isGlobalStylesUserThemeJSON'] ) && true === $decoded_json['isGlobalStylesUserThemeJSON'] ) {
Expand Down
32 changes: 17 additions & 15 deletions lib/compat/wordpress-6.3/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
* @package gutenberg
*/

/**
* Mark CSS safe if it contains grid functions
*
* This function should not be backported to core.
*
* @param bool $allow_css Whether the CSS is allowed.
* @param string $css_test_string The CSS to test.
*/
function allow_grid_functions_in_styles( $allow_css, $css_test_string ) {
if ( preg_match(
'/^grid-template-columns:\s*repeat\([0-9,a-z-\s\(\)]*\)$/',
$css_test_string
) ) {
return true;
if ( ! function_exists( 'allow_grid_functions_in_styles' ) ) {
/**
* Mark CSS safe if it contains grid functions
*
* This function should not be backported to core.
*
* @param bool $allow_css Whether the CSS is allowed.
* @param string $css_test_string The CSS to test.
*/
function allow_grid_functions_in_styles( $allow_css, $css_test_string ) {
if ( preg_match(
'/^grid-template-columns:\s*repeat\([0-9,a-z-\s\(\)]*\)$/',
$css_test_string
) ) {
return true;
}
return $allow_css;
}
return $allow_css;
}
add_filter( 'safecss_filter_attr_allow_css', 'allow_grid_functions_in_styles', 10, 2 );
32 changes: 8 additions & 24 deletions lib/compat/wordpress-6.3/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,13 @@ function gutenberg_update_templates_template_parts_rest_controller( $args, $post
}
add_filter( 'register_post_type_args', 'gutenberg_update_templates_template_parts_rest_controller', 10, 2 );

/**
* Registers the Global Styles Revisions REST API routes.
*/
function gutenberg_register_global_styles_revisions_endpoints() {
$global_styles_revisions_controller = new Gutenberg_REST_Global_Styles_Revisions_Controller_6_3();
$global_styles_revisions_controller->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_global_styles_revisions_endpoints' );

/**
* Registers the Global Styles REST API routes.
*/
function gutenberg_register_global_styles_endpoints() {
$global_styles_controller = new Gutenberg_REST_Global_Styles_Controller_6_3();
$global_styles_controller->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_global_styles_endpoints' );

/**
* Add the `modified` value to the `wp_template` schema.
*
* @since 6.3.0 Added 'modified' property and response value.
*/
function add_modified_wp_template_schema() {
if ( ! function_exists( 'add_modified_wp_template_schema' ) ) {
/**
* Add the `modified` value to the `wp_template` schema.
*
* @since 6.3.0 Added 'modified' property and response value.
*/
function add_modified_wp_template_schema() {
register_rest_field(
array( 'wp_template', 'wp_template_part' ),
'modified',
Expand All @@ -98,6 +81,7 @@ function add_modified_wp_template_schema() {
},
)
);
}
}
add_filter( 'rest_api_init', 'add_modified_wp_template_schema' );

Expand Down
Loading

0 comments on commit 44b988a

Please sign in to comment.