Skip to content

Commit

Permalink
prep build 07/10
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jul 10, 2024
2 parents 6e1d982 + ac01698 commit 145ddea
Show file tree
Hide file tree
Showing 87 changed files with 1,168 additions and 2,499 deletions.
3 changes: 3 additions & 0 deletions backport-changelog/6.7/6668.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6668

* https://github.com/WordPress/gutenberg/pull/62092
375 changes: 375 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

44 changes: 43 additions & 1 deletion docs/reference-guides/block-api/block-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ See the [Example documentation](/docs/reference-guides/block-api/block-registrat

### Variations

- Type: `object[]`
- Type: `object[]|WPDefinedPath` ([learn more](#wpdefinedpath))
- Optional
- Localized: Yes (`title`, `description`, and `keywords` of each variation only)
- Property: `variations`
Expand All @@ -454,6 +454,48 @@ Block Variations is the API that allows a block to have similar versions of it,

_Note: In JavaScript you can provide a function for the `isActive` property, and a React element for the `icon`. In the `block.json` file both only support strings_

Starting with version 6.7, it is possible to specify a PHP file in `block.json` that generates the list of block variations on the server side:

```json
{ "variations": "file:./variations.php" }
```

That PHP file is expected to `return` an array that contains the block variations. Strings found in the variations returned from the PHP file will not be localized automatically; instead, use the `__()` function as usual.

For example:

```php
<?php
// Generate variations for a Social Icon kind of block.

return array(
array(
'isDefault' => true,
'name' => 'wordpress',
'title' => 'WordPress',
'icon' => 'wordpress',
'attributes' => array(
'service' => 'wordpress',
),
'isActive' => array( 'service' )
),
array(
'name' => 'mail',
'title' => __( 'Mail' ),
'keywords' => array(
__( 'email' ),
__( 'e-mail' )
),
'icon' => 'mail',
'attributes' => array(
'service' => 'mail',
),
'isActive' => array( 'mail' )
),
);

```

See [the variations documentation](/docs/reference-guides/block-api/block-variations.md) for more details.

### Block Hooks
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Gather blocks in a layout container. ([Source](https://github.com/WordPress/gute

- **Name:** core/group
- **Category:** design
- **Supports:** align (full, wide), anchor, ariaLabel, background (backgroundImage, backgroundSize), color (background, button, gradients, heading, link, text), dimensions (minHeight), interactivity (clientNavigation), layout (allowSizingOnChildren), position (sticky), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, wide), anchor, ariaLabel, background (backgroundImage, backgroundSize), color (background, button, gradients, heading, link, text), dimensions (minHeight), interactivity (clientNavigation), layout (allowSizingOnChildren), position (sticky), shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** allowedBlocks, tagName, templateLock

## Heading
Expand Down
45 changes: 45 additions & 0 deletions lib/compat/wordpress-6.7/blocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Temporary compatibility shims for block APIs present in Gutenberg.
*
* @package gutenberg
*/

/**
* Allow passing a PHP file as `variations` field for Core versions < 6.7
*
* @param array $settings Array of determined settings for registering a block type.
* @param array $metadata Metadata provided for registering a block type.
* @return array The block type settings
*/
function gutenberg_filter_block_type_metadata_settings_allow_variations_php_file( $settings, $metadata ) {
// If `variations` is a string, it's the name of a PHP file that
// generates the variations.
if ( ! empty( $settings['variations'] ) && is_string( $settings['variations'] ) ) {
$variations_path = wp_normalize_path(
realpath(
dirname( $metadata['file'] ) . '/' .
remove_block_asset_path_prefix( $settings['variations'] )
)
);
if ( $variations_path ) {
/**
* Generates the list of block variations.
*
* @since 6.7.0
*
* @return string Returns the list of block variations.
*/
$settings['variation_callback'] = static function () use ( $variations_path ) {
$variations = require $variations_path;
return $variations;
};
// The block instance's `variations` field is only allowed to be an array
// (of known block variations). We unset it so that the block instance will
// provide a getter that returns the result of the `variation_callback` instead.
unset( $settings['variations'] );
}
}
return $settings;
}
add_filter( 'block_type_metadata_settings', 'gutenberg_filter_block_type_metadata_settings_allow_variations_php_file', 10, 2 );
3 changes: 3 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.6/option.php';
require __DIR__ . '/compat/wordpress-6.6/post.php';

// WordPress 6.7 compat.
require __DIR__ . '/compat/wordpress-6.7/blocks.php';

// Experimental features.
require __DIR__ . '/experimental/block-editor-settings-mobile.php';
require __DIR__ . '/experimental/blocks.php';
Expand Down
22 changes: 12 additions & 10 deletions lib/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ function gutenberg_enqueue_global_styles() {

$stylesheet = gutenberg_get_global_stylesheet();

/*
* Dequeue the Customizer's custom CSS
* and add it before the global styles custom CSS.
*/
remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
// Get the custom CSS from the Customizer and add it to the global stylesheet.
$custom_css = wp_get_custom_css();
$stylesheet .= $custom_css;
if ( $is_block_theme ) {
/*
* Dequeue the Customizer's custom CSS
* and add it before the global styles custom CSS.
*/
remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
// Get the custom CSS from the Customizer and add it to the global stylesheet.
$custom_css = wp_get_custom_css();
$stylesheet .= $custom_css;

// Add the global styles custom CSS at the end.
$stylesheet .= gutenberg_get_global_stylesheet( array( 'custom-css' ) );
// Add the global styles custom CSS at the end.
$stylesheet .= gutenberg_get_global_stylesheet( array( 'custom-css' ) );
}

if ( empty( $stylesheet ) ) {
return;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "18.7.1",
"version": "18.8.0-rc.1",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,6 @@ _Properties_
- _\_\_experimentalBlockDirectory_ `boolean`: Whether the user has enabled the Block Directory
- _\_\_experimentalBlockPatterns_ `Array`: Array of objects representing the block patterns
- _\_\_experimentalBlockPatternCategories_ `Array`: Array of objects representing the block pattern categories
- _\_\_unstableGalleryWithImageBlocks_ `boolean`: Whether the user has enabled the refactored gallery block which uses InnerBlocks

### SkipToSelectedBlock

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* Internal dependencies
*/
import { PatternCategoryPreviews } from './pattern-category-previews';
import { useZoomOut } from '../../../hooks/use-zoom-out';

function PatternCategoryPreviewPanelInner( {
export function PatternCategoryPreviewPanel( {
rootClientId,
onInsert,
onHover,
Expand All @@ -24,17 +23,3 @@ function PatternCategoryPreviewPanelInner( {
/>
);
}

function PatternCategoryPreviewPanelWithZoomOut( props ) {
useZoomOut();
return <PatternCategoryPreviewPanelInner { ...props } />;
}

export function PatternCategoryPreviewPanel( props ) {
// When the pattern panel is showing, we want to use zoom out mode
if ( window.__experimentalEnableZoomedOutPatternsTab ) {
return <PatternCategoryPreviewPanelWithZoomOut { ...props } />;
}

return <PatternCategoryPreviewPanelInner { ...props } />;
}
6 changes: 6 additions & 0 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import InserterSearchResults from './search-results';
import useInsertionPoint from './hooks/use-insertion-point';
import { store as blockEditorStore } from '../../store';
import TabbedSidebar from '../tabbed-sidebar';
import { useZoomOut } from '../../hooks/use-zoom-out';

const NOOP = () => {};
function InserterMenu(
Expand Down Expand Up @@ -145,6 +146,11 @@ function InserterMenu(

const showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory;

const showZoomOut =
showPatternPanel && window.__experimentalEnableZoomedOutPatternsTab;

useZoomOut( showZoomOut );

const inserterSearch = useMemo( () => {
if ( selectedTab === 'media' ) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*/
import {
Button,
CustomSelectControl,
Icon,
RangeControl,
__experimentalHStack as HStack,
__experimentalUnitControl as UnitControl,
__experimentalUseCustomUnits as useCustomUnits,
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useState, useMemo } from '@wordpress/element';
Expand All @@ -31,6 +31,11 @@ import {
getPresetValueFromCustomValue,
isValueSpacingPreset,
} from '../utils';
import { unlock } from '../../../lock-unlock';

const { CustomSelectControlV2Legacy: CustomSelectControl } = unlock(
componentsPrivateApis
);

const CUSTOM_VALUE_SETTINGS = {
px: { max: 300, steps: 1 },
Expand Down
2 changes: 0 additions & 2 deletions packages/block-editor/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const PREFERENCES_DEFAULTS = {
* @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
* @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
* @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
* @property {boolean} __unstableGalleryWithImageBlocks Whether the user has enabled the refactored gallery block which uses InnerBlocks
*/
export const SETTINGS_DEFAULTS = {
alignWide: false,
Expand Down Expand Up @@ -168,7 +167,6 @@ export const SETTINGS_DEFAULTS = {
__mobileEnablePageTemplates: false,
__experimentalBlockPatterns: [],
__experimentalBlockPatternCategories: [],
__unstableGalleryWithImageBlocks: false,
__unstableIsPreviewMode: false,

// These settings will be completely revamped in the future.
Expand Down
3 changes: 0 additions & 3 deletions packages/block-editor/src/store/defaults.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const SETTINGS_DEFAULTS = {
...SETTINGS,
// Don't add the default font sizes for standard themes
fontSizes: undefined,
// FOR TESTING ONLY - Later, this will come from a REST API
// eslint-disable-next-line no-undef
__unstableGalleryWithImageBlocks: __DEV__,
alignWide: true,
supportsLayout: false,
__experimentalFeatures: {
Expand Down
61 changes: 6 additions & 55 deletions packages/block-library/src/gallery/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
LINK_DESTINATION_MEDIA,
LINK_DESTINATION_NONE,
} from './constants';
import { isGalleryV2Enabled } from './shared';

const DEPRECATED_LINK_DESTINATION_MEDIA = 'file';
const DEPRECATED_LINK_DESTINATION_ATTACHMENT = 'post';
Expand Down Expand Up @@ -408,11 +407,7 @@ const v6 = {
);
},
migrate( attributes ) {
if ( isGalleryV2Enabled() ) {
return runV2Migration( attributes );
}

return attributes;
return runV2Migration( attributes );
},
};
const v5 = {
Expand Down Expand Up @@ -498,23 +493,7 @@ const v5 = {
return ! linkTo || linkTo === 'attachment' || linkTo === 'media';
},
migrate( attributes ) {
if ( isGalleryV2Enabled() ) {
return runV2Migration( attributes );
}

let linkTo = attributes.linkTo;

if ( ! attributes.linkTo ) {
linkTo = 'none';
} else if ( attributes.linkTo === 'attachment' ) {
linkTo = 'post';
} else if ( attributes.linkTo === 'media' ) {
linkTo = 'file';
}
return {
...attributes,
linkTo,
};
return runV2Migration( attributes );
},
save( { attributes } ) {
const {
Expand Down Expand Up @@ -661,17 +640,7 @@ const v4 = {
return ids && ids.some( ( id ) => typeof id === 'string' );
},
migrate( attributes ) {
if ( isGalleryV2Enabled() ) {
return runV2Migration( attributes );
}

return {
...attributes,
ids: ( attributes.ids ?? [] ).map( ( id ) => {
const parsedId = parseInt( id, 10 );
return Number.isInteger( parsedId ) ? parsedId : null;
} ),
};
return runV2Migration( attributes );
},
save( { attributes } ) {
const {
Expand Down Expand Up @@ -867,10 +836,7 @@ const v3 = {
);
},
migrate( attributes ) {
if ( isGalleryV2Enabled() ) {
return runV2Migration( attributes );
}
return attributes;
return runV2Migration( attributes );
},
};
const v2 = {
Expand Down Expand Up @@ -936,18 +902,7 @@ const v2 = {
);
},
migrate( attributes ) {
if ( isGalleryV2Enabled() ) {
return runV2Migration( attributes );
}
return {
...attributes,
ids: ( attributes.images ?? [] ).map( ( { id } ) => {
if ( ! id ) {
return null;
}
return parseInt( id, 10 );
} ),
};
return runV2Migration( attributes );
},
supports: {
align: true,
Expand Down Expand Up @@ -1100,11 +1055,7 @@ const v1 = {
);
},
migrate( attributes ) {
if ( isGalleryV2Enabled() ) {
return runV2Migration( attributes );
}

return attributes;
return runV2Migration( attributes );
},
};

Expand Down
Loading

0 comments on commit 145ddea

Please sign in to comment.