mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Update editor related npm packages
The npm packages needed updating for 6.4 to the latest. Props mikachan, mukesdpanchal27, luisherranz, youknowriad, tellthemachines, gziolo, ockham, michalczaplinski Fixes #59411 git-svn-id: https://develop.svn.wordpress.org/trunk@56710 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e77aaf1bae
commit
ae1484cbb6
@ -171,6 +171,10 @@ module.exports = function(grunt) {
|
||||
'webpack-assets': webpackFiles.map( function( file ) {
|
||||
return setFilePath( WORKING_DIR, file );
|
||||
} ),
|
||||
'interactivity-assets': [
|
||||
WORKING_DIR + 'wp-includes/js/dist/interactivity.asset.php',
|
||||
WORKING_DIR + 'wp-includes/js/dist/interactivity.min.asset.php',
|
||||
],
|
||||
dynamic: {
|
||||
dot: true,
|
||||
expand: true,
|
||||
@ -1458,6 +1462,7 @@ module.exports = function(grunt) {
|
||||
'clean:webpack-assets',
|
||||
'webpack:prod',
|
||||
'webpack:dev',
|
||||
'clean:interactivity-assets',
|
||||
] );
|
||||
|
||||
grunt.registerTask( 'build:js', [
|
||||
|
||||
32392
package-lock.json
generated
32392
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
134
package.json
134
package.json
@ -26,10 +26,10 @@
|
||||
"devDependencies": {
|
||||
"@lodder/grunt-postcss": "^3.1.1",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
|
||||
"@wordpress/babel-preset-default": "7.19.1",
|
||||
"@wordpress/dependency-extraction-webpack-plugin": "4.18.1",
|
||||
"@wordpress/e2e-test-utils": "10.6.4",
|
||||
"@wordpress/scripts": "26.6.4",
|
||||
"@wordpress/babel-preset-default": "7.26.1",
|
||||
"@wordpress/dependency-extraction-webpack-plugin": "4.25.1",
|
||||
"@wordpress/e2e-test-utils": "10.13.1",
|
||||
"@wordpress/scripts": "26.13.1",
|
||||
"autoprefixer": "10.4.16",
|
||||
"chalk": "5.3.0",
|
||||
"check-node-version": "4.2.1",
|
||||
@ -78,72 +78,76 @@
|
||||
"dependencies": {
|
||||
"@emotion/is-prop-valid": "0.8.8",
|
||||
"@emotion/memoize": "0.7.4",
|
||||
"@wordpress/a11y": "3.35.1",
|
||||
"@wordpress/annotations": "2.35.8",
|
||||
"@wordpress/api-fetch": "6.32.1",
|
||||
"@wordpress/autop": "3.35.1",
|
||||
"@wordpress/blob": "3.35.1",
|
||||
"@wordpress/block-directory": "4.12.17",
|
||||
"@wordpress/block-editor": "12.3.14",
|
||||
"@wordpress/block-library": "8.12.17",
|
||||
"@wordpress/block-serialization-default-parser": "4.35.1",
|
||||
"@wordpress/blocks": "12.12.7",
|
||||
"@wordpress/commands": "0.6.12",
|
||||
"@wordpress/components": "25.1.11",
|
||||
"@wordpress/compose": "6.12.2",
|
||||
"@wordpress/core-commands": "0.4.15",
|
||||
"@wordpress/core-data": "6.12.15",
|
||||
"@wordpress/customize-widgets": "4.12.17",
|
||||
"@wordpress/data": "9.5.5",
|
||||
"@wordpress/data-controls": "3.4.5",
|
||||
"@wordpress/date": "4.35.1",
|
||||
"@wordpress/deprecated": "3.35.1",
|
||||
"@wordpress/dom": "3.35.1",
|
||||
"@wordpress/dom-ready": "3.35.1",
|
||||
"@wordpress/edit-post": "7.12.17",
|
||||
"@wordpress/edit-site": "5.12.17",
|
||||
"@wordpress/edit-widgets": "5.12.17",
|
||||
"@wordpress/editor": "13.12.15",
|
||||
"@wordpress/element": "5.12.1",
|
||||
"@wordpress/escape-html": "2.35.1",
|
||||
"@wordpress/format-library": "4.12.14",
|
||||
"@wordpress/hooks": "3.35.1",
|
||||
"@wordpress/html-entities": "3.35.1",
|
||||
"@wordpress/i18n": "4.35.1",
|
||||
"@wordpress/icons": "9.26.2",
|
||||
"@wordpress/interface": "5.12.11",
|
||||
"@wordpress/is-shallow-equal": "4.35.1",
|
||||
"@wordpress/keyboard-shortcuts": "4.12.5",
|
||||
"@wordpress/keycodes": "3.35.1",
|
||||
"@wordpress/list-reusable-blocks": "4.12.11",
|
||||
"@wordpress/media-utils": "4.26.1",
|
||||
"@wordpress/notices": "4.3.5",
|
||||
"@wordpress/nux": "7.1.4",
|
||||
"@wordpress/plugins": "6.3.11",
|
||||
"@wordpress/preferences": "3.12.11",
|
||||
"@wordpress/preferences-persistence": "1.27.1",
|
||||
"@wordpress/primitives": "3.33.1",
|
||||
"@wordpress/priority-queue": "2.35.1",
|
||||
"@wordpress/private-apis": "0.17.2",
|
||||
"@wordpress/redux-routine": "4.35.1",
|
||||
"@wordpress/reusable-blocks": "4.12.15",
|
||||
"@wordpress/rich-text": "6.12.8",
|
||||
"@wordpress/router": "0.4.2",
|
||||
"@wordpress/server-side-render": "4.12.13",
|
||||
"@wordpress/shortcode": "3.35.1",
|
||||
"@wordpress/style-engine": "1.18.1",
|
||||
"@wordpress/token-list": "2.35.1",
|
||||
"@wordpress/url": "3.36.1",
|
||||
"@wordpress/viewport": "5.12.5",
|
||||
"@wordpress/warning": "2.35.1",
|
||||
"@wordpress/widgets": "3.12.15",
|
||||
"@wordpress/wordcount": "3.35.1",
|
||||
"@wordpress/a11y": "3.42.1",
|
||||
"@wordpress/annotations": "2.42.1",
|
||||
"@wordpress/api-fetch": "6.39.1",
|
||||
"@wordpress/autop": "3.42.1",
|
||||
"@wordpress/blob": "3.42.1",
|
||||
"@wordpress/block-directory": "4.19.1",
|
||||
"@wordpress/block-editor": "12.10.1",
|
||||
"@wordpress/block-library": "8.19.1",
|
||||
"@wordpress/block-serialization-default-parser": "4.42.1",
|
||||
"@wordpress/blocks": "12.19.1",
|
||||
"@wordpress/commands": "0.13.1",
|
||||
"@wordpress/components": "25.8.1",
|
||||
"@wordpress/compose": "6.19.1",
|
||||
"@wordpress/core-commands": "0.11.1",
|
||||
"@wordpress/core-data": "6.19.1",
|
||||
"@wordpress/customize-widgets": "4.19.1",
|
||||
"@wordpress/data": "9.12.1",
|
||||
"@wordpress/data-controls": "3.11.1",
|
||||
"@wordpress/date": "4.42.1",
|
||||
"@wordpress/deprecated": "3.42.1",
|
||||
"@wordpress/dom": "3.42.1",
|
||||
"@wordpress/dom-ready": "3.42.1",
|
||||
"@wordpress/edit-post": "7.19.1",
|
||||
"@wordpress/edit-site": "5.19.1",
|
||||
"@wordpress/edit-widgets": "5.19.1",
|
||||
"@wordpress/editor": "13.19.1",
|
||||
"@wordpress/element": "5.19.1",
|
||||
"@wordpress/escape-html": "2.42.1",
|
||||
"@wordpress/format-library": "4.19.1",
|
||||
"@wordpress/hooks": "3.42.1",
|
||||
"@wordpress/html-entities": "3.42.1",
|
||||
"@wordpress/i18n": "4.42.1",
|
||||
"@wordpress/icons": "9.33.1",
|
||||
"@wordpress/interactivity": "2.3.1",
|
||||
"@wordpress/interface": "5.19.1",
|
||||
"@wordpress/is-shallow-equal": "4.42.1",
|
||||
"@wordpress/keyboard-shortcuts": "4.19.1",
|
||||
"@wordpress/keycodes": "3.42.1",
|
||||
"@wordpress/list-reusable-blocks": "4.19.1",
|
||||
"@wordpress/media-utils": "4.33.1",
|
||||
"@wordpress/notices": "4.10.1",
|
||||
"@wordpress/nux": "8.4.1",
|
||||
"@wordpress/patterns": "1.3.1",
|
||||
"@wordpress/plugins": "6.10.1",
|
||||
"@wordpress/preferences": "3.19.1",
|
||||
"@wordpress/preferences-persistence": "1.34.1",
|
||||
"@wordpress/primitives": "3.40.1",
|
||||
"@wordpress/priority-queue": "2.42.1",
|
||||
"@wordpress/private-apis": "0.24.1",
|
||||
"@wordpress/redux-routine": "4.42.1",
|
||||
"@wordpress/reusable-blocks": "4.19.1",
|
||||
"@wordpress/rich-text": "6.19.1",
|
||||
"@wordpress/router": "0.11.1",
|
||||
"@wordpress/server-side-render": "4.19.1",
|
||||
"@wordpress/shortcode": "3.42.1",
|
||||
"@wordpress/style-engine": "1.25.1",
|
||||
"@wordpress/sync": "0.4.1",
|
||||
"@wordpress/token-list": "2.42.1",
|
||||
"@wordpress/undo-manager": "0.2.1",
|
||||
"@wordpress/url": "3.43.1",
|
||||
"@wordpress/viewport": "5.19.1",
|
||||
"@wordpress/warning": "2.42.1",
|
||||
"@wordpress/widgets": "3.19.1",
|
||||
"@wordpress/wordcount": "3.42.1",
|
||||
"backbone": "1.5.0",
|
||||
"clipboard": "2.0.11",
|
||||
"core-js-url-browser": "3.6.4",
|
||||
"element-closest": "^3.0.2",
|
||||
"formdata-polyfill": "4.0.10",
|
||||
"framer-motion": "10.11.6",
|
||||
"framer-motion": "10.16.4",
|
||||
"hoverintent": "2.2.1",
|
||||
"imagesloaded": "5.0.0",
|
||||
"is-plain-object": "5.0.0",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -112,12 +112,12 @@ function get_block_core_avatar_border_attributes( $attributes ) {
|
||||
|
||||
// Border color.
|
||||
$preset_color = array_key_exists( 'borderColor', $attributes ) ? "var:preset|color|{$attributes['borderColor']}" : null;
|
||||
$custom_color = _wp_array_get( $attributes, array( 'style', 'border', 'color' ), null );
|
||||
$custom_color = $attributes['style']['border']['color'] ?? null;
|
||||
$border_styles['color'] = $preset_color ? $preset_color : $custom_color;
|
||||
|
||||
// Individual border styles e.g. top, left etc.
|
||||
foreach ( $sides as $side ) {
|
||||
$border = _wp_array_get( $attributes, array( 'style', 'border', $side ), null );
|
||||
$border = $attributes['style']['border'][ $side ] ?? null;
|
||||
$border_styles[ $side ] = array(
|
||||
'color' => isset( $border['color'] ) ? $border['color'] : null,
|
||||
'style' => isset( $border['style'] ) ? $border['style'] : null,
|
||||
|
||||
@ -48,6 +48,9 @@
|
||||
"__experimentalDuotone": "img"
|
||||
}
|
||||
},
|
||||
"selectors": {
|
||||
"border": ".wp-block-avatar img"
|
||||
},
|
||||
"editorStyle": "wp-block-avatar-editor",
|
||||
"style": "wp-block-avatar"
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
"title": "Pattern",
|
||||
"category": "reusable",
|
||||
"description": "Create and save content to reuse across your site. Update the pattern, and the changes apply everywhere it’s used.",
|
||||
"keywords": [ "reusable" ],
|
||||
"keywords": [ "reusable" ],
|
||||
"textdomain": "default",
|
||||
"attributes": {
|
||||
"ref": {
|
||||
|
||||
@ -172,6 +172,9 @@
|
||||
'__experimentalDuotone' => 'img'
|
||||
)
|
||||
),
|
||||
'selectors' => array(
|
||||
'border' => '.wp-block-avatar img'
|
||||
),
|
||||
'editorStyle' => 'wp-block-avatar-editor',
|
||||
'style' => 'wp-block-avatar'
|
||||
),
|
||||
@ -212,6 +215,18 @@
|
||||
),
|
||||
'textdomain' => 'default',
|
||||
'attributes' => array(
|
||||
'tagName' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array(
|
||||
'a',
|
||||
'button'
|
||||
),
|
||||
'default' => 'a'
|
||||
),
|
||||
'type' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'button'
|
||||
),
|
||||
'textAlign' => array(
|
||||
'type' => 'string'
|
||||
),
|
||||
@ -225,14 +240,14 @@
|
||||
'title' => array(
|
||||
'type' => 'string',
|
||||
'source' => 'attribute',
|
||||
'selector' => 'a',
|
||||
'selector' => 'a,button',
|
||||
'attribute' => 'title',
|
||||
'__experimentalRole' => 'content'
|
||||
),
|
||||
'text' => array(
|
||||
'type' => 'string',
|
||||
'source' => 'html',
|
||||
'selector' => 'a',
|
||||
'selector' => 'a,button',
|
||||
'__experimentalRole' => 'content'
|
||||
),
|
||||
'linkTarget' => array(
|
||||
@ -503,7 +518,8 @@
|
||||
'content' => array(
|
||||
'type' => 'string',
|
||||
'source' => 'html',
|
||||
'selector' => 'code'
|
||||
'selector' => 'code',
|
||||
'__unstablePreserveWhiteSpace' => true
|
||||
)
|
||||
),
|
||||
'supports' => array(
|
||||
@ -592,11 +608,14 @@
|
||||
)
|
||||
),
|
||||
'supports' => array(
|
||||
'__experimentalOnEnter' => true,
|
||||
'anchor' => true,
|
||||
'reusable' => false,
|
||||
'html' => false,
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'heading' => true,
|
||||
'button' => true,
|
||||
'link' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'background' => true,
|
||||
@ -676,6 +695,8 @@
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'link' => true,
|
||||
'heading' => true,
|
||||
'button' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'background' => true,
|
||||
'text' => true
|
||||
@ -1066,6 +1087,7 @@
|
||||
'html' => false,
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'heading' => true,
|
||||
'link' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'background' => true,
|
||||
@ -1478,11 +1500,13 @@
|
||||
),
|
||||
'color' => array(
|
||||
'__experimentalDuotone' => '> .wp-block-cover__image-background, > .wp-block-cover__video-background',
|
||||
'heading' => true,
|
||||
'text' => true,
|
||||
'background' => false,
|
||||
'__experimentalSkipSerialization' => array(
|
||||
'gradients'
|
||||
)
|
||||
),
|
||||
'enableContrastChecker' => false
|
||||
),
|
||||
'typography' => array(
|
||||
'fontSize' => true,
|
||||
@ -1512,9 +1536,10 @@
|
||||
'category' => 'text',
|
||||
'description' => 'Hide and show additional content.',
|
||||
'keywords' => array(
|
||||
'disclosure',
|
||||
'accordion',
|
||||
'summary',
|
||||
'hide'
|
||||
'toggle',
|
||||
'disclosure'
|
||||
),
|
||||
'textdomain' => 'default',
|
||||
'attributes' => array(
|
||||
@ -1523,7 +1548,9 @@
|
||||
'default' => false
|
||||
),
|
||||
'summary' => array(
|
||||
'type' => 'string'
|
||||
'type' => 'string',
|
||||
'source' => 'html',
|
||||
'selector' => 'summary'
|
||||
)
|
||||
),
|
||||
'supports' => array(
|
||||
@ -1548,6 +1575,7 @@
|
||||
'spacing' => array(
|
||||
'margin' => true,
|
||||
'padding' => true,
|
||||
'blockGap' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'margin' => false,
|
||||
'padding' => false
|
||||
@ -1565,6 +1593,9 @@
|
||||
'__experimentalDefaultControls' => array(
|
||||
'fontSize' => true
|
||||
)
|
||||
),
|
||||
'layout' => array(
|
||||
'allowEditing' => false
|
||||
)
|
||||
),
|
||||
'editorStyle' => 'wp-block-details-editor',
|
||||
@ -1684,6 +1715,10 @@
|
||||
'supports' => array(
|
||||
'anchor' => true,
|
||||
'align' => true,
|
||||
'spacing' => array(
|
||||
'margin' => true,
|
||||
'padding' => true
|
||||
),
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'link' => true,
|
||||
@ -1692,7 +1727,8 @@
|
||||
'background' => true,
|
||||
'link' => true
|
||||
)
|
||||
)
|
||||
),
|
||||
'interactivity' => true
|
||||
),
|
||||
'viewScript' => 'file:./view.min.js',
|
||||
'editorStyle' => 'wp-block-file-editor',
|
||||
@ -1714,9 +1750,52 @@
|
||||
'postType'
|
||||
),
|
||||
'supports' => array(
|
||||
'__experimentalBorder' => array(
|
||||
'radius' => true,
|
||||
'color' => true,
|
||||
'width' => true,
|
||||
'style' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'radius' => false,
|
||||
'color' => false,
|
||||
'width' => false,
|
||||
'style' => false
|
||||
)
|
||||
),
|
||||
'color' => array(
|
||||
'background' => true,
|
||||
'link' => true,
|
||||
'text' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'link' => true,
|
||||
'text' => true
|
||||
)
|
||||
),
|
||||
'html' => false,
|
||||
'multiple' => false,
|
||||
'reusable' => false
|
||||
'reusable' => false,
|
||||
'spacing' => array(
|
||||
'margin' => true,
|
||||
'padding' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'margin' => false,
|
||||
'padding' => false
|
||||
)
|
||||
),
|
||||
'typography' => array(
|
||||
'fontSize' => true,
|
||||
'lineHeight' => true,
|
||||
'__experimentalFontFamily' => true,
|
||||
'__experimentalTextDecoration' => true,
|
||||
'__experimentalFontStyle' => true,
|
||||
'__experimentalFontWeight' => true,
|
||||
'__experimentalLetterSpacing' => true,
|
||||
'__experimentalTextTransform' => true,
|
||||
'__experimentalWritingMode' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'fontSize' => true
|
||||
)
|
||||
)
|
||||
),
|
||||
'style' => 'wp-block-footnotes'
|
||||
),
|
||||
@ -1811,11 +1890,11 @@
|
||||
),
|
||||
'shortCodeTransforms' => array(
|
||||
'type' => 'array',
|
||||
'default' => array(
|
||||
|
||||
),
|
||||
'items' => array(
|
||||
'type' => 'object'
|
||||
),
|
||||
'default' => array(
|
||||
|
||||
)
|
||||
),
|
||||
'columns' => array(
|
||||
@ -1937,7 +2016,9 @@
|
||||
),
|
||||
'supports' => array(
|
||||
'__experimentalOnEnter' => true,
|
||||
'__experimentalOnMerge' => true,
|
||||
'__experimentalSettings' => true,
|
||||
'__experimentalMetadata' => true,
|
||||
'align' => array(
|
||||
'wide',
|
||||
'full'
|
||||
@ -1945,8 +2026,13 @@
|
||||
'anchor' => true,
|
||||
'ariaLabel' => true,
|
||||
'html' => false,
|
||||
'background' => array(
|
||||
'backgroundImage' => true
|
||||
),
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'heading' => true,
|
||||
'button' => true,
|
||||
'link' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'background' => true,
|
||||
@ -2066,6 +2152,7 @@
|
||||
'__experimentalLetterSpacing' => true,
|
||||
'__experimentalTextTransform' => true,
|
||||
'__experimentalTextDecoration' => true,
|
||||
'__experimentalWritingMode' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'fontSize' => true,
|
||||
'fontAppearance' => true,
|
||||
@ -2190,6 +2277,12 @@
|
||||
'selector' => 'figcaption',
|
||||
'__experimentalRole' => 'content'
|
||||
),
|
||||
'lightbox' => array(
|
||||
'type' => 'object',
|
||||
'enabled' => array(
|
||||
'type' => 'boolean'
|
||||
)
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'string',
|
||||
'source' => 'attribute',
|
||||
@ -2247,9 +2340,6 @@
|
||||
),
|
||||
'supports' => array(
|
||||
'anchor' => true,
|
||||
'behaviors' => array(
|
||||
'lightbox' => true
|
||||
),
|
||||
'color' => array(
|
||||
'text' => false,
|
||||
'background' => false
|
||||
@ -2287,7 +2377,8 @@
|
||||
)
|
||||
),
|
||||
'editorStyle' => 'wp-block-image-editor',
|
||||
'style' => 'wp-block-image'
|
||||
'style' => 'wp-block-image',
|
||||
'viewScript' => 'file:./view.min.js'
|
||||
),
|
||||
'latest-comments' => array(
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
@ -2573,6 +2664,7 @@
|
||||
),
|
||||
'__unstablePasteTextInline' => true,
|
||||
'__experimentalSelector' => 'ol,ul',
|
||||
'__experimentalOnMerge' => true,
|
||||
'__experimentalSlashInserter' => true
|
||||
),
|
||||
'editorStyle' => 'wp-block-list-editor',
|
||||
@ -2767,6 +2859,7 @@
|
||||
'html' => false,
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'heading' => true,
|
||||
'link' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'background' => true,
|
||||
@ -2958,6 +3051,7 @@
|
||||
'wide',
|
||||
'full'
|
||||
),
|
||||
'ariaLabel' => true,
|
||||
'html' => false,
|
||||
'inserter' => true,
|
||||
'typography' => array(
|
||||
@ -3006,12 +3100,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
'viewScript' => array(
|
||||
'file:./view.min.js',
|
||||
'file:./view-modal.min.js'
|
||||
),
|
||||
'interactivity' => true
|
||||
),
|
||||
'viewScript' => 'file:./view.min.js',
|
||||
'editorStyle' => 'wp-block-navigation-editor',
|
||||
'style' => 'wp-block-navigation'
|
||||
),
|
||||
@ -3310,6 +3402,9 @@
|
||||
'text'
|
||||
),
|
||||
'textdomain' => 'default',
|
||||
'usesContext' => array(
|
||||
'postId'
|
||||
),
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string'
|
||||
@ -3347,6 +3442,7 @@
|
||||
'text' => true
|
||||
)
|
||||
),
|
||||
'__experimentalConnections' => true,
|
||||
'spacing' => array(
|
||||
'margin' => true,
|
||||
'padding' => true,
|
||||
@ -3364,6 +3460,7 @@
|
||||
'__experimentalFontWeight' => true,
|
||||
'__experimentalLetterSpacing' => true,
|
||||
'__experimentalTextTransform' => true,
|
||||
'__experimentalWritingMode' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'fontSize' => true
|
||||
)
|
||||
@ -3396,7 +3493,7 @@
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
'apiVersion' => 3,
|
||||
'name' => 'core/post-author',
|
||||
'title' => 'Post Author',
|
||||
'title' => 'Author',
|
||||
'category' => 'theme',
|
||||
'description' => 'Display post author details such as name, avatar, and bio.',
|
||||
'textdomain' => 'default',
|
||||
@ -3467,7 +3564,7 @@
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
'apiVersion' => 3,
|
||||
'name' => 'core/post-author-biography',
|
||||
'title' => 'Post Author Biography',
|
||||
'title' => 'Author Biography',
|
||||
'category' => 'theme',
|
||||
'description' => 'The author biography.',
|
||||
'textdomain' => 'default',
|
||||
@ -3512,7 +3609,7 @@
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
'apiVersion' => 3,
|
||||
'name' => 'core/post-author-name',
|
||||
'title' => 'Post Author Name',
|
||||
'title' => 'Author Name',
|
||||
'category' => 'theme',
|
||||
'description' => 'The author name.',
|
||||
'textdomain' => 'default',
|
||||
@ -3567,7 +3664,7 @@
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
'apiVersion' => 3,
|
||||
'name' => 'core/post-comments-form',
|
||||
'title' => 'Post Comments Form',
|
||||
'title' => 'Comments Form',
|
||||
'category' => 'theme',
|
||||
'description' => 'Display a post\'s comments form.',
|
||||
'textdomain' => 'default',
|
||||
@ -3584,6 +3681,7 @@
|
||||
'html' => false,
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'heading' => true,
|
||||
'link' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'background' => true,
|
||||
@ -3617,7 +3715,7 @@
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
'apiVersion' => 3,
|
||||
'name' => 'core/post-content',
|
||||
'title' => 'Post Content',
|
||||
'title' => 'Content',
|
||||
'category' => 'theme',
|
||||
'description' => 'Displays the contents of a post or page.',
|
||||
'textdomain' => 'default',
|
||||
@ -3636,6 +3734,17 @@
|
||||
'dimensions' => array(
|
||||
'minHeight' => true
|
||||
),
|
||||
'spacing' => array(
|
||||
'blockGap' => true
|
||||
),
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'link' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'background' => false,
|
||||
'text' => false
|
||||
)
|
||||
),
|
||||
'typography' => array(
|
||||
'fontSize' => true,
|
||||
'lineHeight' => true,
|
||||
@ -3656,9 +3765,9 @@
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
'apiVersion' => 3,
|
||||
'name' => 'core/post-date',
|
||||
'title' => 'Post Date',
|
||||
'title' => 'Date',
|
||||
'category' => 'theme',
|
||||
'description' => 'Add the date of this post.',
|
||||
'description' => 'Display the publish date for an entry such as a post or page.',
|
||||
'textdomain' => 'default',
|
||||
'attributes' => array(
|
||||
'textAlign' => array(
|
||||
@ -3776,7 +3885,7 @@
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
'apiVersion' => 3,
|
||||
'name' => 'core/post-featured-image',
|
||||
'title' => 'Post Featured Image',
|
||||
'title' => 'Featured Image',
|
||||
'category' => 'theme',
|
||||
'description' => 'Display a post\'s featured image.',
|
||||
'textdomain' => 'default',
|
||||
@ -3913,6 +4022,7 @@
|
||||
'__experimentalTextTransform' => true,
|
||||
'__experimentalTextDecoration' => true,
|
||||
'__experimentalLetterSpacing' => true,
|
||||
'__experimentalWritingMode' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'fontSize' => true
|
||||
)
|
||||
@ -3937,7 +4047,8 @@
|
||||
'queryContext',
|
||||
'displayLayout',
|
||||
'templateSlug',
|
||||
'previewPostType'
|
||||
'previewPostType',
|
||||
'enhancedPagination'
|
||||
),
|
||||
'supports' => array(
|
||||
'reusable' => false,
|
||||
@ -4142,6 +4253,10 @@
|
||||
'text' => true
|
||||
)
|
||||
),
|
||||
'spacing' => array(
|
||||
'padding' => true,
|
||||
'margin' => true
|
||||
),
|
||||
'typography' => array(
|
||||
'fontSize' => true,
|
||||
'lineHeight' => true,
|
||||
@ -4277,12 +4392,17 @@
|
||||
),
|
||||
'namespace' => array(
|
||||
'type' => 'string'
|
||||
),
|
||||
'enhancedPagination' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false
|
||||
)
|
||||
),
|
||||
'providesContext' => array(
|
||||
'queryId' => 'queryId',
|
||||
'query' => 'query',
|
||||
'displayLayout' => 'displayLayout'
|
||||
'displayLayout' => 'displayLayout',
|
||||
'enhancedPagination' => 'enhancedPagination'
|
||||
),
|
||||
'supports' => array(
|
||||
'align' => array(
|
||||
@ -4292,7 +4412,9 @@
|
||||
'html' => false,
|
||||
'layout' => true
|
||||
),
|
||||
'editorStyle' => 'wp-block-query-editor'
|
||||
'editorStyle' => 'wp-block-query-editor',
|
||||
'style' => 'wp-block-query',
|
||||
'viewScript' => 'file:./view.min.js'
|
||||
),
|
||||
'query-no-results' => array(
|
||||
'$schema' => 'https://schemas.wp.org/trunk/block.json',
|
||||
@ -4418,7 +4540,8 @@
|
||||
'queryId',
|
||||
'query',
|
||||
'paginationArrow',
|
||||
'showLabel'
|
||||
'showLabel',
|
||||
'enhancedPagination'
|
||||
),
|
||||
'supports' => array(
|
||||
'reusable' => false,
|
||||
@ -4456,9 +4579,16 @@
|
||||
),
|
||||
'description' => 'Displays a list of page numbers for pagination',
|
||||
'textdomain' => 'default',
|
||||
'attributes' => array(
|
||||
'midSize' => array(
|
||||
'type' => 'number',
|
||||
'default' => 2
|
||||
)
|
||||
),
|
||||
'usesContext' => array(
|
||||
'queryId',
|
||||
'query'
|
||||
'query',
|
||||
'enhancedPagination'
|
||||
),
|
||||
'supports' => array(
|
||||
'reusable' => false,
|
||||
@ -4506,7 +4636,8 @@
|
||||
'queryId',
|
||||
'query',
|
||||
'paginationArrow',
|
||||
'showLabel'
|
||||
'showLabel',
|
||||
'enhancedPagination'
|
||||
),
|
||||
'supports' => array(
|
||||
'reusable' => false,
|
||||
@ -4632,6 +4763,7 @@
|
||||
'anchor' => true,
|
||||
'html' => false,
|
||||
'__experimentalOnEnter' => true,
|
||||
'__experimentalOnMerge' => true,
|
||||
'typography' => array(
|
||||
'fontSize' => true,
|
||||
'lineHeight' => true,
|
||||
@ -4648,6 +4780,7 @@
|
||||
),
|
||||
'color' => array(
|
||||
'gradients' => true,
|
||||
'heading' => true,
|
||||
'link' => true,
|
||||
'__experimentalDefaultControls' => array(
|
||||
'background' => true,
|
||||
@ -4855,6 +4988,7 @@
|
||||
'text' => true
|
||||
)
|
||||
),
|
||||
'interactivity' => true,
|
||||
'typography' => array(
|
||||
'__experimentalSkipSerialization' => true,
|
||||
'__experimentalSelector' => '.wp-block-search__label, .wp-block-search__input, .wp-block-search__button',
|
||||
|
||||
@ -9,6 +9,15 @@
|
||||
"keywords": [ "link" ],
|
||||
"textdomain": "default",
|
||||
"attributes": {
|
||||
"tagName": {
|
||||
"type": "string",
|
||||
"enum": [ "a", "button" ],
|
||||
"default": "a"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"default": "button"
|
||||
},
|
||||
"textAlign": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -22,14 +31,14 @@
|
||||
"title": {
|
||||
"type": "string",
|
||||
"source": "attribute",
|
||||
"selector": "a",
|
||||
"selector": "a,button",
|
||||
"attribute": "title",
|
||||
"__experimentalRole": "content"
|
||||
},
|
||||
"text": {
|
||||
"type": "string",
|
||||
"source": "html",
|
||||
"selector": "a",
|
||||
"selector": "a,button",
|
||||
"__experimentalRole": "content"
|
||||
},
|
||||
"linkTarget": {
|
||||
|
||||
@ -44,12 +44,12 @@ function render_block_core_calendar( $attributes ) {
|
||||
|
||||
// Text color.
|
||||
$preset_text_color = array_key_exists( 'textColor', $attributes ) ? "var:preset|color|{$attributes['textColor']}" : null;
|
||||
$custom_text_color = _wp_array_get( $attributes, array( 'style', 'color', 'text' ), null );
|
||||
$custom_text_color = $attributes['style']['color']['text'] ?? null;
|
||||
$color_block_styles['text'] = $preset_text_color ? $preset_text_color : $custom_text_color;
|
||||
|
||||
// Background Color.
|
||||
$preset_background_color = array_key_exists( 'backgroundColor', $attributes ) ? "var:preset|color|{$attributes['backgroundColor']}" : null;
|
||||
$custom_background_color = _wp_array_get( $attributes, array( 'style', 'color', 'background' ), null );
|
||||
$custom_background_color = $attributes['style']['color']['background'] ?? null;
|
||||
$color_block_styles['background'] = $preset_background_color ? $preset_background_color : $custom_background_color;
|
||||
|
||||
// Generate color styles and classes.
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
"content": {
|
||||
"type": "string",
|
||||
"source": "html",
|
||||
"selector": "code"
|
||||
"selector": "code",
|
||||
"__unstablePreserveWhiteSpace": true
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
|
||||
@ -23,11 +23,14 @@
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"__experimentalOnEnter": true,
|
||||
"anchor": true,
|
||||
"reusable": false,
|
||||
"html": false,
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"heading": true,
|
||||
"button": true,
|
||||
"link": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"background": true,
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"link": true,
|
||||
"heading": true,
|
||||
"button": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"background": true,
|
||||
"text": true
|
||||
|
||||
@ -28,7 +28,7 @@ function block_core_comment_template_render_comments( $comments, $block ) {
|
||||
$content = '';
|
||||
foreach ( $comments as $comment ) {
|
||||
$comment_id = $comment->comment_ID;
|
||||
$filter_block_context = static function( $context ) use ( $comment_id ) {
|
||||
$filter_block_context = static function ( $context ) use ( $comment_id ) {
|
||||
$context['commentId'] = $comment_id;
|
||||
return $context;
|
||||
};
|
||||
|
||||
@ -26,7 +26,7 @@ function render_block_core_comments_pagination_next( $attributes, $content, $blo
|
||||
$label = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
|
||||
$pagination_arrow = get_comments_pagination_arrow( $block, 'next' );
|
||||
|
||||
$filter_link_attributes = static function() {
|
||||
$filter_link_attributes = static function () {
|
||||
return get_block_wrapper_attributes();
|
||||
};
|
||||
add_filter( 'next_comments_link_attributes', $filter_link_attributes );
|
||||
|
||||
@ -22,7 +22,7 @@ function render_block_core_comments_pagination_previous( $attributes, $content,
|
||||
$label = $pagination_arrow . $label;
|
||||
}
|
||||
|
||||
$filter_link_attributes = static function() {
|
||||
$filter_link_attributes = static function () {
|
||||
return get_block_wrapper_attributes();
|
||||
};
|
||||
add_filter( 'previous_comments_link_attributes', $filter_link_attributes );
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
"html": false,
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"heading": true,
|
||||
"link": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"background": true,
|
||||
|
||||
@ -108,9 +108,11 @@
|
||||
},
|
||||
"color": {
|
||||
"__experimentalDuotone": "> .wp-block-cover__image-background, > .wp-block-cover__video-background",
|
||||
"heading": true,
|
||||
"text": true,
|
||||
"background": false,
|
||||
"__experimentalSkipSerialization": [ "gradients" ]
|
||||
"__experimentalSkipSerialization": [ "gradients" ],
|
||||
"enableContrastChecker": false
|
||||
},
|
||||
"typography": {
|
||||
"fontSize": true,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
"title": "Details",
|
||||
"category": "text",
|
||||
"description": "Hide and show additional content.",
|
||||
"keywords": [ "disclosure", "summary", "hide" ],
|
||||
"keywords": [ "accordion", "summary", "toggle", "disclosure" ],
|
||||
"textdomain": "default",
|
||||
"attributes": {
|
||||
"showContent": {
|
||||
@ -13,7 +13,9 @@
|
||||
"default": false
|
||||
},
|
||||
"summary": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"source": "html",
|
||||
"selector": "summary"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
@ -35,6 +37,7 @@
|
||||
"spacing": {
|
||||
"margin": true,
|
||||
"padding": true,
|
||||
"blockGap": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"margin": false,
|
||||
"padding": false
|
||||
@ -52,6 +55,9 @@
|
||||
"__experimentalDefaultControls": {
|
||||
"fontSize": true
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"allowEditing": false
|
||||
}
|
||||
},
|
||||
"editorStyle": "wp-block-details-editor",
|
||||
|
||||
@ -5,25 +5,8 @@
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
||||
/**
|
||||
* Replaces view script for the File block with version using Interactivity API.
|
||||
*
|
||||
* @param array $metadata Block metadata as read in via block.json.
|
||||
*
|
||||
* @return array Filtered block type metadata.
|
||||
*/
|
||||
function gutenberg_block_core_file_update_interactive_view_script( $metadata ) {
|
||||
if ( 'core/file' === $metadata['name'] ) {
|
||||
$metadata['viewScript'] = array( 'file:./interactivity.min.js' );
|
||||
}
|
||||
return $metadata;
|
||||
}
|
||||
add_filter( 'block_type_metadata', 'gutenberg_block_core_file_update_interactive_view_script', 10, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* When the `core/file` block is rendering, check if we need to enqueue the `'wp-block-file-view` script.
|
||||
* When the `core/file` block is rendering, check if we need to enqueue the `wp-block-file-view` script.
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
* @param string $content The block content.
|
||||
@ -71,19 +54,37 @@ function render_block_core_file( $attributes, $content, $block ) {
|
||||
);
|
||||
|
||||
// If it uses the Interactivity API, add the directives.
|
||||
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $should_load_view_script ) {
|
||||
if ( $should_load_view_script ) {
|
||||
$processor = new WP_HTML_Tag_Processor( $content );
|
||||
$processor->next_tag();
|
||||
$processor->set_attribute( 'data-wp-interactive', '' );
|
||||
$processor->next_tag( 'object' );
|
||||
$processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
|
||||
$processor->set_attribute( 'hidden', true );
|
||||
$processor->set_attribute( 'data-wp-style--display', 'selectors.core.file.hasPdfPreview' );
|
||||
return $processor->get_updated_html();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the view script has the `wp-interactivity` dependency.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @global WP_Scripts $wp_scripts
|
||||
*/
|
||||
function block_core_file_ensure_interactivity_dependency() {
|
||||
global $wp_scripts;
|
||||
if (
|
||||
isset( $wp_scripts->registered['wp-block-file-view'] ) &&
|
||||
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-file-view']->deps, true )
|
||||
) {
|
||||
$wp_scripts->registered['wp-block-file-view']->deps[] = 'wp-interactivity';
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_print_scripts', 'block_core_file_ensure_interactivity_dependency' );
|
||||
|
||||
/**
|
||||
* Registers the `core/file` block on server.
|
||||
*/
|
||||
|
||||
@ -57,6 +57,10 @@
|
||||
"supports": {
|
||||
"anchor": true,
|
||||
"align": true,
|
||||
"spacing": {
|
||||
"margin": true,
|
||||
"padding": true
|
||||
},
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"link": true,
|
||||
@ -65,7 +69,8 @@
|
||||
"background": true,
|
||||
"link": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"interactivity": true
|
||||
},
|
||||
"viewScript": "file:./view.min.js",
|
||||
"editorStyle": "wp-block-file-editor",
|
||||
|
||||
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => 'ebbbc9ac027ad9970c8e');
|
||||
<?php return array('dependencies' => array(), 'version' => '2b632fa4c08cb0d6a2fb');
|
||||
|
||||
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '9d287166f699a66eff3b');
|
||||
<?php return array('dependencies' => array(), 'version' => '04232c367aee581e5f25');
|
||||
|
||||
@ -9,9 +9,52 @@
|
||||
"textdomain": "default",
|
||||
"usesContext": [ "postId", "postType" ],
|
||||
"supports": {
|
||||
"__experimentalBorder": {
|
||||
"radius": true,
|
||||
"color": true,
|
||||
"width": true,
|
||||
"style": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"radius": false,
|
||||
"color": false,
|
||||
"width": false,
|
||||
"style": false
|
||||
}
|
||||
},
|
||||
"color": {
|
||||
"background": true,
|
||||
"link": true,
|
||||
"text": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"link": true,
|
||||
"text": true
|
||||
}
|
||||
},
|
||||
"html": false,
|
||||
"multiple": false,
|
||||
"reusable": false
|
||||
"reusable": false,
|
||||
"spacing": {
|
||||
"margin": true,
|
||||
"padding": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"margin": false,
|
||||
"padding": false
|
||||
}
|
||||
},
|
||||
"typography": {
|
||||
"fontSize": true,
|
||||
"lineHeight": true,
|
||||
"__experimentalFontFamily": true,
|
||||
"__experimentalTextDecoration": true,
|
||||
"__experimentalFontStyle": true,
|
||||
"__experimentalFontWeight": true,
|
||||
"__experimentalLetterSpacing": true,
|
||||
"__experimentalTextTransform": true,
|
||||
"__experimentalWritingMode": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"fontSize": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"style": "wp-block-footnotes"
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility'
|
||||
* @return string The content of the block being rendered.
|
||||
*/
|
||||
function block_core_gallery_render( $attributes, $content ) {
|
||||
$gap = _wp_array_get( $attributes, array( 'style', 'spacing', 'blockGap' ) );
|
||||
$gap = $attributes['style']['spacing']['blockGap'] ?? null;
|
||||
// Skip if gap value contains unsupported characters.
|
||||
// Regex for CSS value borrowed from `safecss_filter_attr`, and used here
|
||||
// because we only want to match against the value, not the CSS attribute.
|
||||
|
||||
@ -61,10 +61,10 @@
|
||||
},
|
||||
"shortCodeTransforms": {
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"columns": {
|
||||
"type": "number",
|
||||
|
||||
@ -22,13 +22,20 @@
|
||||
},
|
||||
"supports": {
|
||||
"__experimentalOnEnter": true,
|
||||
"__experimentalOnMerge": true,
|
||||
"__experimentalSettings": true,
|
||||
"__experimentalMetadata": true,
|
||||
"align": [ "wide", "full" ],
|
||||
"anchor": true,
|
||||
"ariaLabel": true,
|
||||
"html": false,
|
||||
"background": {
|
||||
"backgroundImage": true
|
||||
},
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"heading": true,
|
||||
"button": true,
|
||||
"link": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"background": true,
|
||||
|
||||
@ -55,6 +55,7 @@
|
||||
"__experimentalLetterSpacing": true,
|
||||
"__experimentalTextTransform": true,
|
||||
"__experimentalTextDecoration": true,
|
||||
"__experimentalWritingMode": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"fontSize": true,
|
||||
"fontAppearance": true,
|
||||
|
||||
@ -98,8 +98,15 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) {
|
||||
$colors['css_classes'],
|
||||
$font_sizes['css_classes']
|
||||
);
|
||||
$classes[] = 'wp-block-navigation-item';
|
||||
$style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
|
||||
$classes[] = 'wp-block-navigation-item';
|
||||
|
||||
if ( is_front_page() ) {
|
||||
$classes[] = 'current-menu-item';
|
||||
} elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) {
|
||||
// Edge case where the Reading settings has a posts page set but not a static homepage.
|
||||
$classes[] = 'current-menu-item';
|
||||
}
|
||||
|
||||
$wrapper_attributes = get_block_wrapper_attributes(
|
||||
array(
|
||||
@ -124,8 +131,14 @@ function render_block_core_home_link( $attributes, $content, $block ) {
|
||||
if ( empty( $attributes['label'] ) ) {
|
||||
return '';
|
||||
}
|
||||
$aria_current = '';
|
||||
|
||||
$aria_current = is_home() || ( is_front_page() && 'page' === get_option( 'show_on_front' ) ) ? ' aria-current="page"' : '';
|
||||
if ( is_front_page() ) {
|
||||
$aria_current = ' aria-current="page"';
|
||||
} elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) {
|
||||
// Edge case where the Reading settings has a posts page set but not a static homepage.
|
||||
$aria_current = ' aria-current="page"';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" rel="home"%3$s>%4$s</a></li>',
|
||||
|
||||
@ -9,11 +9,12 @@
|
||||
* Renders the `core/image` block on the server,
|
||||
* adding a data-id attribute to the element if core/gallery has added on pre-render.
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
* @param string $content The block content.
|
||||
* @param array $attributes The block attributes.
|
||||
* @param string $content The block content.
|
||||
* @param WP_Block $block The block object.
|
||||
* @return string Returns the block content with the data-id attribute added.
|
||||
*/
|
||||
function render_block_core_image( $attributes, $content ) {
|
||||
function render_block_core_image( $attributes, $content, $block ) {
|
||||
|
||||
$processor = new WP_HTML_Tag_Processor( $content );
|
||||
$processor->next_tag( 'img' );
|
||||
@ -30,14 +31,280 @@ function render_block_core_image( $attributes, $content ) {
|
||||
$processor->set_attribute( 'data-id', $attributes['data-id'] );
|
||||
}
|
||||
|
||||
$lightbox_enabled = false;
|
||||
$link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
|
||||
$lightbox_settings = block_core_image_get_lightbox_settings( $block->parsed_block );
|
||||
|
||||
// If the lightbox is enabled and the image is not linked, flag the lightbox to be rendered.
|
||||
if ( isset( $lightbox_settings ) && 'none' === $link_destination ) {
|
||||
|
||||
if ( isset( $lightbox_settings['enabled'] ) && true === $lightbox_settings['enabled'] ) {
|
||||
$lightbox_enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If at least one block in the page has the lightbox, mark the block type as interactive.
|
||||
if ( $lightbox_enabled ) {
|
||||
$block->block_type->supports['interactivity'] = true;
|
||||
}
|
||||
|
||||
// Determine whether the view script should be enqueued or not.
|
||||
$view_js_file = 'wp-block-image-view';
|
||||
if ( ! wp_script_is( $view_js_file ) ) {
|
||||
$script_handles = $block->block_type->view_script_handles;
|
||||
|
||||
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
||||
if ( ! $lightbox_enabled && in_array( $view_js_file, $script_handles, true ) ) {
|
||||
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
||||
}
|
||||
// If the script is needed, but it was previously removed, add it again.
|
||||
if ( $lightbox_enabled && ! in_array( $view_js_file, $script_handles, true ) ) {
|
||||
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $lightbox_enabled ) {
|
||||
return block_core_image_render_lightbox( $processor->get_updated_html(), $block->parsed_block );
|
||||
}
|
||||
|
||||
return $processor->get_updated_html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the lightboxEnabled flag to the block data.
|
||||
*
|
||||
* This is used to determine whether the lightbox should be rendered or not.
|
||||
*
|
||||
* @param array $block Block data.
|
||||
* @return array Filtered block data.
|
||||
*/
|
||||
function block_core_image_get_lightbox_settings( $block ) {
|
||||
// Get the lightbox setting from the block attributes.
|
||||
if ( isset( $block['attrs']['lightbox'] ) ) {
|
||||
$lightbox_settings = $block['attrs']['lightbox'];
|
||||
// If the lightbox setting is not set in the block attributes,
|
||||
// check the legacy lightbox settings that are set using the
|
||||
// `gutenberg_should_render_lightbox` filter.
|
||||
// We can remove this elseif statement when the legacy lightbox settings are removed.
|
||||
} elseif ( isset( $block['legacyLightboxSettings'] ) ) {
|
||||
$lightbox_settings = $block['legacyLightboxSettings'];
|
||||
}
|
||||
|
||||
if ( ! isset( $lightbox_settings ) ) {
|
||||
$lightbox_settings = wp_get_global_settings( array( 'lightbox' ), array( 'block_name' => 'core/image' ) );
|
||||
|
||||
// If not present in global settings, check the top-level global settings.
|
||||
//
|
||||
// NOTE: If no block-level settings are found, the previous call to
|
||||
// `wp_get_global_settings` will return the whole `theme.json`
|
||||
// structure in which case we can check if the "lightbox" key is present at
|
||||
// the top-level of the global settings and use its value.
|
||||
if ( isset( $lightbox_settings['lightbox'] ) ) {
|
||||
$lightbox_settings = wp_get_global_settings( array( 'lightbox' ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $lightbox_settings ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the directives and layout needed for the lightbox behavior.
|
||||
*
|
||||
* @param string $block_content Rendered block content.
|
||||
* @param array $block Block object.
|
||||
* @return string Filtered block content.
|
||||
*/
|
||||
function block_core_image_render_lightbox( $block_content, $block ) {
|
||||
$processor = new WP_HTML_Tag_Processor( $block_content );
|
||||
|
||||
$aria_label = __( 'Enlarge image' );
|
||||
|
||||
$alt_attribute = $processor->get_attribute( 'alt' );
|
||||
|
||||
if ( null !== $alt_attribute ) {
|
||||
$alt_attribute = trim( $alt_attribute );
|
||||
}
|
||||
|
||||
if ( $alt_attribute ) {
|
||||
/* translators: %s: Image alt text. */
|
||||
$aria_label = sprintf( __( 'Enlarge image: %s' ), $alt_attribute );
|
||||
}
|
||||
$content = $processor->get_updated_html();
|
||||
|
||||
// Currently, we are only enabling the zoom animation.
|
||||
$lightbox_animation = 'zoom';
|
||||
|
||||
// We want to store the src in the context so we can set it dynamically when the lightbox is opened.
|
||||
$z = new WP_HTML_Tag_Processor( $content );
|
||||
$z->next_tag( 'img' );
|
||||
|
||||
if ( isset( $block['attrs']['id'] ) ) {
|
||||
$img_uploaded_src = wp_get_attachment_url( $block['attrs']['id'] );
|
||||
$img_metadata = wp_get_attachment_metadata( $block['attrs']['id'] );
|
||||
$img_width = $img_metadata['width'];
|
||||
$img_height = $img_metadata['height'];
|
||||
} else {
|
||||
$img_uploaded_src = $z->get_attribute( 'src' );
|
||||
$img_width = 'none';
|
||||
$img_height = 'none';
|
||||
}
|
||||
|
||||
if ( isset( $block['attrs']['scale'] ) ) {
|
||||
$scale_attr = $block['attrs']['scale'];
|
||||
} else {
|
||||
$scale_attr = false;
|
||||
}
|
||||
|
||||
$w = new WP_HTML_Tag_Processor( $content );
|
||||
$w->next_tag( 'figure' );
|
||||
$w->add_class( 'wp-lightbox-container' );
|
||||
$w->set_attribute( 'data-wp-interactive', true );
|
||||
|
||||
$w->set_attribute(
|
||||
'data-wp-context',
|
||||
sprintf(
|
||||
'{ "core":
|
||||
{ "image":
|
||||
{ "imageLoaded": false,
|
||||
"initialized": false,
|
||||
"lightboxEnabled": false,
|
||||
"hideAnimationEnabled": false,
|
||||
"preloadInitialized": false,
|
||||
"lightboxAnimation": "%s",
|
||||
"imageUploadedSrc": "%s",
|
||||
"imageCurrentSrc": "",
|
||||
"targetWidth": "%s",
|
||||
"targetHeight": "%s",
|
||||
"scaleAttr": "%s"
|
||||
}
|
||||
}
|
||||
}',
|
||||
$lightbox_animation,
|
||||
$img_uploaded_src,
|
||||
$img_width,
|
||||
$img_height,
|
||||
$scale_attr
|
||||
)
|
||||
);
|
||||
$w->next_tag( 'img' );
|
||||
$w->set_attribute( 'data-wp-init', 'effects.core.image.setCurrentSrc' );
|
||||
$w->set_attribute( 'data-wp-on--load', 'actions.core.image.handleLoad' );
|
||||
$w->set_attribute( 'data-wp-effect', 'effects.core.image.setButtonStyles' );
|
||||
$body_content = $w->get_updated_html();
|
||||
|
||||
// Wrap the image in the body content with a button.
|
||||
$img = null;
|
||||
preg_match( '/<img[^>]+>/', $body_content, $img );
|
||||
$button =
|
||||
'<button
|
||||
type="button"
|
||||
aria-haspopup="dialog"
|
||||
aria-label="' . esc_attr( $aria_label ) . '"
|
||||
data-wp-on--click="actions.core.image.showLightbox"
|
||||
data-wp-style--width="context.core.image.imageButtonWidth"
|
||||
data-wp-style--height="context.core.image.imageButtonHeight"
|
||||
data-wp-style--left="context.core.image.imageButtonLeft"
|
||||
data-wp-style--top="context.core.image.imageButtonTop"
|
||||
>
|
||||
</button>'
|
||||
. $img[0];
|
||||
$body_content = preg_replace( '/<img[^>]+>/', $button, $body_content );
|
||||
|
||||
// We need both a responsive image and an enlarged image to animate
|
||||
// the zoom seamlessly on slow internet connections; the responsive
|
||||
// image is a copy of the one in the body, which animates immediately
|
||||
// as the lightbox is opened, while the enlarged one is a full-sized
|
||||
// version that will likely still be loading as the animation begins.
|
||||
$m = new WP_HTML_Tag_Processor( $content );
|
||||
$m->next_tag( 'figure' );
|
||||
$m->add_class( 'responsive-image' );
|
||||
$m->next_tag( 'img' );
|
||||
// We want to set the 'src' attribute to an empty string in the responsive image
|
||||
// because otherwise, as of this writing, the wp_filter_content_tags() function in
|
||||
// WordPress will automatically add a 'srcset' attribute to the image, which will at
|
||||
// times cause the incorrectly sized image to be loaded in the lightbox on Firefox.
|
||||
// Because of this, we bind the 'src' attribute explicitly the current src to reliably
|
||||
// use the exact same image as in the content when the lightbox is first opened while
|
||||
// we wait for the larger image to load.
|
||||
$m->set_attribute( 'src', '' );
|
||||
$m->set_attribute( 'data-wp-bind--src', 'context.core.image.imageCurrentSrc' );
|
||||
$m->set_attribute( 'data-wp-style--object-fit', 'selectors.core.image.lightboxObjectFit' );
|
||||
$initial_image_content = $m->get_updated_html();
|
||||
|
||||
$q = new WP_HTML_Tag_Processor( $content );
|
||||
$q->next_tag( 'figure' );
|
||||
$q->add_class( 'enlarged-image' );
|
||||
$q->next_tag( 'img' );
|
||||
|
||||
// We set the 'src' attribute to an empty string to prevent the browser from loading the image
|
||||
// on initial page load, then bind the attribute to a selector that returns the full-sized image src when
|
||||
// the lightbox is opened. We could use 'loading=lazy' in combination with the 'hidden' attribute to
|
||||
// accomplish the same behavior, but that approach breaks progressive loading of the image in Safari
|
||||
// and Chrome (see https://github.com/WordPress/gutenberg/pull/52765#issuecomment-1674008151). Until that
|
||||
// is resolved, manually setting the 'src' seems to be the best solution to load the large image on demand.
|
||||
$q->set_attribute( 'src', '' );
|
||||
$q->set_attribute( 'data-wp-bind--src', 'selectors.core.image.enlargedImgSrc' );
|
||||
$q->set_attribute( 'data-wp-style--object-fit', 'selectors.core.image.lightboxObjectFit' );
|
||||
$enlarged_image_content = $q->get_updated_html();
|
||||
|
||||
$background_color = esc_attr( wp_get_global_styles( array( 'color', 'background' ) ) );
|
||||
|
||||
$close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
|
||||
$close_button_color = esc_attr( wp_get_global_styles( array( 'color', 'text' ) ) );
|
||||
$dialog_label = $alt_attribute ? esc_attr( $alt_attribute ) : esc_attr__( 'Image' );
|
||||
$close_button_label = esc_attr__( 'Close' );
|
||||
|
||||
$lightbox_html = <<<HTML
|
||||
<div data-wp-body="" class="wp-lightbox-overlay $lightbox_animation"
|
||||
data-wp-bind--role="selectors.core.image.roleAttribute"
|
||||
aria-label="$dialog_label"
|
||||
data-wp-class--initialized="context.core.image.initialized"
|
||||
data-wp-class--active="context.core.image.lightboxEnabled"
|
||||
data-wp-class--hideAnimationEnabled="context.core.image.hideAnimationEnabled"
|
||||
data-wp-bind--aria-hidden="!context.core.image.lightboxEnabled"
|
||||
aria-hidden="true"
|
||||
data-wp-bind--aria-modal="context.core.image.lightboxEnabled"
|
||||
aria-modal="false"
|
||||
data-wp-effect="effects.core.image.initLightbox"
|
||||
data-wp-on--keydown="actions.core.image.handleKeydown"
|
||||
data-wp-on--mousewheel="actions.core.image.hideLightbox"
|
||||
data-wp-on--click="actions.core.image.hideLightbox"
|
||||
>
|
||||
<button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button" data-wp-on--click="actions.core.image.hideLightbox">
|
||||
$close_button_icon
|
||||
</button>
|
||||
<div class="lightbox-image-container">$initial_image_content</div>
|
||||
<div class="lightbox-image-container">$enlarged_image_content</div>
|
||||
<div class="scrim" style="background-color: $background_color"></div>
|
||||
</div>
|
||||
HTML;
|
||||
|
||||
return str_replace( '</figure>', $lightbox_html . '</figure>', $body_content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the view script has the `wp-interactivity` dependency.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @global WP_Scripts $wp_scripts
|
||||
*/
|
||||
function block_core_image_ensure_interactivity_dependency() {
|
||||
global $wp_scripts;
|
||||
if (
|
||||
isset( $wp_scripts->registered['wp-block-image-view'] ) &&
|
||||
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-image-view']->deps, true )
|
||||
) {
|
||||
$wp_scripts->registered['wp-block-image-view']->deps[] = 'wp-interactivity';
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_print_scripts', 'block_core_image_ensure_interactivity_dependency' );
|
||||
|
||||
/**
|
||||
* Registers the `core/image` block on server.
|
||||
*/
|
||||
function register_block_core_image() {
|
||||
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/image',
|
||||
array(
|
||||
|
||||
@ -33,6 +33,12 @@
|
||||
"selector": "figcaption",
|
||||
"__experimentalRole": "content"
|
||||
},
|
||||
"lightbox": {
|
||||
"type": "object",
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"source": "attribute",
|
||||
@ -90,9 +96,6 @@
|
||||
},
|
||||
"supports": {
|
||||
"anchor": true,
|
||||
"behaviors": {
|
||||
"lightbox": true
|
||||
},
|
||||
"color": {
|
||||
"text": false,
|
||||
"background": false
|
||||
@ -127,5 +130,6 @@
|
||||
{ "name": "rounded", "label": "Rounded" }
|
||||
],
|
||||
"editorStyle": "wp-block-image-editor",
|
||||
"style": "wp-block-image"
|
||||
"style": "wp-block-image",
|
||||
"viewScript": "file:./view.min.js"
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$block_core_latest_posts_excerpt_length = $attributes['excerptLength'];
|
||||
add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
|
||||
|
||||
$filter_latest_posts_excerpt_more = static function( $more ) use ( $attributes ) {
|
||||
$filter_latest_posts_excerpt_more = static function ( $more ) use ( $attributes ) {
|
||||
$use_excerpt = 'excerpt' === $attributes['displayPostContentRadio'];
|
||||
/* translators: %1$s is a URL to a post, excerpt truncation character, default … */
|
||||
return $use_excerpt ? sprintf( __( ' … <a href="%1$s" rel="noopener noreferrer">Read more</a>' ), esc_url( get_permalink() ) ) : $more;
|
||||
@ -56,7 +56,7 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
|
||||
add_filter( 'excerpt_more', $filter_latest_posts_excerpt_more );
|
||||
|
||||
if ( isset( $attributes['categories'] ) ) {
|
||||
if ( ! empty( $attributes['categories'] ) ) {
|
||||
$args['category__in'] = array_column( $attributes['categories'], 'id' );
|
||||
}
|
||||
if ( isset( $attributes['selectedAuthor'] ) ) {
|
||||
|
||||
@ -69,6 +69,7 @@
|
||||
},
|
||||
"__unstablePasteTextInline": true,
|
||||
"__experimentalSelector": "ol,ul",
|
||||
"__experimentalOnMerge": true,
|
||||
"__experimentalSlashInserter": true
|
||||
},
|
||||
"editorStyle": "wp-block-list-editor",
|
||||
|
||||
@ -100,6 +100,7 @@
|
||||
"html": false,
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"heading": true,
|
||||
"link": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"background": true,
|
||||
|
||||
@ -5,16 +5,6 @@
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build an array with CSS classes and inline styles defining the colors
|
||||
* which will be applied to the navigation markup in the front-end.
|
||||
*
|
||||
* @param array $context Navigation block context.
|
||||
* @param array $attributes Block attributes.
|
||||
* @param bool $is_sub_menu Whether the block is a sub-menu.
|
||||
* @return array Colors CSS classes and inline styles.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build an array with CSS classes and inline styles defining the font sizes
|
||||
* which will be applied to the navigation markup in the front-end.
|
||||
|
||||
@ -65,87 +65,62 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
||||
|
||||
return $menu_items_by_parent_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Interactivity API directives to the navigation-submenu and page-list blocks markup using the Tag Processor
|
||||
* The final HTML of the navigation-submenu and the page-list blocks will look similar to this:
|
||||
*
|
||||
* <li
|
||||
* class="has-child"
|
||||
* data-wp-context='{ "core": { "navigation": { "isMenuOpen": false, "overlay": false } } }'
|
||||
* data-wp-effect="effects.core.navigation.initMenu"
|
||||
* data-wp-on.keydown="actions.core.navigation.handleMenuKeydown"
|
||||
* data-wp-on.focusout="actions.core.navigation.handleMenuFocusout"
|
||||
* >
|
||||
* <button
|
||||
* class="wp-block-navigation-submenu__toggle"
|
||||
* data-wp-on.click="actions.core.navigation.openMenu"
|
||||
* data-wp-bind.aria-expanded="context.core.navigation.isMenuOpen"
|
||||
* >
|
||||
* </button>
|
||||
* <span>Title</span>
|
||||
* <ul class="wp-block-navigation__submenu-container">
|
||||
* SUBMENU ITEMS
|
||||
* </ul>
|
||||
* </li>
|
||||
*
|
||||
* @param string $w Markup of the navigation block.
|
||||
* @param array $block_attributes Block attributes.
|
||||
*
|
||||
* @return string Submenu markup with the directives injected.
|
||||
*/
|
||||
function block_core_navigation_add_directives_to_submenu( $w, $block_attributes ) {
|
||||
while ( $w->next_tag(
|
||||
array(
|
||||
'tag_name' => 'LI',
|
||||
'class_name' => 'has-child',
|
||||
)
|
||||
) ) {
|
||||
// Add directives to the parent `<li>`.
|
||||
$w->set_attribute( 'data-wp-interactive', true );
|
||||
$w->set_attribute( 'data-wp-context', '{ "core": { "navigation": { "isMenuOpen": { "click": false, "hover": false }, "overlay": false } } }' );
|
||||
$w->set_attribute( 'data-wp-effect', 'effects.core.navigation.initMenu' );
|
||||
$w->set_attribute( 'data-wp-on--focusout', 'actions.core.navigation.handleMenuFocusout' );
|
||||
$w->set_attribute( 'data-wp-on--keydown', 'actions.core.navigation.handleMenuKeydown' );
|
||||
if ( ! isset( $block_attributes['openSubmenusOnClick'] ) || false === $block_attributes['openSubmenusOnClick'] ) {
|
||||
$w->set_attribute( 'data-wp-on--mouseenter', 'actions.core.navigation.openMenuOnHover' );
|
||||
$w->set_attribute( 'data-wp-on--mouseleave', 'actions.core.navigation.closeMenuOnHover' );
|
||||
}
|
||||
|
||||
// Add directives to the toggle submenu button.
|
||||
if ( $w->next_tag(
|
||||
array(
|
||||
'tag_name' => 'BUTTON',
|
||||
'class_name' => 'wp-block-navigation-submenu__toggle',
|
||||
)
|
||||
) ) {
|
||||
$w->set_attribute( 'data-wp-on--click', 'actions.core.navigation.toggleMenuOnClick' );
|
||||
$w->set_attribute( 'data-wp-bind--aria-expanded', 'selectors.core.navigation.isMenuOpen' );
|
||||
};
|
||||
|
||||
// Iterate through subitems if exist.
|
||||
block_core_navigation_add_directives_to_submenu( $w, $block_attributes );
|
||||
}
|
||||
return $w->get_updated_html();
|
||||
};
|
||||
|
||||
/**
|
||||
* Replaces view script for the Navigation block with version using Interactivity API.
|
||||
*
|
||||
* @param array $metadata Block metadata as read in via block.json.
|
||||
*
|
||||
* @return array Filtered block type metadata.
|
||||
*/
|
||||
function gutenberg_block_core_navigation_update_interactive_view_script( $metadata ) {
|
||||
if ( 'core/navigation' === $metadata['name'] ) {
|
||||
$metadata['viewScript'] = array( 'file:./interactivity.min.js' );
|
||||
}
|
||||
return $metadata;
|
||||
}
|
||||
add_filter( 'block_type_metadata', 'gutenberg_block_core_navigation_update_interactive_view_script', 10, 1 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Interactivity API directives to the navigation-submenu and page-list
|
||||
* blocks markup using the Tag Processor.
|
||||
*
|
||||
* @param string $w Markup of the navigation block.
|
||||
* @param array $block_attributes Block attributes.
|
||||
*
|
||||
* @return string Submenu markup with the directives injected.
|
||||
*/
|
||||
function block_core_navigation_add_directives_to_submenu( $w, $block_attributes ) {
|
||||
while ( $w->next_tag(
|
||||
array(
|
||||
'tag_name' => 'LI',
|
||||
'class_name' => 'has-child',
|
||||
)
|
||||
) ) {
|
||||
// Add directives to the parent `<li>`.
|
||||
$w->set_attribute( 'data-wp-interactive', true );
|
||||
$w->set_attribute( 'data-wp-context', '{ "core": { "navigation": { "submenuOpenedBy": {}, "type": "submenu" } } }' );
|
||||
$w->set_attribute( 'data-wp-effect', 'effects.core.navigation.initMenu' );
|
||||
$w->set_attribute( 'data-wp-on--focusout', 'actions.core.navigation.handleMenuFocusout' );
|
||||
$w->set_attribute( 'data-wp-on--keydown', 'actions.core.navigation.handleMenuKeydown' );
|
||||
if ( ! isset( $block_attributes['openSubmenusOnClick'] ) || false === $block_attributes['openSubmenusOnClick'] ) {
|
||||
$w->set_attribute( 'data-wp-on--mouseenter', 'actions.core.navigation.openMenuOnHover' );
|
||||
$w->set_attribute( 'data-wp-on--mouseleave', 'actions.core.navigation.closeMenuOnHover' );
|
||||
}
|
||||
|
||||
// Add directives to the toggle submenu button.
|
||||
if ( $w->next_tag(
|
||||
array(
|
||||
'tag_name' => 'BUTTON',
|
||||
'class_name' => 'wp-block-navigation-submenu__toggle',
|
||||
)
|
||||
) ) {
|
||||
$w->set_attribute( 'data-wp-on--click', 'actions.core.navigation.toggleMenuOnClick' );
|
||||
$w->set_attribute( 'data-wp-bind--aria-expanded', 'selectors.core.navigation.isMenuOpen' );
|
||||
// The `aria-expanded` attribute for SSR is already added in the submenu block.
|
||||
}
|
||||
// Add directives to the submenu.
|
||||
if ( $w->next_tag(
|
||||
array(
|
||||
'tag_name' => 'UL',
|
||||
'class_name' => 'wp-block-navigation__submenu-container',
|
||||
)
|
||||
) ) {
|
||||
$w->set_attribute( 'data-wp-on--focus', 'actions.core.navigation.openMenuOnFocus' );
|
||||
}
|
||||
|
||||
// Iterate through subitems if exist.
|
||||
block_core_navigation_add_directives_to_submenu( $w, $block_attributes );
|
||||
}
|
||||
return $w->get_updated_html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an array with CSS classes and inline styles defining the colors
|
||||
@ -276,10 +251,6 @@ function block_core_navigation_render_submenu_icon() {
|
||||
return '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Filter out empty "null" blocks from the block list.
|
||||
* 'parse_blocks' includes a null block with '\n\n' as the content when
|
||||
@ -292,7 +263,7 @@ function block_core_navigation_render_submenu_icon() {
|
||||
function block_core_navigation_filter_out_empty_blocks( $parsed_blocks ) {
|
||||
$filtered = array_filter(
|
||||
$parsed_blocks,
|
||||
static function( $block ) {
|
||||
static function ( $block ) {
|
||||
return isset( $block['blockName'] );
|
||||
}
|
||||
);
|
||||
@ -422,7 +393,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
// a fallback (i.e. the block has no menu associated with it).
|
||||
$is_fallback = false;
|
||||
|
||||
$nav_menu_name = '';
|
||||
$nav_menu_name = $attributes['ariaLabel'] ?? '';
|
||||
|
||||
/**
|
||||
* Deprecated:
|
||||
@ -558,7 +529,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
}
|
||||
|
||||
// Manually add block support text decoration as CSS class.
|
||||
$text_decoration = _wp_array_get( $attributes, array( 'style', 'typography', 'textDecoration' ), null );
|
||||
$text_decoration = $attributes['style']['typography']['textDecoration'] ?? null;
|
||||
$text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration );
|
||||
|
||||
$colors = block_core_navigation_build_css_colors( $attributes );
|
||||
@ -658,24 +629,25 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
$inner_blocks_html .= '</ul>';
|
||||
}
|
||||
|
||||
// If the script already exists, there is no point in removing it from viewScript.
|
||||
$should_load_view_script = ( $is_responsive_menu || ( $has_submenus && ( $attributes['openSubmenusOnClick'] || $attributes['showSubmenuIcon'] ) ) );
|
||||
$should_load_view_script = ( $has_submenus && ( $attributes['openSubmenusOnClick'] || $attributes['showSubmenuIcon'] ) ) || $is_responsive_menu;
|
||||
$view_js_file = 'wp-block-navigation-view';
|
||||
|
||||
// If the script already exists, there is no point in removing it from viewScript.
|
||||
if ( ! wp_script_is( $view_js_file ) ) {
|
||||
$script_handles = $block->block_type->view_script_handles;
|
||||
|
||||
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
||||
if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
|
||||
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file, 'wp-block-navigation-view-2' ) );
|
||||
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
||||
}
|
||||
// If the script is needed, but it was previously removed, add it again.
|
||||
if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
|
||||
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file, 'wp-block-navigation-view-2' ) );
|
||||
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Add directives to the submenu if needed.
|
||||
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $has_submenus && $should_load_view_script ) {
|
||||
if ( $has_submenus && $should_load_view_script ) {
|
||||
$w = new WP_HTML_Tag_Processor( $inner_blocks_html );
|
||||
$inner_blocks_html = block_core_navigation_add_directives_to_submenu( $w, $attributes );
|
||||
}
|
||||
@ -723,10 +695,10 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
$responsive_container_directives = '';
|
||||
$responsive_dialog_directives = '';
|
||||
$close_button_directives = '';
|
||||
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $should_load_view_script ) {
|
||||
if ( $should_load_view_script ) {
|
||||
$nav_element_directives = '
|
||||
data-wp-interactive
|
||||
data-wp-context=\'{ "core": { "navigation": { "isMenuOpen": { "click": false, "hover": false }, "overlay": true, "roleAttribute": "" } } }\'
|
||||
data-wp-context=\'{ "core": { "navigation": { "overlayOpenedBy": {}, "type": "overlay", "roleAttribute": "" } } }\'
|
||||
';
|
||||
$open_button_directives = '
|
||||
data-wp-on--click="actions.core.navigation.openMenuOnClick"
|
||||
@ -741,7 +713,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
tabindex="-1"
|
||||
';
|
||||
$responsive_dialog_directives = '
|
||||
data-wp-bind--aria-modal="selectors.core.navigation.isMenuOpen"
|
||||
data-wp-bind--aria-modal="selectors.core.navigation.ariaModal"
|
||||
data-wp-bind--role="selectors.core.navigation.roleAttribute"
|
||||
data-wp-effect="effects.core.navigation.focusFirstElement"
|
||||
';
|
||||
@ -751,11 +723,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
}
|
||||
|
||||
$responsive_container_markup = sprintf(
|
||||
'<button aria-haspopup="true" %3$s class="%6$s" data-micromodal-trigger="%1$s" %11$s>%9$s</button>
|
||||
'<button aria-haspopup="true" %3$s class="%6$s" %11$s>%9$s</button>
|
||||
<div class="%5$s" style="%7$s" id="%1$s" %12$s>
|
||||
<div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
|
||||
<div class="wp-block-navigation__responsive-close" tabindex="-1">
|
||||
<div class="wp-block-navigation__responsive-dialog" aria-label="%8$s" %13$s>
|
||||
<button %4$s data-micromodal-close class="wp-block-navigation__responsive-container-close" %14$s>%10$s</button>
|
||||
<button %4$s class="wp-block-navigation__responsive-container-close" %14$s>%10$s</button>
|
||||
<div class="wp-block-navigation__responsive-container-content" id="%1$s-content">
|
||||
%2$s
|
||||
</div>
|
||||
@ -837,6 +809,25 @@ function block_core_navigation_typographic_presets_backcompatibility( $parsed_bl
|
||||
|
||||
add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_backcompatibility' );
|
||||
|
||||
/**
|
||||
* Ensure that the view script has the `wp-interactivity` dependency.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @global WP_Scripts $wp_scripts
|
||||
*/
|
||||
function block_core_navigation_ensure_interactivity_dependency() {
|
||||
global $wp_scripts;
|
||||
if (
|
||||
isset( $wp_scripts->registered['wp-block-navigation-view'] ) &&
|
||||
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-navigation-view']->deps, true )
|
||||
) {
|
||||
$wp_scripts->registered['wp-block-navigation-view']->deps[] = 'wp-interactivity';
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_print_scripts', 'block_core_navigation_ensure_interactivity_dependency' );
|
||||
|
||||
/**
|
||||
* Turns menu item data into a nested array of parsed blocks
|
||||
*
|
||||
@ -930,7 +921,7 @@ function block_core_navigation_get_classic_menu_fallback() {
|
||||
// Otherwise return the most recently created classic menu.
|
||||
usort(
|
||||
$classic_nav_menus,
|
||||
static function( $a, $b ) {
|
||||
static function ( $a, $b ) {
|
||||
return $b->term_id - $a->term_id;
|
||||
}
|
||||
);
|
||||
|
||||
@ -91,6 +91,7 @@
|
||||
},
|
||||
"supports": {
|
||||
"align": [ "wide", "full" ],
|
||||
"ariaLabel": true,
|
||||
"html": false,
|
||||
"inserter": true,
|
||||
"typography": {
|
||||
@ -131,9 +132,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"interactivity": true
|
||||
},
|
||||
"viewScript": [ "file:./view.min.js", "file:./view-modal.min.js" ],
|
||||
"viewScript": "file:./view.min.js",
|
||||
"editorStyle": "wp-block-navigation-editor",
|
||||
"style": "wp-block-navigation"
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => 'e0302ba06467706c7421');
|
||||
<?php return array('dependencies' => array(), 'version' => 'fa68a54f17d2cf6a40e0');
|
||||
|
||||
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '886680af40b7521d60fc');
|
||||
<?php return array('dependencies' => array(), 'version' => '3d8680462ad916d46a80');
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
"description": "Start with the basic building block of all narrative.",
|
||||
"keywords": [ "text" ],
|
||||
"textdomain": "default",
|
||||
"usesContext": [ "postId" ],
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string"
|
||||
@ -41,6 +42,7 @@
|
||||
"text": true
|
||||
}
|
||||
},
|
||||
"__experimentalConnections": true,
|
||||
"spacing": {
|
||||
"margin": true,
|
||||
"padding": true,
|
||||
@ -58,6 +60,7 @@
|
||||
"__experimentalFontWeight": true,
|
||||
"__experimentalLetterSpacing": true,
|
||||
"__experimentalTextTransform": true,
|
||||
"__experimentalWritingMode": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"fontSize": true
|
||||
}
|
||||
|
||||
@ -41,7 +41,17 @@ function render_block_core_pattern( $attributes ) {
|
||||
}
|
||||
|
||||
$pattern = $registry->get_registered( $slug );
|
||||
return do_blocks( $pattern['content'] );
|
||||
$content = $pattern['content'];
|
||||
|
||||
// Backward compatibility for handling Block Hooks and injecting the theme attribute in the Gutenberg plugin.
|
||||
// This can be removed when the minimum supported WordPress is >= 6.4.
|
||||
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && ! function_exists( 'traverse_and_serialize_blocks' ) ) {
|
||||
$content = _inject_theme_attribute_in_block_template_content( $content );
|
||||
$blocks = parse_blocks( $content );
|
||||
$content = gutenberg_serialize_blocks( $blocks );
|
||||
}
|
||||
|
||||
return do_blocks( $content );
|
||||
}
|
||||
|
||||
add_action( 'init', 'register_block_core_pattern' );
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "core/post-author-biography",
|
||||
"title": "Post Author Biography",
|
||||
"title": "Author Biography",
|
||||
"category": "theme",
|
||||
"description": "The author biography.",
|
||||
"textdomain": "default",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "core/post-author-name",
|
||||
"title": "Post Author Name",
|
||||
"title": "Author Name",
|
||||
"category": "theme",
|
||||
"description": "The author name.",
|
||||
"textdomain": "default",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "core/post-author",
|
||||
"title": "Post Author",
|
||||
"title": "Author",
|
||||
"category": "theme",
|
||||
"description": "Display post author details such as name, avatar, and bio.",
|
||||
"textdomain": "default",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "core/post-comments-form",
|
||||
"title": "Post Comments Form",
|
||||
"title": "Comments Form",
|
||||
"category": "theme",
|
||||
"description": "Display a post's comments form.",
|
||||
"textdomain": "default",
|
||||
@ -16,6 +16,7 @@
|
||||
"html": false,
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"heading": true,
|
||||
"link": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"background": true,
|
||||
|
||||
@ -35,12 +35,6 @@ function render_block_core_post_content( $attributes, $content, $block ) {
|
||||
|
||||
$seen_ids[ $post_id ] = true;
|
||||
|
||||
// Check is needed for backward compatibility with third-party plugins
|
||||
// that might rely on the `in_the_loop` check; calling `the_post` sets it to true.
|
||||
if ( ! in_the_loop() && have_posts() ) {
|
||||
the_post();
|
||||
}
|
||||
|
||||
// When inside the main loop, we want to use queried object
|
||||
// so that `the_preview` for the current post can apply.
|
||||
// We force this behavior by omitting the third argument (post ID) from the `get_the_content`.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "core/post-content",
|
||||
"title": "Post Content",
|
||||
"title": "Content",
|
||||
"category": "theme",
|
||||
"description": "Displays the contents of a post or page.",
|
||||
"textdomain": "default",
|
||||
@ -14,6 +14,17 @@
|
||||
"dimensions": {
|
||||
"minHeight": true
|
||||
},
|
||||
"spacing": {
|
||||
"blockGap": true
|
||||
},
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"link": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"background": false,
|
||||
"text": false
|
||||
}
|
||||
},
|
||||
"typography": {
|
||||
"fontSize": true,
|
||||
"lineHeight": true,
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "core/post-date",
|
||||
"title": "Post Date",
|
||||
"title": "Date",
|
||||
"category": "theme",
|
||||
"description": "Add the date of this post.",
|
||||
"description": "Display the publish date for an entry such as a post or page.",
|
||||
"textdomain": "default",
|
||||
"attributes": {
|
||||
"textAlign": {
|
||||
|
||||
@ -31,7 +31,7 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
|
||||
}
|
||||
|
||||
$more_text = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : '';
|
||||
$filter_excerpt_more = static function( $more ) use ( $more_text ) {
|
||||
$filter_excerpt_more = static function ( $more ) use ( $more_text ) {
|
||||
return empty( $more_text ) ? $more : '';
|
||||
};
|
||||
/**
|
||||
@ -87,7 +87,7 @@ if ( is_admin() ||
|
||||
defined( 'REST_REQUEST' ) && REST_REQUEST ) {
|
||||
add_filter(
|
||||
'excerpt_length',
|
||||
static function() {
|
||||
static function () {
|
||||
return 100;
|
||||
},
|
||||
PHP_INT_MAX
|
||||
|
||||
@ -19,12 +19,6 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
|
||||
}
|
||||
$post_ID = $block->context['postId'];
|
||||
|
||||
// Check is needed for backward compatibility with third-party plugins
|
||||
// that might rely on the `in_the_loop` check; calling `the_post` sets it to true.
|
||||
if ( ! in_the_loop() && have_posts() ) {
|
||||
the_post();
|
||||
}
|
||||
|
||||
$is_link = isset( $attributes['isLink'] ) && $attributes['isLink'];
|
||||
$size_slug = isset( $attributes['sizeSlug'] ) ? $attributes['sizeSlug'] : 'post-thumbnail';
|
||||
$attr = get_block_core_post_featured_image_border_attributes( $attributes );
|
||||
@ -190,12 +184,12 @@ function get_block_core_post_featured_image_border_attributes( $attributes ) {
|
||||
|
||||
// Border color.
|
||||
$preset_color = array_key_exists( 'borderColor', $attributes ) ? "var:preset|color|{$attributes['borderColor']}" : null;
|
||||
$custom_color = _wp_array_get( $attributes, array( 'style', 'border', 'color' ), null );
|
||||
$custom_color = $attributes['style']['border']['color'] ?? null;
|
||||
$border_styles['color'] = $preset_color ? $preset_color : $custom_color;
|
||||
|
||||
// Individual border styles e.g. top, left etc.
|
||||
foreach ( $sides as $side ) {
|
||||
$border = _wp_array_get( $attributes, array( 'style', 'border', $side ), null );
|
||||
$border = $attributes['style']['border'][ $side ] ?? null;
|
||||
$border_styles[ $side ] = array(
|
||||
'color' => isset( $border['color'] ) ? $border['color'] : null,
|
||||
'style' => isset( $border['style'] ) ? $border['style'] : null,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "core/post-featured-image",
|
||||
"title": "Post Featured Image",
|
||||
"title": "Featured Image",
|
||||
"category": "theme",
|
||||
"description": "Display a post's featured image.",
|
||||
"textdomain": "default",
|
||||
|
||||
@ -28,7 +28,11 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
|
||||
if ( isset( $attributes['textAlign'] ) ) {
|
||||
$classes .= " has-text-align-{$attributes['textAlign']}";
|
||||
}
|
||||
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
||||
$wrapper_attributes = get_block_wrapper_attributes(
|
||||
array(
|
||||
'class' => $classes,
|
||||
)
|
||||
);
|
||||
// Set default values.
|
||||
$format = '%link';
|
||||
$link = 'next' === $navigation_type ? _x( 'Next', 'label for next post link' ) : _x( 'Previous', 'label for previous post link' );
|
||||
@ -88,9 +92,9 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
|
||||
$arrow = $arrow_map[ $attributes['arrow'] ][ $navigation_type ];
|
||||
|
||||
if ( 'next' === $navigation_type ) {
|
||||
$format = '%link <span class="wp-block-post-navigation-link__arrow-next is-arrow-' . $attributes['arrow'] . '" aria-hidden="true">' . $arrow . '</span>';
|
||||
$format = '%link<span class="wp-block-post-navigation-link__arrow-next is-arrow-' . $attributes['arrow'] . '" aria-hidden="true">' . $arrow . '</span>';
|
||||
} else {
|
||||
$format = '<span class="wp-block-post-navigation-link__arrow-previous is-arrow-' . $attributes['arrow'] . '" aria-hidden="true">' . $arrow . '</span> %link';
|
||||
$format = '<span class="wp-block-post-navigation-link__arrow-previous is-arrow-' . $attributes['arrow'] . '" aria-hidden="true">' . $arrow . '</span>%link';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
"__experimentalTextTransform": true,
|
||||
"__experimentalTextDecoration": true,
|
||||
"__experimentalLetterSpacing": true,
|
||||
"__experimentalWritingMode": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"fontSize": true
|
||||
}
|
||||
|
||||
@ -43,14 +43,26 @@ function block_core_post_template_uses_featured_image( $inner_blocks ) {
|
||||
* @return string Returns the output of the query, structured using the layout defined by the block's inner blocks.
|
||||
*/
|
||||
function render_block_core_post_template( $attributes, $content, $block ) {
|
||||
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
||||
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
||||
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
||||
$enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination'];
|
||||
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
||||
|
||||
// Use global query if needed.
|
||||
$use_global_query = ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] );
|
||||
if ( $use_global_query ) {
|
||||
global $wp_query;
|
||||
$query = clone $wp_query;
|
||||
|
||||
/*
|
||||
* If already in the main query loop, duplicate the query instance to not tamper with the main instance.
|
||||
* Since this is a nested query, it should start at the beginning, therefore rewind posts.
|
||||
* Otherwise, the main query loop has not started yet and this block is responsible for doing so.
|
||||
*/
|
||||
if ( in_the_loop() ) {
|
||||
$query = clone $wp_query;
|
||||
$query->rewind_posts();
|
||||
} else {
|
||||
$query = $wp_query;
|
||||
}
|
||||
} else {
|
||||
$query_args = build_query_vars_from_query_block( $block, $page );
|
||||
$query = new WP_Query( $query_args );
|
||||
@ -94,7 +106,7 @@ function render_block_core_post_template( $attributes, $content, $block ) {
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$post_type = get_post_type();
|
||||
$filter_block_context = static function( $context ) use ( $post_id, $post_type ) {
|
||||
$filter_block_context = static function ( $context ) use ( $post_id, $post_type ) {
|
||||
$context['postType'] = $post_type;
|
||||
$context['postId'] = $post_id;
|
||||
return $context;
|
||||
@ -109,7 +121,10 @@ function render_block_core_post_template( $attributes, $content, $block ) {
|
||||
|
||||
// Wrap the render inner blocks in a `li` element with the appropriate post classes.
|
||||
$post_classes = implode( ' ', get_post_class( 'wp-block-post' ) );
|
||||
$content .= '<li class="' . esc_attr( $post_classes ) . '">' . $block_content . '</li>';
|
||||
|
||||
$inner_block_directives = $enhanced_pagination ? ' data-wp-key="post-template-item-' . $post_id . '"' : '';
|
||||
|
||||
$content .= '<li' . $inner_block_directives . ' class="' . esc_attr( $post_classes ) . '">' . $block_content . '</li>';
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
"queryContext",
|
||||
"displayLayout",
|
||||
"templateSlug",
|
||||
"previewPostType"
|
||||
"previewPostType",
|
||||
"enhancedPagination"
|
||||
],
|
||||
"supports": {
|
||||
"reusable": false,
|
||||
|
||||
@ -81,8 +81,11 @@ function register_block_core_post_terms() {
|
||||
$variation = array(
|
||||
'name' => $taxonomy->name,
|
||||
'title' => $taxonomy->label,
|
||||
/* translators: %s: taxonomy's label */
|
||||
'description' => sprintf( __( 'Display the assigned taxonomy: %s' ), $taxonomy->label ),
|
||||
'description' => sprintf(
|
||||
/* translators: %s: taxonomy's label */
|
||||
__( 'Display a list of assigned terms from the taxonomy: %s' ),
|
||||
$taxonomy->label
|
||||
),
|
||||
'attributes' => array(
|
||||
'term' => $taxonomy->name,
|
||||
),
|
||||
|
||||
@ -25,6 +25,10 @@
|
||||
"text": true
|
||||
}
|
||||
},
|
||||
"spacing": {
|
||||
"padding": true,
|
||||
"margin": true
|
||||
},
|
||||
"typography": {
|
||||
"fontSize": true,
|
||||
"lineHeight": true,
|
||||
|
||||
@ -32,14 +32,10 @@ function render_block_core_query_no_results( $attributes, $content, $block ) {
|
||||
$query = new WP_Query( $query_args );
|
||||
}
|
||||
|
||||
if ( $query->have_posts() ) {
|
||||
if ( $query->post_count > 0 ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ! $use_global_query ) {
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
$classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';
|
||||
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
||||
return sprintf(
|
||||
|
||||
@ -15,9 +15,10 @@
|
||||
* @return string Returns the next posts link for the query pagination.
|
||||
*/
|
||||
function render_block_core_query_pagination_next( $attributes, $content, $block ) {
|
||||
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
||||
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
||||
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
|
||||
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
||||
$enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination'];
|
||||
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
||||
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
|
||||
|
||||
$wrapper_attributes = get_block_wrapper_attributes();
|
||||
$show_label = isset( $block->context['showLabel'] ) ? (bool) $block->context['showLabel'] : true;
|
||||
@ -36,7 +37,7 @@ function render_block_core_query_pagination_next( $attributes, $content, $block
|
||||
|
||||
// Check if the pagination is for Query that inherits the global context.
|
||||
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
|
||||
$filter_link_attributes = static function() use ( $wrapper_attributes ) {
|
||||
$filter_link_attributes = static function () use ( $wrapper_attributes ) {
|
||||
return $wrapper_attributes;
|
||||
};
|
||||
add_filter( 'next_posts_link_attributes', $filter_link_attributes );
|
||||
@ -61,6 +62,23 @@ function render_block_core_query_pagination_next( $attributes, $content, $block
|
||||
}
|
||||
wp_reset_postdata(); // Restore original Post Data.
|
||||
}
|
||||
|
||||
if ( $enhanced_pagination ) {
|
||||
$p = new WP_HTML_Tag_Processor( $content );
|
||||
if ( $p->next_tag(
|
||||
array(
|
||||
'tag_name' => 'a',
|
||||
'class_name' => 'wp-block-query-pagination-next',
|
||||
)
|
||||
) ) {
|
||||
$p->set_attribute( 'data-wp-key', 'query-pagination-next' );
|
||||
$p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' );
|
||||
$p->set_attribute( 'data-wp-on--mouseenter', 'actions.core.query.prefetch' );
|
||||
$p->set_attribute( 'data-wp-effect', 'effects.core.query.prefetch' );
|
||||
$content = $p->get_updated_html();
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,13 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"usesContext": [ "queryId", "query", "paginationArrow", "showLabel" ],
|
||||
"usesContext": [
|
||||
"queryId",
|
||||
"query",
|
||||
"paginationArrow",
|
||||
"showLabel",
|
||||
"enhancedPagination"
|
||||
],
|
||||
"supports": {
|
||||
"reusable": false,
|
||||
"html": false,
|
||||
|
||||
@ -15,13 +15,15 @@
|
||||
* @return string Returns the pagination numbers for the Query.
|
||||
*/
|
||||
function render_block_core_query_pagination_numbers( $attributes, $content, $block ) {
|
||||
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
||||
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
||||
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
|
||||
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
||||
$enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination'];
|
||||
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
||||
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
|
||||
|
||||
$wrapper_attributes = get_block_wrapper_attributes();
|
||||
$content = '';
|
||||
global $wp_query;
|
||||
$mid_size = isset( $block->attributes['midSize'] ) ? (int) $block->attributes['midSize'] : null;
|
||||
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
|
||||
// Take into account if we have set a bigger `max page`
|
||||
// than what the query has.
|
||||
@ -30,7 +32,10 @@ function render_block_core_query_pagination_numbers( $attributes, $content, $blo
|
||||
'prev_next' => false,
|
||||
'total' => $total,
|
||||
);
|
||||
$content = paginate_links( $paginate_args );
|
||||
if ( null !== $mid_size ) {
|
||||
$paginate_args['mid_size'] = $mid_size;
|
||||
}
|
||||
$content = paginate_links( $paginate_args );
|
||||
} else {
|
||||
$block_query = new WP_Query( build_query_vars_from_query_block( $block, $page ) );
|
||||
// `paginate_links` works with the global $wp_query, so we have to
|
||||
@ -45,6 +50,9 @@ function render_block_core_query_pagination_numbers( $attributes, $content, $blo
|
||||
'total' => $total,
|
||||
'prev_next' => false,
|
||||
);
|
||||
if ( null !== $mid_size ) {
|
||||
$paginate_args['mid_size'] = $mid_size;
|
||||
}
|
||||
if ( 1 !== $page ) {
|
||||
/**
|
||||
* `paginate_links` doesn't use the provided `format` when the page is `1`.
|
||||
@ -77,9 +85,24 @@ function render_block_core_query_pagination_numbers( $attributes, $content, $blo
|
||||
wp_reset_postdata(); // Restore original Post Data.
|
||||
$wp_query = $prev_wp_query;
|
||||
}
|
||||
|
||||
if ( empty( $content ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( $enhanced_pagination ) {
|
||||
$p = new WP_HTML_Tag_Processor( $content );
|
||||
while ( $p->next_tag(
|
||||
array(
|
||||
'tag_name' => 'a',
|
||||
'class_name' => 'page-numbers',
|
||||
)
|
||||
) ) {
|
||||
$p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' );
|
||||
}
|
||||
$content = $p->get_updated_html();
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<div %1$s>%2$s</div>',
|
||||
$wrapper_attributes,
|
||||
|
||||
@ -7,7 +7,13 @@
|
||||
"parent": [ "core/query-pagination" ],
|
||||
"description": "Displays a list of page numbers for pagination",
|
||||
"textdomain": "default",
|
||||
"usesContext": [ "queryId", "query" ],
|
||||
"attributes": {
|
||||
"midSize": {
|
||||
"type": "number",
|
||||
"default": 2
|
||||
}
|
||||
},
|
||||
"usesContext": [ "queryId", "query", "enhancedPagination" ],
|
||||
"supports": {
|
||||
"reusable": false,
|
||||
"html": false,
|
||||
|
||||
@ -15,8 +15,9 @@
|
||||
* @return string Returns the previous posts link for the query.
|
||||
*/
|
||||
function render_block_core_query_pagination_previous( $attributes, $content, $block ) {
|
||||
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
||||
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
||||
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
||||
$enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination'];
|
||||
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
||||
|
||||
$wrapper_attributes = get_block_wrapper_attributes();
|
||||
$show_label = isset( $block->context['showLabel'] ) ? (bool) $block->context['showLabel'] : true;
|
||||
@ -34,7 +35,7 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl
|
||||
// Check if the pagination is for Query that inherits the global context
|
||||
// and handle appropriately.
|
||||
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
|
||||
$filter_link_attributes = static function() use ( $wrapper_attributes ) {
|
||||
$filter_link_attributes = static function () use ( $wrapper_attributes ) {
|
||||
return $wrapper_attributes;
|
||||
};
|
||||
|
||||
@ -49,6 +50,23 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl
|
||||
$label
|
||||
);
|
||||
}
|
||||
|
||||
if ( $enhanced_pagination ) {
|
||||
$p = new WP_HTML_Tag_Processor( $content );
|
||||
if ( $p->next_tag(
|
||||
array(
|
||||
'tag_name' => 'a',
|
||||
'class_name' => 'wp-block-query-pagination-previous',
|
||||
)
|
||||
) ) {
|
||||
$p->set_attribute( 'data-wp-key', 'query-pagination-previous' );
|
||||
$p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' );
|
||||
$p->set_attribute( 'data-wp-on--mouseenter', 'actions.core.query.prefetch' );
|
||||
$p->set_attribute( 'data-wp-effect', 'effects.core.query.prefetch' );
|
||||
$content = $p->get_updated_html();
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,13 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"usesContext": [ "queryId", "query", "paginationArrow", "showLabel" ],
|
||||
"usesContext": [
|
||||
"queryId",
|
||||
"query",
|
||||
"paginationArrow",
|
||||
"showLabel",
|
||||
"enhancedPagination"
|
||||
],
|
||||
"supports": {
|
||||
"reusable": false,
|
||||
"html": false,
|
||||
|
||||
@ -5,12 +5,120 @@
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Modifies the static `core/query` block on the server.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @param array $attributes Block attributes.
|
||||
* @param string $content Block default content.
|
||||
* @param string $block Block instance.
|
||||
*
|
||||
* @return string Returns the modified output of the query block.
|
||||
*/
|
||||
function render_block_core_query( $attributes, $content, $block ) {
|
||||
if ( $attributes['enhancedPagination'] ) {
|
||||
$p = new WP_HTML_Tag_Processor( $content );
|
||||
if ( $p->next_tag() ) {
|
||||
// Add the necessary directives.
|
||||
$p->set_attribute( 'data-wp-interactive', true );
|
||||
$p->set_attribute( 'data-wp-navigation-id', 'query-' . $attributes['queryId'] );
|
||||
// Use context to send translated strings.
|
||||
$p->set_attribute(
|
||||
'data-wp-context',
|
||||
wp_json_encode(
|
||||
array(
|
||||
'core' => array(
|
||||
'query' => array(
|
||||
'loadingText' => __( 'Loading page, please wait.' ),
|
||||
'loadedText' => __( 'Page Loaded.' ),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
$content = $p->get_updated_html();
|
||||
|
||||
// Mark the block as interactive.
|
||||
$block->block_type->supports['interactivity'] = true;
|
||||
|
||||
// Add a div to announce messages using `aria-live`.
|
||||
$last_div_position = strripos( $content, '</div>' );
|
||||
$content = substr_replace(
|
||||
$content,
|
||||
'<div
|
||||
class="wp-block-query__enhanced-pagination-navigation-announce"
|
||||
aria-live="polite"
|
||||
data-wp-text="context.core.query.message"
|
||||
></div>
|
||||
<div
|
||||
class="wp-block-query__enhanced-pagination-animation"
|
||||
data-wp-class--start-animation="selectors.core.query.startAnimation"
|
||||
data-wp-class--finish-animation="selectors.core.query.finishAnimation"
|
||||
></div>',
|
||||
$last_div_position,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$view_asset = 'wp-block-query-view';
|
||||
if ( ! wp_script_is( $view_asset ) ) {
|
||||
$script_handles = $block->block_type->view_script_handles;
|
||||
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
||||
if ( ! $attributes['enhancedPagination'] && in_array( $view_asset, $script_handles, true ) ) {
|
||||
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_asset ) );
|
||||
}
|
||||
// If the script is needed, but it was previously removed, add it again.
|
||||
if ( $attributes['enhancedPagination'] && ! in_array( $view_asset, $script_handles, true ) ) {
|
||||
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_asset ) );
|
||||
}
|
||||
}
|
||||
|
||||
$style_asset = 'wp-block-query';
|
||||
if ( ! wp_style_is( $style_asset ) ) {
|
||||
$style_handles = $block->block_type->style_handles;
|
||||
// If the styles are not needed, and they are still in the `style_handles`, remove them.
|
||||
if ( ! $attributes['enhancedPagination'] && in_array( $style_asset, $style_handles, true ) ) {
|
||||
$block->block_type->style_handles = array_diff( $style_handles, array( $style_asset ) );
|
||||
}
|
||||
// If the styles are needed, but they were previously removed, add them again.
|
||||
if ( $attributes['enhancedPagination'] && ! in_array( $style_asset, $style_handles, true ) ) {
|
||||
$block->block_type->style_handles = array_merge( $style_handles, array( $style_asset ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the view script has the `wp-interactivity` dependency.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @global WP_Scripts $wp_scripts
|
||||
*/
|
||||
function block_core_query_ensure_interactivity_dependency() {
|
||||
global $wp_scripts;
|
||||
if (
|
||||
isset( $wp_scripts->registered['wp-block-query-view'] ) &&
|
||||
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-query-view']->deps, true )
|
||||
) {
|
||||
$wp_scripts->registered['wp-block-query-view']->deps[] = 'wp-interactivity';
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_print_scripts', 'block_core_query_ensure_interactivity_dependency' );
|
||||
|
||||
/**
|
||||
* Registers the `core/query` block on the server.
|
||||
*/
|
||||
function register_block_core_query() {
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/query'
|
||||
__DIR__ . '/query',
|
||||
array(
|
||||
'render_callback' => 'render_block_core_query',
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'init', 'register_block_core_query' );
|
||||
|
||||
@ -34,17 +34,24 @@
|
||||
},
|
||||
"namespace": {
|
||||
"type": "string"
|
||||
},
|
||||
"enhancedPagination": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"providesContext": {
|
||||
"queryId": "queryId",
|
||||
"query": "query",
|
||||
"displayLayout": "displayLayout"
|
||||
"displayLayout": "displayLayout",
|
||||
"enhancedPagination": "enhancedPagination"
|
||||
},
|
||||
"supports": {
|
||||
"align": [ "wide", "full" ],
|
||||
"html": false,
|
||||
"layout": true
|
||||
},
|
||||
"editorStyle": "wp-block-query-editor"
|
||||
"editorStyle": "wp-block-query-editor",
|
||||
"style": "wp-block-query",
|
||||
"viewScript": "file:./view.min.js"
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
"anchor": true,
|
||||
"html": false,
|
||||
"__experimentalOnEnter": true,
|
||||
"__experimentalOnMerge": true,
|
||||
"typography": {
|
||||
"fontSize": true,
|
||||
"lineHeight": true,
|
||||
@ -47,6 +48,7 @@
|
||||
},
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"heading": true,
|
||||
"link": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"background": true,
|
||||
|
||||
@ -64,4 +64,3 @@ require_once ABSPATH . WPINC . '/blocks/site-title.php';
|
||||
require_once ABSPATH . WPINC . '/blocks/social-link.php';
|
||||
require_once ABSPATH . WPINC . '/blocks/tag-cloud.php';
|
||||
require_once ABSPATH . WPINC . '/blocks/template-part.php';
|
||||
require_once ABSPATH . WPINC . '/blocks/term-description.php';
|
||||
|
||||
@ -46,6 +46,9 @@ function render_block_core_search( $attributes, $content, $block ) {
|
||||
'button-inside' === $attributes['buttonPosition'];
|
||||
// Border color classes need to be applied to the elements that have a border color.
|
||||
$border_color_classes = get_border_color_classes_for_block_core_search( $attributes );
|
||||
// This variable is a constant and its value is always false at this moment.
|
||||
// It is defined this way because some values depend on it, in case it changes in the future.
|
||||
$open_by_default = 'false';
|
||||
|
||||
$label_inner_html = empty( $attributes['label'] ) ? __( 'Search' ) : wp_kses_post( $attributes['label'] );
|
||||
$label = new WP_HTML_Tag_Processor( sprintf( '<label %1$s>%2$s</label>', $inline_styles['label'], $label_inner_html ) );
|
||||
@ -77,6 +80,9 @@ function render_block_core_search( $attributes, $content, $block ) {
|
||||
|
||||
$is_expandable_searchfield = 'button-only' === $button_position && 'expand-searchfield' === $button_behavior;
|
||||
if ( $is_expandable_searchfield ) {
|
||||
$input->set_attribute( 'data-wp-bind--aria-hidden', '!context.core.search.isSearchInputVisible' );
|
||||
$input->set_attribute( 'data-wp-bind--tabindex', 'selectors.core.search.tabindex' );
|
||||
// Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
|
||||
$input->set_attribute( 'aria-hidden', 'true' );
|
||||
$input->set_attribute( 'tabindex', '-1' );
|
||||
}
|
||||
@ -139,9 +145,16 @@ function render_block_core_search( $attributes, $content, $block ) {
|
||||
if ( $button->next_tag() ) {
|
||||
$button->add_class( implode( ' ', $button_classes ) );
|
||||
if ( 'expand-searchfield' === $attributes['buttonBehavior'] && 'button-only' === $attributes['buttonPosition'] ) {
|
||||
$button->set_attribute( 'data-wp-bind--aria-label', 'selectors.core.search.ariaLabel' );
|
||||
$button->set_attribute( 'data-wp-bind--aria-controls', 'selectors.core.search.ariaControls' );
|
||||
$button->set_attribute( 'data-wp-bind--aria-expanded', 'context.core.search.isSearchInputVisible' );
|
||||
$button->set_attribute( 'data-wp-bind--type', 'selectors.core.search.type' );
|
||||
$button->set_attribute( 'data-wp-on--click', 'actions.core.search.openSearchInput' );
|
||||
// Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
|
||||
$button->set_attribute( 'aria-label', __( 'Expand search field' ) );
|
||||
$button->set_attribute( 'aria-controls', 'wp-block-search__input-' . $input_id );
|
||||
$button->set_attribute( 'aria-expanded', 'false' );
|
||||
$button->set_attribute( 'type', 'button' );
|
||||
} else {
|
||||
$button->set_attribute( 'aria-label', wp_strip_all_tags( $attributes['buttonText'] ) );
|
||||
}
|
||||
@ -158,11 +171,24 @@ function render_block_core_search( $attributes, $content, $block ) {
|
||||
$wrapper_attributes = get_block_wrapper_attributes(
|
||||
array( 'class' => $classnames )
|
||||
);
|
||||
$form_directives = '';
|
||||
if ( $is_expandable_searchfield ) {
|
||||
$aria_label_expanded = __( 'Submit Search' );
|
||||
$aria_label_collapsed = __( 'Expand search field' );
|
||||
$form_directives = '
|
||||
data-wp-interactive
|
||||
data-wp-context=\'{ "core": { "search": { "isSearchInputVisible": ' . $open_by_default . ', "inputId": "' . $input_id . '", "ariaLabelExpanded": "' . $aria_label_expanded . '", "ariaLabelCollapsed": "' . $aria_label_collapsed . '" } } }\'
|
||||
data-wp-class--wp-block-search__searchfield-hidden="!context.core.search.isSearchInputVisible"
|
||||
data-wp-on--keydown="actions.core.search.handleSearchKeydown"
|
||||
data-wp-on--focusout="actions.core.search.handleSearchFocusout"
|
||||
';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<form role="search" method="get" action="%s" %s>%s</form>',
|
||||
'<form role="search" method="get" action="%1s" %2s %3s>%4s</form>',
|
||||
esc_url( home_url( '/' ) ),
|
||||
$wrapper_attributes,
|
||||
$form_directives,
|
||||
$label . $field_markup
|
||||
);
|
||||
}
|
||||
@ -180,6 +206,25 @@ function register_block_core_search() {
|
||||
}
|
||||
add_action( 'init', 'register_block_core_search' );
|
||||
|
||||
/**
|
||||
* Ensure that the view script has the `wp-interactivity` dependency.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @global WP_Scripts $wp_scripts
|
||||
*/
|
||||
function block_core_search_ensure_interactivity_dependency() {
|
||||
global $wp_scripts;
|
||||
if (
|
||||
isset( $wp_scripts->registered['wp-block-search-view'] ) &&
|
||||
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-search-view']->deps, true )
|
||||
) {
|
||||
$wp_scripts->registered['wp-block-search-view']->deps[] = 'wp-interactivity';
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_print_scripts', 'block_core_search_ensure_interactivity_dependency' );
|
||||
|
||||
/**
|
||||
* Builds the correct top level classnames for the 'core/search' block.
|
||||
*
|
||||
@ -240,7 +285,7 @@ function classnames_for_block_core_search( $attributes ) {
|
||||
* @return void
|
||||
*/
|
||||
function apply_block_core_search_border_style( $attributes, $property, $side, &$wrapper_styles, &$button_styles, &$input_styles ) {
|
||||
$is_button_inside = 'button-inside' === _wp_array_get( $attributes, array( 'buttonPosition' ), false );
|
||||
$is_button_inside = isset( $attributes['buttonPosition'] ) && 'button-inside' === $attributes['buttonPosition'];
|
||||
|
||||
$path = array( 'style', 'border', $property );
|
||||
|
||||
|
||||
@ -62,6 +62,7 @@
|
||||
"text": true
|
||||
}
|
||||
},
|
||||
"interactivity": true,
|
||||
"typography": {
|
||||
"__experimentalSkipSerialization": true,
|
||||
"__experimentalSelector": ".wp-block-search__label, .wp-block-search__input, .wp-block-search__button",
|
||||
|
||||
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '1653a74623d252458484');
|
||||
<?php return array('dependencies' => array(), 'version' => 'e81408b3448113f37705');
|
||||
|
||||
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => 'c6277d25063d1381b56e');
|
||||
<?php return array('dependencies' => array(), 'version' => '9c35ebc6d0bf36f1ef22');
|
||||
|
||||
@ -258,6 +258,10 @@ function block_core_social_link_services( $service = '', $field = '' ) {
|
||||
'name' => 'Telegram',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M28.9700376,63.3244248 C47.6273373,55.1957357 60.0684594,49.8368063 66.2934036,47.2476366 C84.0668845,39.855031 87.7600616,38.5708563 90.1672227,38.528 C90.6966555,38.5191258 91.8804274,38.6503351 92.6472251,39.2725385 C93.294694,39.7979149 93.4728387,40.5076237 93.5580865,41.0057381 C93.6433345,41.5038525 93.7494885,42.63857 93.6651041,43.5252052 C92.7019529,53.6451182 88.5344133,78.2034783 86.4142057,89.5379542 C85.5170662,94.3339958 83.750571,95.9420841 82.0403991,96.0994568 C78.3237996,96.4414641 75.5015827,93.6432685 71.9018743,91.2836143 C66.2690414,87.5912212 63.0868492,85.2926952 57.6192095,81.6896017 C51.3004058,77.5256038 55.3966232,75.2369981 58.9976911,71.4967761 C59.9401076,70.5179421 76.3155302,55.6232293 76.6324771,54.2720454 C76.6721165,54.1030573 76.7089039,53.4731496 76.3346867,53.1405352 C75.9604695,52.8079208 75.4081573,52.921662 75.0095933,53.0121213 C74.444641,53.1403447 65.4461175,59.0880351 48.0140228,70.8551922 C45.4598218,72.6091037 43.1463059,73.4636682 41.0734751,73.4188859 C38.7883453,73.3695169 34.3926725,72.1268388 31.1249416,71.0646282 C27.1169366,69.7617838 23.931454,69.0729605 24.208838,66.8603276 C24.3533167,65.7078514 25.9403832,64.5292172 28.9700376,63.3244248 Z" /></svg>',
|
||||
),
|
||||
'threads' => array(
|
||||
'name' => 'Threads',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M16.3 11.3c-.1 0-.2-.1-.2-.1-.1-2.6-1.5-4-3.9-4-1.4 0-2.6.6-3.3 1.7l1.3.9c.5-.8 1.4-1 2-1 .8 0 1.4.2 1.7.7.3.3.5.8.5 1.3-.7-.1-1.4-.2-2.2-.1-2.2.1-3.7 1.4-3.6 3.2 0 .9.5 1.7 1.3 2.2.7.4 1.5.6 2.4.6 1.2-.1 2.1-.5 2.7-1.3.5-.6.8-1.4.9-2.4.6.3 1 .8 1.2 1.3.4.9.4 2.4-.8 3.6-1.1 1.1-2.3 1.5-4.3 1.5-2.1 0-3.8-.7-4.8-2S5.7 14.3 5.7 12c0-2.3.5-4.1 1.5-5.4 1.1-1.3 2.7-2 4.8-2 2.2 0 3.8.7 4.9 2 .5.7.9 1.5 1.2 2.5l1.5-.4c-.3-1.2-.8-2.2-1.5-3.1-1.3-1.7-3.3-2.6-6-2.6-2.6 0-4.7.9-6 2.6C4.9 7.2 4.3 9.3 4.3 12s.6 4.8 1.9 6.4c1.4 1.7 3.4 2.6 6 2.6 2.3 0 4-.6 5.3-2 1.8-1.8 1.7-4 1.1-5.4-.4-.9-1.2-1.7-2.3-2.3zm-4 3.8c-1 .1-2-.4-2-1.3 0-.7.5-1.5 2.1-1.6h.5c.6 0 1.1.1 1.6.2-.2 2.3-1.3 2.7-2.2 2.7z"/></svg>',
|
||||
),
|
||||
'tiktok' => array(
|
||||
'name' => 'TikTok',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M16.708 0.027c1.745-0.027 3.48-0.011 5.213-0.027 0.105 2.041 0.839 4.12 2.333 5.563 1.491 1.479 3.6 2.156 5.652 2.385v5.369c-1.923-0.063-3.855-0.463-5.6-1.291-0.76-0.344-1.468-0.787-2.161-1.24-0.009 3.896 0.016 7.787-0.025 11.667-0.104 1.864-0.719 3.719-1.803 5.255-1.744 2.557-4.771 4.224-7.88 4.276-1.907 0.109-3.812-0.411-5.437-1.369-2.693-1.588-4.588-4.495-4.864-7.615-0.032-0.667-0.043-1.333-0.016-1.984 0.24-2.537 1.495-4.964 3.443-6.615 2.208-1.923 5.301-2.839 8.197-2.297 0.027 1.975-0.052 3.948-0.052 5.923-1.323-0.428-2.869-0.308-4.025 0.495-0.844 0.547-1.485 1.385-1.819 2.333-0.276 0.676-0.197 1.427-0.181 2.145 0.317 2.188 2.421 4.027 4.667 3.828 1.489-0.016 2.916-0.88 3.692-2.145 0.251-0.443 0.532-0.896 0.547-1.417 0.131-2.385 0.079-4.76 0.095-7.145 0.011-5.375-0.016-10.735 0.025-16.093z" /></svg>',
|
||||
|
||||
@ -67,14 +67,11 @@ function render_block_core_template_part( $attributes ) {
|
||||
// Else, if the template part was provided by the active theme,
|
||||
// render the corresponding file content.
|
||||
if ( 0 === validate_file( $attributes['slug'] ) ) {
|
||||
$block_template_file = _get_block_template_file( 'wp_template_part', $attributes['slug'] );
|
||||
if ( $block_template_file ) {
|
||||
$template_part_file_path = $block_template_file['path'];
|
||||
$content = (string) file_get_contents( $template_part_file_path );
|
||||
$content = '' !== $content ? _inject_theme_attribute_in_block_template_content( $content ) : '';
|
||||
if ( isset( $block_template_file['area'] ) ) {
|
||||
$area = $block_template_file['area'];
|
||||
}
|
||||
$block_template = get_block_file_template( $template_part_id, 'wp_template_part' );
|
||||
|
||||
$content = $block_template->content;
|
||||
if ( isset( $block_template->area ) ) {
|
||||
$area = $block_template->area;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ class WP_Block_Parser {
|
||||
$this->offset = 0;
|
||||
$this->output = array();
|
||||
$this->stack = array();
|
||||
$this->empty_attrs = json_decode( '{}', true );
|
||||
$this->empty_attrs = array();
|
||||
|
||||
while ( $this->proceed() ) {
|
||||
continue;
|
||||
|
||||
@ -108,7 +108,7 @@ function wp_default_packages_vendor( $scripts ) {
|
||||
$vendor_scripts_versions = array(
|
||||
'react' => '18.2.0',
|
||||
'react-dom' => '18.2.0',
|
||||
'regenerator-runtime' => '0.14.0',
|
||||
'regenerator-runtime' => '0.13.11',
|
||||
'moment' => '2.29.4',
|
||||
'lodash' => '4.17.19',
|
||||
'wp-polyfill-fetch' => '3.6.17',
|
||||
@ -279,6 +279,10 @@ function wp_default_packages_scripts( $scripts ) {
|
||||
*/
|
||||
$assets = include ABSPATH . WPINC . "/assets/script-loader-packages{$suffix}.php";
|
||||
|
||||
// Add the private version of the Interactivity API manually.
|
||||
$scripts->add( 'wp-interactivity', '/wp-includes/js/dist/interactivity.min.js' );
|
||||
did_action( 'init' ) && $scripts->add_data( 'wp-interactivity', 'strategy', 'defer' );
|
||||
|
||||
foreach ( $assets as $file_name => $package_data ) {
|
||||
$basename = str_replace( $suffix . '.js', '', basename( $file_name ) );
|
||||
$handle = 'wp-' . $basename;
|
||||
@ -1684,6 +1688,7 @@ function wp_default_styles( $styles ) {
|
||||
'wp-block-library',
|
||||
'wp-reusable-blocks',
|
||||
'wp-block-editor-content',
|
||||
'wp-patterns',
|
||||
);
|
||||
|
||||
// Only load the default layout and margin styles for themes without theme.json file.
|
||||
@ -1726,10 +1731,12 @@ function wp_default_styles( $styles ) {
|
||||
'wp-components',
|
||||
'wp-block-editor',
|
||||
'wp-reusable-blocks',
|
||||
'wp-patterns',
|
||||
),
|
||||
'format-library' => array(),
|
||||
'list-reusable-blocks' => array( 'wp-components' ),
|
||||
'reusable-blocks' => array( 'wp-components' ),
|
||||
'patterns' => array( 'wp-components' ),
|
||||
'nux' => array( 'wp-components' ),
|
||||
'widgets' => array(
|
||||
'wp-components',
|
||||
@ -1740,6 +1747,7 @@ function wp_default_styles( $styles ) {
|
||||
'wp-edit-blocks',
|
||||
'wp-block-library',
|
||||
'wp-reusable-blocks',
|
||||
'wp-patterns',
|
||||
),
|
||||
'customize-widgets' => array(
|
||||
'wp-widgets',
|
||||
@ -1747,6 +1755,7 @@ function wp_default_styles( $styles ) {
|
||||
'wp-edit-blocks',
|
||||
'wp-block-library',
|
||||
'wp-reusable-blocks',
|
||||
'wp-patterns',
|
||||
),
|
||||
'edit-site' => array(
|
||||
'wp-components',
|
||||
@ -1818,6 +1827,7 @@ function wp_default_styles( $styles ) {
|
||||
'wp-format-library',
|
||||
'wp-list-reusable-blocks',
|
||||
'wp-reusable-blocks',
|
||||
'wp-patterns',
|
||||
'wp-nux',
|
||||
'wp-widgets',
|
||||
// Deprecated CSS.
|
||||
|
||||
@ -63,4 +63,3 @@ remove_action( 'init', 'register_block_core_site_title' );
|
||||
remove_action( 'init', 'register_block_core_social_link' );
|
||||
remove_action( 'init', 'register_block_core_tag_cloud' );
|
||||
remove_action( 'init', 'register_block_core_template_part' );
|
||||
remove_action( 'init', 'register_block_core_term_description' );
|
||||
|
||||
@ -65,20 +65,72 @@ module.exports = function( env = { environment: 'production', watch: false, buil
|
||||
const config = {
|
||||
...baseConfig,
|
||||
entry: {
|
||||
'file/view': normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-module/file/view` ),
|
||||
'navigation/view': normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-module/navigation/view` ),
|
||||
'navigation/view-modal': normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-module/navigation/view-modal` ),
|
||||
'search/view': normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-module/search/view` ),
|
||||
'navigation/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/navigation/view' ),
|
||||
'image/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/image/view' ),
|
||||
'query/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/query/view' ),
|
||||
'file/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/file/view' ),
|
||||
'search/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/search/view' ),
|
||||
},
|
||||
output: {
|
||||
devtoolNamespace: 'wp',
|
||||
filename: `[name]${ suffix }.js`,
|
||||
path: normalizeJoin(baseDir, `${ buildTarget }/blocks` ),
|
||||
filename: `./blocks/[name]${ suffix }.js`,
|
||||
path: normalizeJoin( baseDir, buildTarget ),
|
||||
chunkLoadingGlobal: `__WordPressPrivateInteractivityAPI__`,
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@wordpress/interactivity': normalizeJoin( baseDir, 'node_modules/@wordpress/interactivity/src/index.js' ),
|
||||
},
|
||||
},
|
||||
optimization: {
|
||||
...baseConfig.optimization,
|
||||
runtimeChunk: {
|
||||
name: 'private-interactivity',
|
||||
},
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
interactivity: {
|
||||
name: 'private-interactivity',
|
||||
test: /^(?!.*[\\/]block-library[\\/]).*$/,
|
||||
filename: `./js/dist/interactivity${suffix}.js`,
|
||||
chunks: 'all',
|
||||
minSize: 0,
|
||||
priority: -10,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(j|t)sx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve( 'babel-loader' ),
|
||||
options: {
|
||||
cacheDirectory: process.env.BABEL_CACHE_DIRECTORY || true,
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-react',
|
||||
{
|
||||
runtime: 'automatic',
|
||||
importSource: 'preact',
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
...baseConfig.plugins,
|
||||
new DependencyExtractionPlugin( {
|
||||
injectPolyfill: false,
|
||||
useDefaults: false,
|
||||
} ),
|
||||
new CopyWebpackPlugin( {
|
||||
patterns: [
|
||||
|
||||
@ -52,7 +52,7 @@ module.exports = function( env = { environment: 'production', watch: false, buil
|
||||
buildTarget = buildTarget + '/wp-includes';
|
||||
|
||||
const WORDPRESS_NAMESPACE = '@wordpress/';
|
||||
const BUNDLED_PACKAGES = [ '@wordpress/icons', '@wordpress/interface' ];
|
||||
const BUNDLED_PACKAGES = [ '@wordpress/icons', '@wordpress/interface', '@wordpress/interactivity', '@wordpress/sync' ];
|
||||
const packages = Object.keys( dependencies )
|
||||
.filter( ( packageName ) =>
|
||||
! BUNDLED_PACKAGES.includes( packageName ) &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user