Editor: Sync changes from the Gutenberg plugin 14.1 release

Updated WordPress packages necessary for releasing WordPress 6.1 Beta 1:

- @wordpress/a11y@3.17.1
 - @wordpress/annotations@2.17.2
 - @wordpress/api-fetch@6.14.1
 - @wordpress/autop@3.17.1
 - @wordpress/babel-plugin-import-jsx-pragma@4.0.1
 - @wordpress/babel-plugin-makepot@5.1.1
 - @wordpress/babel-preset-default@7.1.1
 - @wordpress/base-styles@4.8.1
 - @wordpress/blob@3.17.1
 - @wordpress/block-directory@3.15.2
 - @wordpress/block-editor@10.0.2
 - @wordpress/block-library@7.14.2
 - @wordpress/block-serialization-default-parser@4.17.1
 - @wordpress/block-serialization-spec-parser@4.17.1
 - @wordpress/blocks@11.16.2
 - @wordpress/browserslist-config@5.0.1
 - @wordpress/components@21.0.2
 - @wordpress/compose@5.15.2
 - @wordpress/core-data@5.0.2
 - @wordpress/create-block-tutorial-template@2.5.1
 - @wordpress/create-block@4.1.1
 - @wordpress/custom-templated-path-webpack-plugin@2.1.3
 - @wordpress/customize-widgets@3.14.2
 - @wordpress/data-controls@2.17.2
 - @wordpress/data@7.1.2
 - @wordpress/date@4.17.1
 - @wordpress/dependency-extraction-webpack-plugin@4.0.2
 - @wordpress/deprecated@3.17.1
 - @wordpress/docgen@1.26.1
 - @wordpress/dom-ready@3.17.1
 - @wordpress/dom@3.17.2
 - @wordpress/e2e-test-utils@8.1.1
 - @wordpress/e2e-tests@5.1.2
 - @wordpress/edit-post@6.14.2
 - @wordpress/edit-site@4.14.2
 - @wordpress/edit-widgets@4.14.2
 - @wordpress/editor@12.16.2
 - @wordpress/element@4.15.1
 - @wordpress/env@5.2.1
 - @wordpress/escape-html@2.17.1
 - @wordpress/eslint-plugin@13.1.1
 - @wordpress/format-library@3.15.2
 - @wordpress/hooks@3.17.1
 - @wordpress/html-entities@3.17.1
 - @wordpress/i18n@4.17.1
 - @wordpress/icons@9.8.1
 - @wordpress/interface@4.16.2
 - @wordpress/is-shallow-equal@4.17.1
 - @wordpress/jest-console@6.0.1
 - @wordpress/jest-preset-default@9.0.1
 - @wordpress/jest-puppeteer-axe@5.0.1
 - @wordpress/keyboard-shortcuts@3.15.2
 - @wordpress/keycodes@3.17.1
 - @wordpress/lazy-import@1.4.3
 - @wordpress/library-export-default-webpack-plugin@2.3.3
 - @wordpress/list-reusable-blocks@3.15.2
 - @wordpress/media-utils@4.8.1
 - @wordpress/notices@3.17.2
 - @wordpress/npm-package-json-lint-config@4.2.1
 - @wordpress/nux@5.15.2
 - @wordpress/plugins@4.15.2
 - @wordpress/postcss-plugins-preset@4.1.1
 - @wordpress/postcss-themes@5.0.1
 - @wordpress/preferences-persistence@1.9.1
 - @wordpress/preferences@2.9.2
 - @wordpress/prettier-config@2.0.1
 - @wordpress/primitives@3.15.1
 - @wordpress/priority-queue@2.17.2
 - @wordpress/project-management-automation@1.16.1
 - @wordpress/react-i18n@3.15.1
 - @wordpress/readable-js-assets-webpack-plugin@2.0.1
 - @wordpress/redux-routine@4.17.1
 - @wordpress/reusable-blocks@3.15.2
 - @wordpress/rich-text@5.15.2
 - @wordpress/scripts@24.1.2
 - @wordpress/server-side-render@3.15.2
 - @wordpress/shortcode@3.17.1
 - @wordpress/style-engine@1.0.1
 - @wordpress/stylelint-config@21.0.1
 - @wordpress/token-list@2.17.1
 - @wordpress/url@3.18.1
 - @wordpress/viewport@4.15.2
 - @wordpress/warning@2.17.1
 - @wordpress/widgets@2.15.2
 - @wordpress/wordcount@3.17.1


Props bernhard-reiter, cbravobernal, czapla, oandregal, isabel_brison, andrewserong, mciampini.
See #56467.



git-svn-id: https://develop.svn.wordpress.org/trunk@54257 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski 2022-09-20 15:14:54 +00:00
parent f158620eab
commit 3b63a75108
119 changed files with 3558 additions and 5993 deletions

7082
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,10 +25,10 @@
],
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
"@wordpress/babel-preset-default": "6.8.1",
"@wordpress/dependency-extraction-webpack-plugin": "3.4.2",
"@wordpress/e2e-test-utils": "7.2.1",
"@wordpress/scripts": "22.4.2",
"@wordpress/babel-preset-default": "7.1.1",
"@wordpress/dependency-extraction-webpack-plugin": "4.0.2",
"@wordpress/e2e-test-utils": "8.1.1",
"@wordpress/scripts": "24.1.2",
"autoprefixer": "^9.8.8",
"chalk": "5.0.1",
"check-node-version": "4.2.1",
@ -76,62 +76,62 @@
"webpack-livereload-plugin": "3.0.2"
},
"dependencies": {
"@wordpress/a11y": "3.6.1",
"@wordpress/annotations": "2.6.2",
"@wordpress/api-fetch": "6.3.1",
"@wordpress/autop": "3.6.1",
"@wordpress/blob": "3.6.1",
"@wordpress/block-directory": "3.4.14",
"@wordpress/block-editor": "8.5.10",
"@wordpress/block-library": "7.3.14",
"@wordpress/block-serialization-default-parser": "4.6.1",
"@wordpress/blocks": "11.5.3",
"@wordpress/components": "19.8.5",
"@wordpress/compose": "5.4.1",
"@wordpress/core-data": "4.4.5",
"@wordpress/customize-widgets": "3.3.14",
"@wordpress/data": "6.6.1",
"@wordpress/data-controls": "2.6.1",
"@wordpress/date": "4.6.1",
"@wordpress/deprecated": "3.6.1",
"@wordpress/dom": "3.6.1",
"@wordpress/dom-ready": "3.6.1",
"@wordpress/edit-post": "6.3.14",
"@wordpress/edit-site": "4.3.14",
"@wordpress/edit-widgets": "4.3.14",
"@wordpress/editor": "12.5.10",
"@wordpress/element": "4.4.1",
"@wordpress/escape-html": "2.6.1",
"@wordpress/format-library": "3.4.10",
"@wordpress/hooks": "3.6.1",
"@wordpress/html-entities": "3.6.1",
"@wordpress/i18n": "4.6.1",
"@wordpress/icons": "8.2.3",
"@wordpress/interface": "4.5.6",
"@wordpress/is-shallow-equal": "4.6.1",
"@wordpress/keyboard-shortcuts": "3.4.1",
"@wordpress/keycodes": "3.6.1",
"@wordpress/list-reusable-blocks": "3.4.5",
"@wordpress/media-utils": "3.4.1",
"@wordpress/notices": "3.6.1",
"@wordpress/nux": "5.4.5",
"@wordpress/plugins": "4.4.3",
"@wordpress/preferences": "2.8.0",
"@wordpress/preferences-persistence": "1.8.0",
"@wordpress/primitives": "3.4.1",
"@wordpress/priority-queue": "2.6.1",
"@wordpress/redux-routine": "4.6.1",
"@wordpress/reusable-blocks": "3.4.10",
"@wordpress/rich-text": "5.4.2",
"@wordpress/server-side-render": "3.4.6",
"@wordpress/shortcode": "3.6.1",
"@wordpress/style-engine": "0.5.1",
"@wordpress/token-list": "2.6.1",
"@wordpress/url": "3.7.1",
"@wordpress/viewport": "4.4.1",
"@wordpress/warning": "2.6.1",
"@wordpress/widgets": "2.4.10",
"@wordpress/wordcount": "3.6.1",
"@wordpress/a11y": "3.17.1",
"@wordpress/annotations": "2.17.2",
"@wordpress/api-fetch": "6.14.1",
"@wordpress/autop": "3.17.1",
"@wordpress/blob": "3.17.1",
"@wordpress/block-directory": "3.15.2",
"@wordpress/block-editor": "10.0.2",
"@wordpress/block-library": "7.14.2",
"@wordpress/block-serialization-default-parser": "4.17.1",
"@wordpress/blocks": "11.16.2",
"@wordpress/components": "21.0.2",
"@wordpress/compose": "5.15.2",
"@wordpress/core-data": "5.0.2",
"@wordpress/customize-widgets": "3.14.2",
"@wordpress/data": "7.1.2",
"@wordpress/data-controls": "2.17.2",
"@wordpress/date": "4.17.1",
"@wordpress/deprecated": "3.17.1",
"@wordpress/dom": "3.17.2",
"@wordpress/dom-ready": "3.17.1",
"@wordpress/edit-post": "6.14.2",
"@wordpress/edit-site": "4.14.2",
"@wordpress/edit-widgets": "4.14.2",
"@wordpress/editor": "12.16.2",
"@wordpress/element": "4.15.1",
"@wordpress/escape-html": "2.17.1",
"@wordpress/format-library": "3.15.2",
"@wordpress/hooks": "3.17.1",
"@wordpress/html-entities": "3.17.1",
"@wordpress/i18n": "4.17.1",
"@wordpress/icons": "9.8.1",
"@wordpress/interface": "4.16.2",
"@wordpress/is-shallow-equal": "4.17.1",
"@wordpress/keyboard-shortcuts": "3.15.2",
"@wordpress/keycodes": "3.17.1",
"@wordpress/list-reusable-blocks": "3.15.2",
"@wordpress/media-utils": "4.8.1",
"@wordpress/notices": "3.17.2",
"@wordpress/nux": "5.15.2",
"@wordpress/plugins": "4.15.2",
"@wordpress/preferences": "2.9.2",
"@wordpress/preferences-persistence": "1.9.1",
"@wordpress/primitives": "3.15.1",
"@wordpress/priority-queue": "2.17.2",
"@wordpress/redux-routine": "4.17.1",
"@wordpress/reusable-blocks": "3.15.2",
"@wordpress/rich-text": "5.15.2",
"@wordpress/server-side-render": "3.15.2",
"@wordpress/shortcode": "3.17.1",
"@wordpress/style-engine": "1.0.1",
"@wordpress/token-list": "2.17.1",
"@wordpress/url": "3.18.1",
"@wordpress/viewport": "4.15.2",
"@wordpress/warning": "2.17.1",
"@wordpress/widgets": "2.15.2",
"@wordpress/wordcount": "3.17.1",
"backbone": "1.4.1",
"clipboard": "2.0.10",
"core-js-url-browser": "3.6.4",

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-react-refresh-runtime'), 'version' => '8151afc94a5ebc73b7a8229f0d7ee352');
<?php return array('dependencies' => array('wp-react-refresh-runtime'), 'version' => '794dd7047e2302828128');

View File

@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '4fb86f241c3b2d9d9e0411b507079823');
<?php return array('dependencies' => array(), 'version' => 'd4cdced5a2afff4a8cc2');

View File

@ -62,9 +62,11 @@ function render_block_core_archives( $attributes ) {
break;
}
$block_content = '<label for="' . esc_attr( $dropdown_id ) . '">' . esc_html( $title ) . '</label>
<select id="' . esc_attr( $dropdown_id ) . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">' . esc_html( $label ) . '</option>' . $archives . '</select>';
$show_label = empty( $attributes['showLabel'] ) ? ' screen-reader-text' : '';
$block_content = '<label for="' . $dropdown_id . '" class="wp-block-archives__label' . $show_label . '">' . esc_html( $title ) . '</label>
<select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">' . esc_html( $label ) . '</option>' . $archives . '</select>';
return sprintf(
'<div %1$s>%2$s</div>',

View File

@ -11,6 +11,10 @@
"type": "boolean",
"default": false
},
"showLabel": {
"type": "boolean",
"default": true
},
"showPostCounts": {
"type": "boolean",
"default": false
@ -22,7 +26,24 @@
},
"supports": {
"align": true,
"html": false
"html": false,
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-archives-editor"
}

View File

@ -12,15 +12,18 @@
"type": "string",
"source": "attribute",
"selector": "audio",
"attribute": "src"
"attribute": "src",
"__experimentalRole": "content"
},
"caption": {
"type": "string",
"source": "html",
"selector": "figcaption"
"selector": "figcaption",
"__experimentalRole": "content"
},
"id": {
"type": "number"
"type": "number",
"__experimentalRole": "content"
},
"autoplay": {
"type": "boolean",
@ -43,7 +46,11 @@
},
"supports": {
"anchor": true,
"align": true
"align": true,
"spacing": {
"margin": true,
"padding": true
}
},
"editorStyle": "wp-block-audio-editor",
"style": "wp-block-audio"

View File

@ -105,11 +105,11 @@ function render_block_core_avatar( $attributes, $content, $block ) {
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
}
$comment = get_comment( $block->context['commentId'] );
/* translators: %s is the Comment Author name */
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
if ( ! $comment ) {
return '';
}
/* translators: %s is the Comment Author name */
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
$avatar_block = get_avatar(
$comment,
$size,

View File

@ -22,7 +22,6 @@
"type": "string",
"default": "_self"
}
},
"usesContext": [ "postType", "postId", "commentId" ],
"supports": {
@ -30,7 +29,8 @@
"align": true,
"alignWide": false,
"spacing": {
"margin": true
"margin": true,
"padding": true
},
"__experimentalBorder": {
"__experimentalSkipSerialization": true,

View File

@ -68,7 +68,13 @@
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
@ -88,7 +94,7 @@
"radius": true
}
},
"__experimentalSelector": ".wp-block-button__link"
"__experimentalSelector": ".wp-block-button .wp-block-button__link"
},
"styles": [
{ "name": "fill", "label": "Fill", "isDefault": true },

View File

@ -18,6 +18,19 @@
"blockGap": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"__experimentalLayout": {
"allowSwitching": false,
"allowInheriting": false,

View File

@ -30,8 +30,8 @@ function render_block_core_calendar( $attributes ) {
if ( isset( $attributes['month'] ) && isset( $attributes['year'] ) ) {
$permalink_structure = get_option( 'permalink_structure' );
if (
strpos( $permalink_structure, '%monthnum%' ) !== false &&
strpos( $permalink_structure, '%year%' ) !== false
str_contains( $permalink_structure, '%monthnum%' ) &&
str_contains( $permalink_structure, '%year%' )
) {
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
$monthnum = $attributes['month'];

View File

@ -16,7 +16,19 @@
}
},
"supports": {
"align": true
"align": true,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"style": "wp-block-calendar"
}

View File

@ -22,6 +22,7 @@ function render_block_core_categories( $attributes ) {
'orderby' => 'name',
'show_count' => ! empty( $attributes['showPostCounts'] ),
'title_li' => '',
'hide_empty' => empty( $attributes['showEmpty'] ),
);
if ( ! empty( $attributes['showOnlyTopLevel'] ) && $attributes['showOnlyTopLevel'] ) {
$args['parent'] = 0;
@ -75,7 +76,7 @@ function build_dropdown_script_block_core_categories( $dropdown_id ) {
var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );
function onCatChange() {
if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;
location.href = "<?php echo esc_url( home_url() ); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;
}
}
dropdown.onchange = onCatChange;

View File

@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/categories",
"title": "Categories",
"title": "Categories List",
"category": "widgets",
"description": "Display a list of all categories.",
"textdomain": "default",
@ -22,11 +22,32 @@
"showOnlyTopLevel": {
"type": "boolean",
"default": false
},
"showEmpty": {
"type": "boolean",
"default": false
}
},
"supports": {
"align": true,
"html": false
"html": false,
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-categories-editor",
"style": "wp-block-categories"

View File

@ -18,10 +18,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -19,7 +19,7 @@
},
"templateLock": {
"type": [ "string", "boolean" ],
"enum": [ "all", "insert", false ]
"enum": [ "all", "insert", "contentOnly", false ]
}
},
"supports": {
@ -41,6 +41,29 @@
"padding": true
}
},
"__experimentalBorder": {
"color": true,
"style": true,
"width": true,
"__experimentalDefaultControls": {
"color": true,
"style": true,
"width": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"__experimentalLayout": true
}
}

View File

@ -29,7 +29,8 @@
},
"spacing": {
"blockGap": {
"__experimentalDefault": "2em"
"__experimentalDefault": "2em",
"sides": [ "horizontal", "vertical" ]
},
"margin": [ "top", "bottom" ],
"padding": true,
@ -57,6 +58,19 @@
"style": true,
"width": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-columns-editor",

View File

@ -43,7 +43,11 @@
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalLetterSpacing": true
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
}
}

View File

@ -29,7 +29,11 @@
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalLetterSpacing": true
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"spacing": {
"padding": [ "horizontal", "vertical" ],

View File

@ -28,6 +28,10 @@
"link": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
@ -35,6 +39,7 @@
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true

View File

@ -28,6 +28,10 @@
"link": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
@ -35,7 +39,11 @@
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalLetterSpacing": true
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
}
}

View File

@ -23,6 +23,10 @@
"link": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
@ -30,7 +34,11 @@
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalLetterSpacing": true
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"html": false
}

View File

@ -4,14 +4,27 @@
"name": "core/comment-template",
"title": "Comment Template",
"category": "design",
"parent": [ "core/comments-query-loop" ],
"parent": [ "core/comments" ],
"description": "Contains the block elements used to display a comment, like the title, date, author, avatar and more.",
"textdomain": "default",
"usesContext": [ "postId" ],
"supports": {
"reusable": false,
"html": false,
"align": true
"align": true,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"style": "wp-block-comment-template"
}

View File

@ -26,10 +26,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -10,6 +10,19 @@
"usesContext": [ "postId" ],
"supports": {
"reusable": false,
"html": false
"html": false,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
}
}

View File

@ -26,10 +26,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -4,7 +4,7 @@
"name": "core/comments-pagination",
"title": "Comments Pagination",
"category": "theme",
"parent": [ "core/comments-query-loop" ],
"parent": [ "core/comments" ],
"description": "Displays a paginated navigation to next/previous set of comments, when applicable.",
"textdomain": "default",
"attributes": {
@ -35,6 +35,19 @@
"default": {
"type": "flex"
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-comments-pagination-editor",

View File

@ -1,29 +0,0 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/comments-query-loop",
"title": "Comments Query Loop",
"category": "theme",
"description": "An advanced block that allows displaying post comments using different visual configurations.",
"textdomain": "default",
"attributes": {
"tagName": {
"type": "string",
"default": "div"
}
},
"supports": {
"align": [ "wide", "full" ],
"html": false,
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true,
"link": true
}
}
},
"editorStyle": "wp-block-comments-editor"
}

View File

@ -56,7 +56,7 @@ function render_block_core_comments_title( $attributes ) {
} else {
$comments_title = sprintf(
/* translators: %s: Number of comments. */
_n( '%s responses', '%s responses', $comments_count ),
_n( '%s response', '%s responses', $comments_count ),
number_format_i18n( $comments_count )
);
}

View File

@ -4,7 +4,7 @@
"name": "core/comments-title",
"title": "Comments Title",
"category": "theme",
"ancestor": [ "core/comments-query-loop" ],
"ancestor": [ "core/comments" ],
"description": "Displays a title with the number of comments",
"textdomain": "default",
"usesContext": [ "postId", "postType" ],
@ -49,10 +49,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontWeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,
"__experimentalFontFamily": true,

View File

@ -0,0 +1,220 @@
<?php
/**
* Server-side rendering of the `core/comments` block.
*
* @package WordPress
*/
/**
* Renders the `core/comments` block on the server.
*
* This render callback is mainly for rendering a dynamic, legacy version of
* this block (the old `core/post-comments`). It uses the `comments_template()`
* function to generate the output, in the same way as classic PHP themes.
*
* As this callback will always run during SSR, first we need to check whether
* the block is in legacy mode. If not, the HTML generated in the editor is
* returned instead.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the filtered post comments for the current post wrapped inside "p" tags.
*/
function render_block_core_comments( $attributes, $content, $block ) {
global $post;
$post_id = $block->context['postId'];
if ( ! isset( $post_id ) ) {
return '';
}
$comment_args = array(
'post_id' => $post_id,
'count' => true,
'status' => 'approve',
);
// Return early if there are no comments and comments are closed.
if ( ! comments_open( $post_id ) && get_comments( $comment_args ) === 0 ) {
return '';
}
// If this isn't the legacy block, we need to render the static version of this block.
$is_legacy = 'core/post-comments' === $block->name || ! empty( $attributes['legacy'] );
if ( ! $is_legacy ) {
return $block->render( array( 'dynamic' => false ) );
}
$post_before = $post;
$post = get_post( $post_id );
setup_postdata( $post );
ob_start();
/*
* There's a deprecation warning generated by WP Core.
* Ideally this deprecation is removed from Core.
* In the meantime, this removes it from the output.
*/
add_filter( 'deprecated_file_trigger_error', '__return_false' );
comments_template();
remove_filter( 'deprecated_file_trigger_error', '__return_false' );
$output = ob_get_clean();
$post = $post_before;
$classnames = array();
// Adds the old class name for styles' backwards compatibility.
if ( isset( $attributes['legacy'] ) ) {
$classnames[] = 'wp-block-post-comments';
}
if ( isset( $attributes['textAlign'] ) ) {
$classnames[] = 'has-text-align-' . $attributes['textAlign'];
}
$wrapper_attributes = get_block_wrapper_attributes(
array( 'class' => implode( ' ', $classnames ) )
);
/*
* Enqueues scripts and styles required only for the legacy version. That is
* why they are not defined in `block.json`.
*/
wp_enqueue_script( 'comment-reply' );
enqueue_legacy_post_comments_block_styles( $block->name );
return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $output );
}
/**
* Registers the `core/comments` block on the server.
*/
function register_block_core_comments() {
register_block_type_from_metadata(
__DIR__ . '/comments',
array(
'render_callback' => 'render_block_core_comments',
'skip_inner_blocks' => true,
)
);
}
add_action( 'init', 'register_block_core_comments' );
/**
* Use the button block classes for the form-submit button.
*
* @param array $fields The default comment form arguments.
*
* @return array Returns the modified fields.
*/
function comments_block_form_defaults( $fields ) {
if ( wp_is_block_theme() ) {
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link ' . wp_theme_get_element_class_name( 'button' ) . '" value="%4$s" />';
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
}
return $fields;
}
add_filter( 'comment_form_defaults', 'comments_block_form_defaults' );
/**
* Enqueues styles from the legacy `core/post-comments` block. These styles are
* required only by the block's fallback.
*
* @param string $block_name Name of the new block type.
*/
function enqueue_legacy_post_comments_block_styles( $block_name ) {
static $are_styles_enqueued = false;
if ( ! $are_styles_enqueued ) {
$handles = array(
'wp-block-post-comments',
'wp-block-buttons',
'wp-block-button',
);
foreach ( $handles as $handle ) {
wp_enqueue_block_style( $block_name, array( 'handle' => $handle ) );
}
$are_styles_enqueued = true;
}
}
/**
* Ensures backwards compatibility for any users running the Gutenberg plugin
* who have used Post Comments before it was merged into Comments Query Loop.
*
* The same approach was followed when core/query-loop was renamed to
* core/post-template.
*
* @see https://github.com/WordPress/gutenberg/pull/41807
* @see https://github.com/WordPress/gutenberg/pull/32514
*/
function register_legacy_post_comments_block() {
$registry = WP_Block_Type_Registry::get_instance();
/*
* Remove the old `post-comments` block if it was already registered, as it
* is about to be replaced by the type defined below.
*/
if ( $registry->is_registered( 'core/post-comments' ) ) {
unregister_block_type( 'core/post-comments' );
}
// Recreate the legacy block metadata.
$metadata = array(
'name' => 'core/post-comments',
'category' => 'theme',
'attributes' => array(
'textAlign' => array(
'type' => 'string',
),
),
'uses_context' => array(
'postId',
'postType',
),
'supports' => array(
'html' => false,
'align' => array( 'wide', 'full' ),
'typography' => array(
'fontSize' => true,
'lineHeight' => true,
'__experimentalFontStyle' => true,
'__experimentalFontWeight' => true,
'__experimentalLetterSpacing' => true,
'__experimentalTextTransform' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
),
),
'color' => array(
'gradients' => true,
'link' => true,
'__experimentalDefaultControls' => array(
'background' => true,
'text' => true,
),
),
'inserter' => false,
),
'style' => array(
'wp-block-post-comments',
'wp-block-buttons',
'wp-block-button',
),
'editorStyle' => 'wp-block-post-comments-editor',
'render_callback' => 'render_block_core_comments',
'skip_inner_blocks' => true,
);
/*
* Filters the metadata object, the same way it's done inside
* `register_block_type_from_metadata()`. This applies some default filters,
* like `_wp_multiple_block_styles`, which is required in this case because
* the block has multiple styles.
*/
$metadata = apply_filters( 'block_type_metadata', $metadata );
register_block_type( 'core/post-comments', $metadata );
}
add_action( 'init', 'register_legacy_post_comments_block', 21 );

View File

@ -0,0 +1,47 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/comments",
"title": "Comments",
"category": "theme",
"description": "An advanced block that allows displaying post comments using different visual configurations.",
"textdomain": "default",
"attributes": {
"tagName": {
"type": "string",
"default": "div"
},
"legacy": {
"type": "boolean",
"default": false
}
},
"supports": {
"align": [ "wide", "full" ],
"html": false,
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true,
"link": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-comments-editor",
"usesContext": [ "postId", "postType" ]
}

View File

@ -8,8 +8,8 @@
/**
* Renders the `core/cover` block on server.
*
* @param array $attributes The block attributes.
* @param array $content The block rendered content.
* @param array $attributes The block attributes.
* @param string $content The block rendered content.
*
* @return string Returns the cover block markup, if useFeaturedImage is true.
*/
@ -46,9 +46,19 @@ function render_block_core_cover( $attributes, $content ) {
update_post_thumbnail_cache();
}
$current_featured_image = get_the_post_thumbnail_url();
$content = preg_replace(
$styles = 'background-image:url(' . esc_url( $current_featured_image ) . '); ';
if ( isset( $attributes['minHeight'] ) ) {
$height_unit = empty( $attributes['minHeightUnit'] ) ? 'px' : $attributes['minHeightUnit'];
$height = " min-height:{$attributes['minHeight']}{$height_unit}";
$styles .= $height;
}
$content = preg_replace(
'/class=\".*?\"/',
'${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
'${0} style="' . $styles . '"',
$content,
1
);

View File

@ -73,7 +73,7 @@
},
"templateLock": {
"type": [ "string", "boolean" ],
"enum": [ "all", "insert", false ]
"enum": [ "all", "insert", "contentOnly", false ]
}
},
"usesContext": [ "postId", "postType" ],
@ -83,6 +83,7 @@
"html": false,
"spacing": {
"padding": true,
"margin": [ "top", "bottom" ],
"__experimentalDefaultControls": {
"padding": true
}
@ -91,6 +92,19 @@
"__experimentalDuotone": "> .wp-block-cover__image-background, > .wp-block-cover__video-background",
"text": false,
"background": false
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-cover-editor",

View File

@ -19,6 +19,28 @@ function render_block_core_file( $attributes, $content ) {
wp_enqueue_script( 'wp-block-file-view' );
}
// Update object's aria-label attribute if present in block HTML.
// Match an aria-label attribute from an object tag.
$pattern = '@<object.+(?<attribute>aria-label="(?<filename>[^"]+)?")@i';
$content = preg_replace_callback(
$pattern,
function ( $matches ) {
$filename = ! empty( $matches['filename'] ) ? $matches['filename'] : '';
$has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
$label = $has_filename ?
sprintf(
/* translators: %s: filename. */
__( 'Embed of %s.' ),
$filename
)
: __( 'PDF embed' );
return str_replace( $matches['attribute'], sprintf( 'aria-label="%s"', $label ), $matches[0] );
},
$content
);
return $content;
}

View File

@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '9a1dbe2fc8e62a7e82dd0d30439951b3');
<?php return array('dependencies' => array(), 'version' => 'ee575fc5e86fe255013d');

View File

@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'c7ee2db603af4ed37bd6b1d2bb4a51bf');
<?php return array('dependencies' => array(), 'version' => '2a20786ca914ea00891f');

View File

@ -50,10 +50,30 @@ function block_core_gallery_render( $attributes, $content ) {
// because we only want to match against the value, not the CSS attribute.
if ( is_array( $gap ) ) {
foreach ( $gap as $key => $value ) {
$gap[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value;
// Make sure $value is a string to avoid PHP 8.1 deprecation error in preg_match() when the value is null.
$value = is_string( $value ) ? $value : '';
$value = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value;
// Get spacing CSS variable from preset value if provided.
if ( is_string( $value ) && str_contains( $value, 'var:preset|spacing|' ) ) {
$index_to_splice = strrpos( $value, '|' ) + 1;
$slug = _wp_to_kebab_case( substr( $value, $index_to_splice ) );
$value = "var(--wp--preset--spacing--$slug)";
}
$gap[ $key ] = $value;
}
} else {
// Make sure $gap is a string to avoid PHP 8.1 deprecation error in preg_match() when the value is null.
$gap = is_string( $gap ) ? $gap : '';
$gap = $gap && preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap;
// Get spacing CSS variable from preset value if provided.
if ( is_string( $gap ) && str_contains( $gap, 'var:preset|spacing|' ) ) {
$index_to_splice = strrpos( $gap, '|' ) + 1;
$slug = _wp_to_kebab_case( substr( $gap, $index_to_splice ) );
$gap = "var(--wp--preset--spacing--$slug)";
}
}
$class = wp_unique_id( 'wp-block-gallery-' );
@ -76,19 +96,15 @@ function block_core_gallery_render( $attributes, $content ) {
$gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column;
}
// Set the CSS variable to the column value, and the `gap` property to the combined gap value.
$style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
// The unstable gallery gap calculation requires a real value (such as `0px`) and not `0`.
if ( '0' === $gap_column ) {
$gap_column = '0px';
}
// Ideally styles should be loaded in the head, but blocks may be parsed
// after that, so loading in the footer for now.
// See https://core.trac.wordpress.org/ticket/53494.
add_action(
'wp_footer',
function () use ( $style ) {
echo '<style> ' . $style . '</style>';
},
11
);
// Set the CSS variable to the column value, and the `gap` property to the combined gap value.
$style = '.wp-block-gallery.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
wp_enqueue_block_support_styles( $style, 11 );
return $content;
}
/**

View File

@ -110,12 +110,19 @@
"html": false,
"units": [ "px", "em", "rem", "vh", "vw" ],
"spacing": {
"blockGap": true,
"margin": true,
"padding": true,
"blockGap": [ "horizontal", "vertical" ],
"__experimentalSkipSerialization": [ "blockGap" ],
"__experimentalDefaultControls": {
"blockGap": true
}
},
"color": {
"text": false,
"background": true,
"gradients": true
},
"__experimentalLayout": {
"allowSwitching": false,
"allowInheriting": false,

View File

@ -14,12 +14,15 @@
},
"templateLock": {
"type": [ "string", "boolean" ],
"enum": [ "all", "insert", false ]
"enum": [ "all", "insert", "contentOnly", false ]
}
},
"supports": {
"__experimentalOnEnter": true,
"__experimentalSettings": true,
"align": [ "wide", "full" ],
"anchor": true,
"ariaLabel": true,
"html": false,
"color": {
"gradients": true,
@ -53,10 +56,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -31,6 +31,7 @@
"anchor": true,
"className": false,
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
@ -38,15 +39,18 @@
}
},
"spacing": {
"margin": true
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontStyle": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true,

View File

@ -89,7 +89,7 @@ function block_core_home_link_build_css_font_sizes( $context ) {
* Builds an array with classes and style for the li wrapper
*
* @param array $context Home link block context.
* @return array The li wrapper attributes.
* @return string The li wrapper attributes.
*/
function block_core_home_link_build_li_wrapper_attributes( $context ) {
$colors = block_core_home_link_build_css_colors( $context );
@ -125,24 +125,15 @@ function render_block_core_home_link( $attributes, $content, $block ) {
return '';
}
$wrapper_attributes = block_core_home_link_build_li_wrapper_attributes( $block->context );
$aria_current = is_home() || ( is_front_page() && 'page' === get_option( 'show_on_front' ) ) ? ' aria-current="page"' : '';
$html = '<li ' . $wrapper_attributes . '><a class="wp-block-home-link__content wp-block-navigation-item__content" rel="home"' . $aria_current;
// Start appending HTML attributes to anchor tag.
$html .= ' href="' . esc_url( home_url() ) . '"';
// End appending HTML attributes to anchor tag.
$html .= '>';
if ( isset( $attributes['label'] ) ) {
$html .= wp_kses_post( $attributes['label'] );
}
$html .= '</a></li>';
return $html;
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>',
block_core_home_link_build_li_wrapper_attributes( $block->context ),
esc_url( home_url() ),
$aria_current,
wp_kses_post( $attributes['label'] )
);
}
/**

View File

@ -23,7 +23,20 @@
],
"supports": {
"reusable": false,
"html": false
"html": false,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-home-link-editor",
"style": "wp-block-home-link"

View File

@ -20,7 +20,7 @@ function render_block_core_image( $attributes, $content ) {
// which now wraps Image Blocks within innerBlocks.
// The data-id attribute is added in a core/gallery `render_block_data` hook.
$data_id_attribute = 'data-id="' . esc_attr( $attributes['data-id'] ) . '"';
if ( false === strpos( $content, $data_id_attribute ) ) {
if ( ! str_contains( $content, $data_id_attribute ) ) {
$content = str_replace( '<img', '<img ' . $data_id_attribute . ' ', $content );
}
}

View File

@ -16,31 +16,36 @@
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "src"
"attribute": "src",
"__experimentalRole": "content"
},
"alt": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "alt",
"default": ""
"default": "",
"__experimentalRole": "content"
},
"caption": {
"type": "string",
"source": "html",
"selector": "figcaption"
"selector": "figcaption",
"__experimentalRole": "content"
},
"title": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "title"
"attribute": "title",
"__experimentalRole": "content"
},
"href": {
"type": "string",
"source": "attribute",
"selector": "figure > a",
"attribute": "href"
"attribute": "href",
"__experimentalRole": "content"
},
"rel": {
"type": "string",
@ -55,7 +60,8 @@
"attribute": "class"
},
"id": {
"type": "number"
"type": "number",
"__experimentalRole": "content"
},
"width": {
"type": "number"
@ -79,14 +85,20 @@
"supports": {
"anchor": true,
"color": {
"__experimentalDuotone": "img",
"__experimentalDuotone": "img, .components-placeholder",
"text": false,
"background": false
},
"__experimentalBorder": {
"color": true,
"radius": true,
"width": true,
"__experimentalSelector": "img, .wp-block-image__crop-area",
"__experimentalSkipSerialization": true,
"__experimentalDefaultControls": {
"radius": true
"color": true,
"radius": true,
"width": true
}
}
},

View File

@ -84,7 +84,20 @@
},
"supports": {
"align": true,
"html": false
"html": false,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-latest-posts-editor",
"style": "wp-block-latest-posts"

View File

@ -0,0 +1,26 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/list-item",
"title": "List item",
"category": "text",
"parent": [ "core/list" ],
"description": "Create a list item.",
"textdomain": "default",
"attributes": {
"placeholder": {
"type": "string"
},
"content": {
"type": "string",
"source": "html",
"selector": "li",
"default": "",
"__experimentalRole": "content"
}
},
"supports": {
"className": false,
"__experimentalSelector": "li"
}
}

View File

@ -40,12 +40,13 @@
"className": false,
"typography": {
"fontSize": true,
"__experimentalFontFamily": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
@ -58,6 +59,10 @@
"text": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"__unstablePasteTextInline": true,
"__experimentalSelector": "ol,ul",
"__experimentalSlashInserter": true

View File

@ -17,20 +17,23 @@
"source": "attribute",
"selector": "figure img",
"attribute": "alt",
"default": ""
"default": "",
"__experimentalRole": "content"
},
"mediaPosition": {
"type": "string",
"default": "left"
},
"mediaId": {
"type": "number"
"type": "number",
"__experimentalRole": "content"
},
"mediaUrl": {
"type": "string",
"source": "attribute",
"selector": "figure video,figure img",
"attribute": "src"
"attribute": "src",
"__experimentalRole": "content"
},
"mediaLink": {
"type": "string"
@ -48,7 +51,8 @@
"type": "string",
"source": "attribute",
"selector": "figure a",
"attribute": "href"
"attribute": "href",
"__experimentalRole": "content"
},
"rel": {
"type": "string",
@ -63,7 +67,8 @@
"attribute": "class"
},
"mediaType": {
"type": "string"
"type": "string",
"__experimentalRole": "content"
},
"mediaWidth": {
"type": "number",
@ -97,6 +102,23 @@
"background": true,
"text": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-media-text-editor",

View File

@ -150,7 +150,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
$css_classes = trim( implode( ' ', $classes ) );
$has_submenu = count( $block->inner_blocks ) > 0;
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );
$is_active = ! empty( $attributes['id'] ) && ( get_queried_object_id() === (int) $attributes['id'] );
$wrapper_attributes = get_block_wrapper_attributes(
array(

View File

@ -58,7 +58,20 @@
"supports": {
"reusable": false,
"html": false,
"__experimentalSlashInserter": true
"__experimentalSlashInserter": true,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-navigation-link-editor",
"style": "wp-block-navigation-link"

View File

@ -148,7 +148,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
$css_classes = trim( implode( ' ', $classes ) );
$has_submenu = count( $block->inner_blocks ) > 0;
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === (int) $attributes['id'] );
$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
$open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];

View File

@ -250,29 +250,24 @@ function block_core_navigation_render_submenu_icon() {
/**
* Finds the first non-empty `wp_navigation` Post.
* Finds the most recently published `wp_navigation` Post.
*
* @return WP_Post|null the first non-empty Navigation or null.
*/
function block_core_navigation_get_first_non_empty_navigation() {
// Order and orderby args set to mirror those in `wp_get_nav_menus`
// see:
// - https://github.com/WordPress/wordpress-develop/blob/ba943e113d3b31b121f77a2d30aebe14b047c69d/src/wp-includes/nav-menu.php#L613-L619.
// - https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters.
function block_core_navigation_get_most_recently_published_navigation() {
// We default to the most recently created menu.
$parsed_args = array(
'post_type' => 'wp_navigation',
'no_found_rows' => true,
'order' => 'ASC',
'orderby' => 'name',
'order' => 'DESC',
'orderby' => 'date',
'post_status' => 'publish',
'posts_per_page' => 20, // Try the first 20 posts.
'posts_per_page' => 1, // get only the most recent.
);
$navigation_posts = new WP_Query( $parsed_args );
foreach ( $navigation_posts->posts as $navigation_post ) {
if ( has_blocks( $navigation_post ) ) {
return $navigation_post;
}
$navigation_post = new WP_Query( $parsed_args );
if ( count( $navigation_post->posts ) > 0 ) {
return $navigation_post->posts[0];
}
return null;
@ -325,7 +320,7 @@ function block_core_navigation_get_fallback_blocks() {
// Default to a list of Pages.
$navigation_post = block_core_navigation_get_first_non_empty_navigation();
$navigation_post = block_core_navigation_get_most_recently_published_navigation();
// Prefer using the first non-empty Navigation as fallback if available.
if ( $navigation_post ) {
@ -377,7 +372,7 @@ function block_core_navigation_from_block_get_post_ids( $block ) {
}
if ( 'core/navigation-link' === $block->name || 'core/navigation-submenu' === $block->name ) {
if ( $block->attributes && isset( $block->attributes['kind'] ) && 'post-type' === $block->attributes['kind'] ) {
if ( $block->attributes && isset( $block->attributes['kind'] ) && 'post-type' === $block->attributes['kind'] && isset( $block->attributes['id'] ) ) {
$post_ids[] = $block->attributes['id'];
}
}
@ -431,6 +426,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
wp_enqueue_script( 'wp-block-navigation-view' );
}
$should_load_modal_view_script = isset( $attributes['overlayMenu'] ) && 'never' !== $attributes['overlayMenu'];
if ( $should_load_modal_view_script ) {
wp_enqueue_script( 'wp-block-navigation-view-modal' );
}
$inner_blocks = $block->inner_blocks;
// Ensure that blocks saved with the legacy ref attribute name (navigationMenuId) continue to render.
@ -467,23 +467,27 @@ function render_block_core_navigation( $attributes, $content, $block ) {
return '';
}
$nav_menu_name = $navigation_post->post_title;
// Only published posts are valid. If this is changed then a corresponding change
// must also be implemented in `use-navigation-menu.js`.
if ( 'publish' === $navigation_post->post_status ) {
$nav_menu_name = $navigation_post->post_title;
if ( isset( $seen_menu_names[ $nav_menu_name ] ) ) {
++$seen_menu_names[ $nav_menu_name ];
} else {
$seen_menu_names[ $nav_menu_name ] = 1;
if ( isset( $seen_menu_names[ $nav_menu_name ] ) ) {
++$seen_menu_names[ $nav_menu_name ];
} else {
$seen_menu_names[ $nav_menu_name ] = 1;
}
$parsed_blocks = parse_blocks( $navigation_post->post_content );
// 'parse_blocks' includes a null block with '\n\n' as the content when
// it encounters whitespace. This code strips it.
$compacted_blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );
// TODO - this uses the full navigation block attributes for the
// context which could be refined.
$inner_blocks = new WP_Block_List( $compacted_blocks, $attributes );
}
$parsed_blocks = parse_blocks( $navigation_post->post_content );
// 'parse_blocks' includes a null block with '\n\n' as the content when
// it encounters whitespace. This code strips it.
$compacted_blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );
// TODO - this uses the full navigation block attributes for the
// context which could be refined.
$inner_blocks = new WP_Block_List( $compacted_blocks, $attributes );
}
// If there are no inner blocks then fallback to rendering an appropriate fallback.
@ -498,9 +502,18 @@ function render_block_core_navigation( $attributes, $content, $block ) {
}
$inner_blocks = new WP_Block_List( $fallback_blocks, $attributes );
}
/**
* Filter navigation block $inner_blocks.
* Allows modification of a navigation block menu items.
*
* @since 6.1.0
*
* @param \WP_Block_List $inner_blocks
*/
$inner_blocks = apply_filters( 'block_core_navigation_render_inner_blocks', $inner_blocks );
$layout_justification = array(
'left' => 'items-justified-left',
'right' => 'items-justified-right',
@ -552,10 +565,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
$is_list_open = false;
$inner_blocks_html .= '</ul>';
}
if ( 'core/site-title' === $inner_block->name || 'core/site-logo' === $inner_block->name ) {
$inner_blocks_html .= '<li class="wp-block-navigation-item">' . $inner_block->render() . '</li>';
$inner_block_content = $inner_block->render();
if ( 'core/site-title' === $inner_block->name || ( 'core/site-logo' === $inner_block->name && $inner_block_content ) ) {
$inner_blocks_html .= '<li class="wp-block-navigation-item">' . $inner_block_content . '</li>';
} else {
$inner_blocks_html .= $inner_block->render();
$inner_blocks_html .= $inner_block_content;
}
}
@ -604,16 +618,25 @@ function render_block_core_navigation( $attributes, $content, $block ) {
$is_hidden_by_default ? 'always-shown' : '',
);
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg>';
$should_display_icon_label = isset( $attributes['hasIcon'] ) && true === $attributes['hasIcon'];
$toggle_button_content = $should_display_icon_label ? $toggle_button_icon : 'Menu';
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg>';
if ( isset( $attributes['icon'] ) ) {
if ( 'menu' === $attributes['icon'] ) {
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 5v1.5h14V5H5zm0 7.8h14v-1.5H5v1.5zM5 19h14v-1.5H5V19z" /></svg>';
}
}
$toggle_button_content = $should_display_icon_label ? $toggle_button_icon : __( 'Menu' );
$toggle_close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" 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>';
$toggle_close_button_content = $should_display_icon_label ? $toggle_close_button_icon : __( 'Close' );
$toggle_aria_label_open = $should_display_icon_label ? 'aria-label="' . __( 'Open menu' ) . '"' : ''; // Open button label.
$toggle_aria_label_close = $should_display_icon_label ? 'aria-label="' . __( 'Close menu' ) . '"' : ''; // Close button label.
$responsive_container_markup = sprintf(
'<button aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="%1$s">%9$s</button>
'<button aria-haspopup="true" %3$s class="%6$s" data-micromodal-trigger="%1$s">%9$s</button>
<div class="%5$s" style="%7$s" id="%1$s">
<div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
<div class="wp-block-navigation__responsive-dialog" aria-label="%8$s">
<button aria-label="%4$s" data-micromodal-close class="wp-block-navigation__responsive-container-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" 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></button>
<button %4$s data-micromodal-close class="wp-block-navigation__responsive-container-close">%10$s</button>
<div class="wp-block-navigation__responsive-container-content" id="%1$s-content">
%2$s
</div>
@ -622,13 +645,14 @@ function render_block_core_navigation( $attributes, $content, $block ) {
</div>',
esc_attr( $modal_unique_id ),
$inner_blocks_html,
__( 'Open menu' ), // Open button label.
__( 'Close menu' ), // Close button label.
$toggle_aria_label_open,
$toggle_aria_label_close,
esc_attr( implode( ' ', $responsive_container_classes ) ),
esc_attr( implode( ' ', $open_button_classes ) ),
safecss_filter_attr( $colors['overlay_inline_styles'] ),
__( 'Menu' ),
$toggle_button_content
$toggle_button_content,
$toggle_close_button_content
);
return sprintf(

View File

@ -41,6 +41,10 @@
"type": "string",
"default": "mobile"
},
"icon": {
"type": "string",
"default": "handle"
},
"hasIcon": {
"type": "boolean",
"default": true
@ -94,6 +98,7 @@
"__experimentalFontWeight": true,
"__experimentalTextTransform": true,
"__experimentalFontFamily": true,
"__experimentalLetterSpacing": true,
"__experimentalTextDecoration": true,
"__experimentalSkipSerialization": [ "textDecoration" ],
"__experimentalDefaultControls": {
@ -114,9 +119,18 @@
"default": {
"type": "flex"
}
},
"__experimentalStyle": {
"elements": {
"link": {
"color": {
"text": "inherit"
}
}
}
}
},
"viewScript": "file:./view.min.js",
"viewScript": [ "file:./view.min.js", "file:./view-modal.min.js" ],
"editorStyle": "wp-block-navigation-editor",
"style": "wp-block-navigation"
}

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => '6d574d0390bc333487cb');

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => '45f05135277abf0b0408');

View File

@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '3bc2957a58e1f08fa9309e91ffeef792');
<?php return array('dependencies' => array(), 'version' => '4ab20ef60d94f9632256');

View File

@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '009e29110e016c14bac4ba0ecc809fcd');
<?php return array('dependencies' => array(), 'version' => 'c24330f635f5cb9d5e0e');

View File

@ -328,9 +328,9 @@ function render_block_core_page_list( $attributes, $content, $block ) {
);
}
/**
* Registers the `core/pages` block on server.
*/
/**
* Registers the `core/pages` block on server.
*/
function register_block_core_page_list() {
register_block_type_from_metadata(
__DIR__ . '/page-list',
@ -339,4 +339,4 @@ function register_block_core_page_list() {
)
);
}
add_action( 'init', 'register_block_core_page_list' );
add_action( 'init', 'register_block_core_page_list' );

View File

@ -34,15 +34,22 @@
"anchor": true,
"className": false,
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalTextDecoration": true,
"__experimentalFontStyle": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,

View File

@ -32,6 +32,7 @@
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true

View File

@ -15,10 +15,11 @@
*/
function render_block_core_post_author( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
$author_id = get_query_var( 'author' );
} else {
$author_id = get_post_field( 'post_author', $block->context['postId'] );
}
$author_id = get_post_field( 'post_author', $block->context['postId'] );
if ( empty( $author_id ) ) {
return '';
}

View File

@ -35,10 +35,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -72,7 +72,7 @@ add_action( 'init', 'register_block_core_post_comments_form' );
*/
function post_comments_form_block_form_defaults( $fields ) {
if ( wp_is_block_theme() ) {
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />';
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="wp-block-button__link ' . wp_theme_get_element_class_name( 'button' ) . '" value="%4$s" />';
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
}

View File

@ -1,85 +0,0 @@
<?php
/**
* Server-side rendering of the `core/post-comments` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-comments` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the filtered post comments for the current post wrapped inside "p" tags.
*/
function render_block_core_post_comments( $attributes, $content, $block ) {
global $post;
$post_id = $block->context['postId'];
if ( ! isset( $post_id ) ) {
return '';
}
$comment_args = array(
'post_id' => $post_id,
'count' => true,
);
// Return early if there are no comments and comments are closed.
if ( ! comments_open( $post_id ) && get_comments( $comment_args ) === 0 ) {
return '';
}
$post_before = $post;
$post = get_post( $post_id );
setup_postdata( $post );
ob_start();
// There's a deprecation warning generated by WP Core.
// Ideally this deprecation is removed from Core.
// In the meantime, this removes it from the output.
add_filter( 'deprecated_file_trigger_error', '__return_false' );
comments_template();
remove_filter( 'deprecated_file_trigger_error', '__return_false' );
$post = $post_before;
$classes = '';
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . $attributes['textAlign'];
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$output = ob_get_clean();
return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $output );
}
/**
* Registers the `core/post-comments` block on the server.
*/
function register_block_core_post_comments() {
register_block_type_from_metadata(
__DIR__ . '/post-comments',
array(
'render_callback' => 'render_block_core_post_comments',
)
);
}
add_action( 'init', 'register_block_core_post_comments' );
/**
* Use the button block classes for the form-submit button.
*
* @param array $fields The default comment form arguments.
*
* @return array Returns the modified fields.
*/
function post_comments_block_form_defaults( $fields ) {
if ( wp_is_block_theme() ) {
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />';
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
}
return $fields;
}
add_filter( 'comment_form_defaults', 'post_comments_block_form_defaults' );

View File

@ -1,45 +1,47 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/post-comments",
"title": "Post Comments (deprecated)",
"name": "core/comments",
"title": "Comments",
"category": "theme",
"description": "This block is deprecated. Please use the Comments Query Loop block instead.",
"description": "An advanced block that allows displaying post comments using different visual configurations.",
"textdomain": "default",
"attributes": {
"textAlign": {
"type": "string"
"tagName": {
"type": "string",
"default": "div"
},
"legacy": {
"type": "boolean",
"default": false
}
},
"usesContext": [ "postId", "postType" ],
"supports": {
"html": false,
"align": [ "wide", "full" ],
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalTextTransform": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"html": false,
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true
"text": true,
"link": true
}
},
"inserter": false
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"style": [
"wp-block-post-comments",
"wp-block-buttons",
"wp-block-button"
],
"editorStyle": "wp-block-post-comments-editor"
"editorStyle": "wp-block-comments-editor",
"usesContext": [ "postId", "postType" ]
}

View File

@ -10,7 +10,20 @@
"supports": {
"align": [ "wide", "full" ],
"html": false,
"__experimentalLayout": true
"__experimentalLayout": true,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-post-content-editor"
}

View File

@ -21,7 +21,15 @@ function render_block_core_post_date( $attributes, $content, $block ) {
$post_ID = $block->context['postId'];
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
$formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
$formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
$unformatted_date = esc_attr( get_the_modified_date( 'c', $post_ID ) );
} else {
$formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
$unformatted_date = esc_attr( get_the_date( 'c', $post_ID ) );
}
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$formatted_date = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $formatted_date );
}
@ -29,7 +37,7 @@ function render_block_core_post_date( $attributes, $content, $block ) {
return sprintf(
'<div %1$s><time datetime="%2$s">%3$s</time></div>',
$wrapper_attributes,
esc_attr( get_the_date( 'c', $post_ID ) ),
$unformatted_date,
$formatted_date
);
}

View File

@ -16,6 +16,10 @@
"isLink": {
"type": "boolean",
"default": false
},
"displayType": {
"type": "string",
"default": "date"
}
},
"usesContext": [ "postId", "postType", "queryId" ],
@ -30,6 +34,10 @@
"link": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
@ -37,6 +45,7 @@
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true

View File

@ -37,10 +37,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -19,21 +19,40 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
}
$post_ID = $block->context['postId'];
$is_link = isset( $attributes['isLink'] ) && $attributes['isLink'];
$size_slug = isset( $attributes['sizeSlug'] ) ? $attributes['sizeSlug'] : 'post-thumbnail';
$post_title = trim( strip_tags( get_the_title( $post_ID ) ) );
$featured_image = get_the_post_thumbnail( $post_ID, $size_slug, array( 'alt' => $post_title ) );
$attr = get_block_core_post_featured_image_border_attributes( $attributes );
$overlay_markup = get_block_core_post_featured_image_overlay_element_markup( $attributes );
if ( $is_link ) {
$attr['alt'] = $post_title;
}
$featured_image = get_the_post_thumbnail( $post_ID, $size_slug, $attr );
if ( ! $featured_image ) {
return '';
}
$wrapper_attributes = get_block_wrapper_attributes();
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$featured_image = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $featured_image );
if ( $is_link ) {
$link_target = $attributes['linkTarget'];
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
$featured_image = sprintf(
'<a href="%1$s" target="%2$s" %3$s>%4$s%5$s</a>',
get_the_permalink( $post_ID ),
esc_attr( $link_target ),
$rel,
$featured_image,
$overlay_markup
);
} else {
$featured_image = $featured_image . $overlay_markup;
}
$has_width = ! empty( $attributes['width'] );
$has_height = ! empty( $attributes['height'] );
if ( ! $has_height && ! $has_width ) {
return "<figure $wrapper_attributes>$featured_image</figure>";
return "<figure {$wrapper_attributes}>{$featured_image}</figure>";
}
if ( $has_width ) {
@ -48,7 +67,130 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
$featured_image = str_replace( 'src=', 'style="' . esc_attr( $image_styles ) . '" src=', $featured_image );
}
return "<figure $wrapper_attributes>$featured_image</figure>";
return "<figure {$wrapper_attributes}>{$featured_image}</figure>";
}
/**
* Generate markup for the HTML element that will be used for the overlay.
*
* @param array $attributes Block attributes.
*
* @return string HTML markup in string format.
*/
function get_block_core_post_featured_image_overlay_element_markup( $attributes ) {
$has_dim_background = isset( $attributes['dimRatio'] ) && $attributes['dimRatio'];
$has_gradient = isset( $attributes['gradient'] ) && $attributes['gradient'];
$has_custom_gradient = isset( $attributes['customGradient'] ) && $attributes['customGradient'];
$has_solid_overlay = isset( $attributes['overlayColor'] ) && $attributes['overlayColor'];
$has_custom_overlay = isset( $attributes['customOverlayColor'] ) && $attributes['customOverlayColor'];
$class_names = array(
'wp-block-post-featured-image__overlay',
);
$styles_properties = array();
if ( ! $has_dim_background ) {
return '';
}
// Generate required classes for the element.
if ( $has_dim_background ) {
$class_names[] = 'has-background-dim';
$class_names[] = "has-background-dim-{$attributes['dimRatio']}";
}
if ( $has_solid_overlay ) {
$class_names[] = "has-{$attributes['overlayColor']}-background-color";
}
if ( $has_gradient || $has_custom_gradient ) {
$class_names[] = 'has-background-gradient';
}
if ( $has_gradient ) {
$class_names[] = "has-{$attributes['gradient']}-gradient-background";
}
// Generate required CSS properties and their values.
if ( ! empty( $attributes['style']['border']['radius'] ) ) {
$styles_properties['border-radius'] = $attributes['style']['border']['radius'];
}
if ( ! empty( $attributes['style']['border']['width'] ) ) {
$styles_properties['border-width'] = $attributes['style']['border']['width'];
}
if ( $has_custom_gradient ) {
$styles_properties['background-image'] = $attributes['customGradient'];
}
if ( $has_custom_overlay ) {
$styles_properties['background-color'] = $attributes['customOverlayColor'];
}
$styles = '';
foreach ( $styles_properties as $style_attribute => $style_attribute_value ) {
$styles .= "{$style_attribute}: $style_attribute_value; ";
}
return sprintf(
'<span class="%s" style="%s" aria-hidden="true"></span>',
esc_attr( implode( ' ', $class_names ) ),
esc_attr( trim( $styles ) )
);
}
/**
* Generates class names and styles to apply the border support styles for
* the Post Featured Image block.
*
* @param array $attributes The block attributes.
* @return array The border-related classnames and styles for the block.
*/
function get_block_core_post_featured_image_border_attributes( $attributes ) {
$border_styles = array();
$sides = array( 'top', 'right', 'bottom', 'left' );
// Border radius.
if ( isset( $attributes['style']['border']['radius'] ) ) {
$border_styles['radius'] = $attributes['style']['border']['radius'];
}
// Border style.
if ( isset( $attributes['style']['border']['style'] ) ) {
$border_styles['style'] = $attributes['style']['border']['style'];
}
// Border width.
if ( isset( $attributes['style']['border']['width'] ) ) {
$border_styles['width'] = $attributes['style']['border']['width'];
}
// 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 );
$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_styles[ $side ] = array(
'color' => isset( $border['color'] ) ? $border['color'] : null,
'style' => isset( $border['style'] ) ? $border['style'] : null,
'width' => isset( $border['width'] ) ? $border['width'] : null,
);
}
$styles = wp_style_engine_get_styles( array( 'border' => $border_styles ) );
$attributes = array();
if ( ! empty( $styles['classnames'] ) ) {
$attributes['class'] = $styles['classnames'];
}
if ( ! empty( $styles['css'] ) ) {
$attributes['style'] = $styles['css'];
}
return $attributes;
}
/**

View File

@ -23,6 +23,31 @@
},
"sizeSlug": {
"type": "string"
},
"rel": {
"type": "string",
"attribute": "rel",
"default": ""
},
"linkTarget": {
"type": "string",
"default": "_self"
},
"overlayColor": {
"type": "string"
},
"customOverlayColor": {
"type": "string"
},
"dimRatio": {
"type": "number",
"default": 0
},
"gradient": {
"type": "string"
},
"customGradient": {
"type": "string"
}
},
"usesContext": [ "postId", "postType", "queryId" ],
@ -33,6 +58,18 @@
"text": false,
"background": false
},
"__experimentalBorder": {
"color": true,
"radius": true,
"width": true,
"__experimentalSelector": "img, .block-editor-media-placeholder",
"__experimentalSkipSerialization": true,
"__experimentalDefaultControls": {
"color": true,
"radius": true,
"width": true
}
},
"html": false,
"spacing": {
"margin": true,

View File

@ -29,13 +29,18 @@
"supports": {
"reusable": false,
"html": false,
"color": {
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -12,7 +12,8 @@
"query",
"queryContext",
"displayLayout",
"templateSlug"
"templateSlug",
"previewPostType"
],
"supports": {
"reusable": false,
@ -20,6 +21,19 @@
"align": true,
"__experimentalLayout": {
"allowEditing": false
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"style": "wp-block-post-template",

View File

@ -36,12 +36,22 @@ function render_block_core_post_terms( $attributes, $content, $block ) {
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$prefix = "<div $wrapper_attributes>";
if ( isset( $attributes['prefix'] ) && $attributes['prefix'] ) {
$prefix .= '<span class="wp-block-post-terms__prefix">' . $attributes['prefix'] . '</span>';
}
$suffix = '</div>';
if ( isset( $attributes['suffix'] ) && $attributes['suffix'] ) {
$suffix = '<span class="wp-block-post-terms__suffix">' . $attributes['suffix'] . '</span>' . $suffix;
}
return get_the_term_list(
$block->context['postId'],
$attributes['term'],
"<div $wrapper_attributes>",
wp_kses_post( $prefix ),
'<span class="wp-block-post-terms__separator">' . esc_html( $separator ) . '</span>',
'</div>'
wp_kses_post( $suffix )
);
}
@ -49,10 +59,48 @@ function render_block_core_post_terms( $attributes, $content, $block ) {
* Registers the `core/post-terms` block on the server.
*/
function register_block_core_post_terms() {
$taxonomies = get_taxonomies(
array(
'public' => true,
'show_in_rest' => true,
),
'objects'
);
// Split the available taxonomies to `built_in` and custom ones,
// in order to prioritize the `built_in` taxonomies at the
// search results.
$built_ins = array();
$custom_variations = array();
// Create and register the eligible taxonomies variations.
foreach ( $taxonomies as $taxonomy ) {
$variation = array(
'name' => $taxonomy->name,
'title' => $taxonomy->label,
/* translators: %s: taxonomy's label */
'description' => sprintf( __( 'Display the assigned taxonomy: %s' ), $taxonomy->label ),
'attributes' => array(
'term' => $taxonomy->name,
),
'isActive' => array( 'term' ),
);
// Set the category variation as the default one.
if ( 'category' === $taxonomy->name ) {
$variation['isDefault'] = true;
}
if ( $taxonomy->_builtin ) {
$built_ins[] = $variation;
} else {
$custom_variations[] = $variation;
}
}
register_block_type_from_metadata(
__DIR__ . '/post-terms',
array(
'render_callback' => 'render_block_core_post_terms',
'variations' => array_merge( $built_ins, $custom_variations ),
)
);
}

View File

@ -16,6 +16,14 @@
"separator": {
"type": "string",
"default": ", "
},
"prefix": {
"type": "string",
"default": ""
},
"suffix": {
"type": "string",
"default": ""
}
},
"usesContext": [ "postId", "postType" ],
@ -31,12 +39,14 @@
}
},
"typography": {
"lineHeight": true,
"fontSize": true,
"__experimentalFontStyle": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -34,7 +34,8 @@ function render_block_core_post_title( $attributes, $content, $block ) {
}
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$title = sprintf( '<a href="%1$s" target="%2$s" rel="%3$s">%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), esc_attr( $attributes['rel'] ), $title );
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );

View File

@ -42,7 +42,8 @@
}
},
"spacing": {
"margin": true
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
@ -51,6 +52,7 @@
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,

View File

@ -28,10 +28,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -10,8 +10,7 @@
"value": {
"type": "string",
"source": "html",
"selector": "blockquote",
"multiline": "p",
"selector": "p",
"__experimentalRole": "content"
},
"citation": {
@ -40,10 +39,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true
@ -60,6 +61,12 @@
"style": true,
"width": true
}
},
"__experimentalStyle": {
"typography": {
"fontSize": "1.5em",
"lineHeight": "1.6"
}
}
},
"editorStyle": "wp-block-pullquote-editor",

View File

@ -15,6 +15,19 @@
"color": {
"gradients": true,
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
}
}

View File

@ -26,10 +26,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -21,10 +21,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -26,10 +26,12 @@
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}

View File

@ -20,7 +20,6 @@ function render_block_core_query_pagination( $attributes, $content ) {
$wrapper_attributes = get_block_wrapper_attributes(
array(
'role' => 'navigation',
'aria-label' => __( 'Pagination' ),
)
);

View File

@ -36,6 +36,19 @@
"default": {
"type": "flex"
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-query-pagination-editor",

View File

@ -17,13 +17,39 @@
function render_block_core_query_title( $attributes ) {
$type = isset( $attributes['type'] ) ? $attributes['type'] : null;
$is_archive = is_archive();
if ( ! $type || ( 'archive' === $type && ! $is_archive ) ) {
$is_search = is_search();
if ( ! $type ||
( 'archive' === $type && ! $is_archive ) ||
( 'search' === $type && ! $is_search )
) {
return '';
}
$title = '';
if ( $is_archive ) {
$title = get_the_archive_title();
$show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
if ( ! $show_prefix ) {
$filter_title = function( $title, $original_title ) {
return $original_title;
};
add_filter( 'get_the_archive_title', $filter_title, 10, 2 );
$title = get_the_archive_title();
remove_filter( 'get_the_archive_title', $filter_title, 10, 2 );
} else {
$title = get_the_archive_title();
}
}
if ( $is_search ) {
$title = __( 'Search results' );
if ( isset( $attributes['showSearchTerm'] ) && $attributes['showSearchTerm'] ) {
$title = sprintf(
/* translators: %s is the search term. */
__( 'Search results for: "%s"' ),
get_search_query()
);
}
}
$tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h1';
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );

View File

@ -16,6 +16,14 @@
"level": {
"type": "number",
"default": 1
},
"showPrefix": {
"type": "boolean",
"default": true
},
"showSearchTerm": {
"type": "boolean",
"default": true
}
},
"supports": {
@ -29,7 +37,8 @@
}
},
"spacing": {
"margin": true
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
@ -39,6 +48,7 @@
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true,
@ -46,5 +56,5 @@
}
}
},
"editorStyle": "wp-block-query-title-editor"
"style": "wp-block-query-title"
}

View File

@ -24,7 +24,8 @@
"exclude": [],
"sticky": "",
"inherit": true,
"taxQuery": null
"taxQuery": null,
"parents": []
}
},
"tagName": {
@ -36,6 +37,9 @@
"default": {
"type": "list"
}
},
"namespace": {
"type": "string"
}
},
"providesContext": {

View File

@ -30,13 +30,16 @@
"supports": {
"anchor": true,
"__experimentalSlashInserter": true,
"__experimentalOnEnter": true,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontStyle": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true

View File

@ -13,10 +13,11 @@ require ABSPATH . WPINC . '/blocks/comment-date.php';
require ABSPATH . WPINC . '/blocks/comment-edit-link.php';
require ABSPATH . WPINC . '/blocks/comment-reply-link.php';
require ABSPATH . WPINC . '/blocks/comment-template.php';
require ABSPATH . WPINC . '/blocks/comments.php';
require ABSPATH . WPINC . '/blocks/comments-pagination.php';
require ABSPATH . WPINC . '/blocks/comments-pagination-next.php';
require ABSPATH . WPINC . '/blocks/comments-pagination-numbers.php';
require ABSPATH . WPINC . '/blocks/comments-pagination-previous.php';
require ABSPATH . WPINC . '/blocks/comments-pagination.php';
require ABSPATH . WPINC . '/blocks/comments-title.php';
require ABSPATH . WPINC . '/blocks/cover.php';
require ABSPATH . WPINC . '/blocks/file.php';
@ -26,14 +27,13 @@ require ABSPATH . WPINC . '/blocks/image.php';
require ABSPATH . WPINC . '/blocks/latest-comments.php';
require ABSPATH . WPINC . '/blocks/latest-posts.php';
require ABSPATH . WPINC . '/blocks/loginout.php';
require ABSPATH . WPINC . '/blocks/navigation.php';
require ABSPATH . WPINC . '/blocks/navigation-link.php';
require ABSPATH . WPINC . '/blocks/navigation-submenu.php';
require ABSPATH . WPINC . '/blocks/navigation.php';
require ABSPATH . WPINC . '/blocks/page-list.php';
require ABSPATH . WPINC . '/blocks/pattern.php';
require ABSPATH . WPINC . '/blocks/post-author.php';
require ABSPATH . WPINC . '/blocks/post-author-biography.php';
require ABSPATH . WPINC . '/blocks/post-comments.php';
require ABSPATH . WPINC . '/blocks/post-comments-form.php';
require ABSPATH . WPINC . '/blocks/post-content.php';
require ABSPATH . WPINC . '/blocks/post-date.php';
@ -43,13 +43,13 @@ require ABSPATH . WPINC . '/blocks/post-navigation-link.php';
require ABSPATH . WPINC . '/blocks/post-template.php';
require ABSPATH . WPINC . '/blocks/post-terms.php';
require ABSPATH . WPINC . '/blocks/post-title.php';
require ABSPATH . WPINC . '/blocks/query.php';
require ABSPATH . WPINC . '/blocks/query-no-results.php';
require ABSPATH . WPINC . '/blocks/query-pagination.php';
require ABSPATH . WPINC . '/blocks/query-pagination-next.php';
require ABSPATH . WPINC . '/blocks/query-pagination-numbers.php';
require ABSPATH . WPINC . '/blocks/query-pagination-previous.php';
require ABSPATH . WPINC . '/blocks/query-pagination.php';
require ABSPATH . WPINC . '/blocks/query-title.php';
require ABSPATH . WPINC . '/blocks/query.php';
require ABSPATH . WPINC . '/blocks/read-more.php';
require ABSPATH . WPINC . '/blocks/rss.php';
require ABSPATH . WPINC . '/blocks/search.php';

View File

@ -9,13 +9,13 @@ return array(
'code',
'column',
'columns',
'comments-query-loop',
'embed',
'freeform',
'group',
'heading',
'html',
'list',
'list-item',
'media-text',
'missing',
'more',

View File

@ -13,8 +13,6 @@
* @return string The search block markup.
*/
function render_block_core_search( $attributes ) {
static $instance_id = 0;
// Older versions of the Search block defaulted the label and buttonText
// attributes to `__( 'Search' )` meaning that many posts contain `<!--
// wp:search /-->`. Support these by defaulting an undefined label and
@ -27,17 +25,20 @@ function render_block_core_search( $attributes ) {
)
);
$input_id = 'wp-block-search__input-' . ++$instance_id;
$classnames = classnames_for_block_core_search( $attributes );
$show_label = ( ! empty( $attributes['showLabel'] ) ) ? true : false;
$use_icon_button = ( ! empty( $attributes['buttonUseIcon'] ) ) ? true : false;
$show_input = ( ! empty( $attributes['buttonPosition'] ) && 'button-only' === $attributes['buttonPosition'] ) ? false : true;
$show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
$input_markup = '';
$button_markup = '';
$inline_styles = styles_for_block_core_search( $attributes );
$color_classes = get_color_classes_for_block_core_search( $attributes );
$is_button_inside = ! empty( $attributes['buttonPosition'] ) &&
$input_id = wp_unique_id( 'wp-block-search__input-' );
$classnames = classnames_for_block_core_search( $attributes );
$show_label = ( ! empty( $attributes['showLabel'] ) ) ? true : false;
$use_icon_button = ( ! empty( $attributes['buttonUseIcon'] ) ) ? true : false;
$show_input = ( ! empty( $attributes['buttonPosition'] ) && 'button-only' === $attributes['buttonPosition'] ) ? false : true;
$show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
$query_params = ( ! empty( $attributes['query'] ) ) ? $attributes['query'] : array();
$input_markup = '';
$button_markup = '';
$query_params_markup = '';
$inline_styles = styles_for_block_core_search( $attributes );
$color_classes = get_color_classes_for_block_core_search( $attributes );
$typography_classes = get_typography_classes_for_block_core_search( $attributes );
$is_button_inside = ! empty( $attributes['buttonPosition'] ) &&
'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 );
@ -50,50 +51,80 @@ function render_block_core_search( $attributes ) {
$label_inner_html
);
if ( $show_label && ! empty( $attributes['label'] ) ) {
$label_classes = array( 'wp-block-search__label' );
if ( ! empty( $typography_classes ) ) {
$label_classes[] = $typography_classes;
}
$label_markup = sprintf(
'<label for="%1$s" class="wp-block-search__label">%2$s</label>',
$input_id,
'<label for="%1$s" class="%2$s" %3$s>%4$s</label>',
esc_attr( $input_id ),
esc_attr( implode( ' ', $label_classes ) ),
$inline_styles['label'],
$label_inner_html
);
}
if ( $show_input ) {
$input_classes = ! $is_button_inside ? $border_color_classes : '';
$input_markup = sprintf(
$input_classes = array( 'wp-block-search__input' );
if ( $is_button_inside ) {
$input_classes[] = $border_color_classes;
}
if ( ! empty( $typography_classes ) ) {
$input_classes[] = $typography_classes;
}
$input_markup = sprintf(
'<input type="search" id="%s" class="wp-block-search__input %s" name="s" value="%s" placeholder="%s" %s required />',
$input_id,
esc_attr( $input_classes ),
esc_attr( get_search_query() ),
esc_attr( implode( ' ', $input_classes ) ),
get_search_query(),
esc_attr( $attributes['placeholder'] ),
$inline_styles['input']
);
}
if ( $show_button ) {
$button_internal_markup = '';
$button_classes = $color_classes;
$aria_label = '';
if ( count( $query_params ) > 0 ) {
foreach ( $query_params as $param => $value ) {
$query_params_markup .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
esc_attr( $param ),
esc_attr( $value )
);
}
}
if ( ! $is_button_inside ) {
$button_classes .= ' ' . $border_color_classes;
if ( $show_button ) {
$button_classes = array( 'wp-block-search__button' );
$button_internal_markup = '';
if ( ! empty( $color_classes ) ) {
$button_classes[] = $color_classes;
}
if ( ! empty( $typography_classes ) ) {
$button_classes[] = $typography_classes;
}
$aria_label = '';
if ( ! $is_button_inside && ! empty( $border_color_classes ) ) {
$button_classes[] = $border_color_classes;
}
if ( ! $use_icon_button ) {
if ( ! empty( $attributes['buttonText'] ) ) {
$button_internal_markup = wp_kses_post( $attributes['buttonText'] );
}
} else {
$aria_label = sprintf( 'aria-label="%s"', esc_attr( wp_strip_all_tags( $attributes['buttonText'] ) ) );
$button_classes .= ' has-icon';
$aria_label = sprintf( 'aria-label="%s"', esc_attr( wp_strip_all_tags( $attributes['buttonText'] ) ) );
$button_classes[] = 'has-icon';
$button_internal_markup =
'<svg id="search-icon" class="search-icon" viewBox="0 0 24 24" width="24" height="24">
'<svg class="search-icon" viewBox="0 0 24 24" width="24" height="24">
<path d="M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"></path>
</svg>';
}
$button_markup = sprintf(
'<button type="submit" class="wp-block-search__button %s" %s %s>%s</button>',
esc_attr( $button_classes ),
// Include the button element class.
$button_classes[] = wp_theme_get_element_class_name( 'button' );
$button_markup = sprintf(
'<button type="submit" class="%s" %s %s>%s</button>',
esc_attr( implode( ' ', $button_classes ) ),
$inline_styles['button'],
$aria_label,
$button_internal_markup
@ -105,9 +136,11 @@ function render_block_core_search( $attributes ) {
'<div class="wp-block-search__inside-wrapper %s" %s>%s</div>',
esc_attr( $field_markup_classes ),
$inline_styles['wrapper'],
$input_markup . $button_markup
$input_markup . $query_params_markup . $button_markup
);
$wrapper_attributes = get_block_wrapper_attributes(
array( 'class' => $classnames )
);
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
return sprintf(
'<form role="search" method="get" action="%s" %s>%s</form>',
@ -171,6 +204,75 @@ function classnames_for_block_core_search( $attributes ) {
return implode( ' ', $classnames );
}
/**
* This generates a CSS rule for the given border property and side if provided.
* Based on whether the Search block is configured to display the button inside
* or not, the generated rule is injected into the appropriate collection of
* styles for later application in the block's markup.
*
* @param array $attributes The block attributes.
* @param string $property Border property to generate rule for e.g. width or color.
* @param string $side Optional side border. The dictates the value retrieved and final CSS property.
* @param array $wrapper_styles Current collection of wrapper styles.
* @param array $button_styles Current collection of button styles.
* @param array $input_styles Current collection of input styles.
*
* @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 );
$path = array( 'style', 'border', $property );
if ( $side ) {
array_splice( $path, 2, 0, $side );
}
$value = _wp_array_get( $attributes, $path, false );
if ( empty( $value ) ) {
return;
}
if ( 'color' === $property && $side ) {
$has_color_preset = str_contains( $value, 'var:preset|color|' );
if ( $has_color_preset ) {
$named_color_value = substr( $value, strrpos( $value, '|' ) + 1 );
$value = sprintf( 'var(--wp--preset--color--%s)', $named_color_value );
}
}
$property_suffix = $side ? sprintf( '%s-%s', $side, $property ) : $property;
if ( $is_button_inside ) {
$wrapper_styles[] = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
} else {
$button_styles[] = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
$input_styles[] = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
}
}
/**
* This adds CSS rules for a given border property e.g. width or color. It
* injects rules into the provided wrapper, button and input style arrays for
* uniform "flat" borders or those with individual sides configured.
*
* @param array $attributes The block attributes.
* @param string $property Border property to generate rule for e.g. width or color.
* @param array $wrapper_styles Current collection of wrapper styles.
* @param array $button_styles Current collection of button styles.
* @param array $input_styles Current collection of input styles.
*
* @return void
*/
function apply_block_core_search_border_styles( $attributes, $property, &$wrapper_styles, &$button_styles, &$input_styles ) {
apply_block_core_search_border_style( $attributes, $property, null, $wrapper_styles, $button_styles, $input_styles );
apply_block_core_search_border_style( $attributes, $property, 'top', $wrapper_styles, $button_styles, $input_styles );
apply_block_core_search_border_style( $attributes, $property, 'right', $wrapper_styles, $button_styles, $input_styles );
apply_block_core_search_border_style( $attributes, $property, 'bottom', $wrapper_styles, $button_styles, $input_styles );
apply_block_core_search_border_style( $attributes, $property, 'left', $wrapper_styles, $button_styles, $input_styles );
}
/**
* Builds an array of inline styles for the search block.
*
@ -186,8 +288,10 @@ function styles_for_block_core_search( $attributes ) {
$wrapper_styles = array();
$button_styles = array();
$input_styles = array();
$label_styles = array();
$is_button_inside = ! empty( $attributes['buttonPosition'] ) &&
'button-inside' === $attributes['buttonPosition'];
$show_label = ( isset( $attributes['showLabel'] ) ) && false !== $attributes['showLabel'];
// Add width styles.
$has_width = ! empty( $attributes['width'] ) && ! empty( $attributes['widthUnit'] );
@ -201,19 +305,10 @@ function styles_for_block_core_search( $attributes ) {
);
}
// Add border width styles.
$has_border_width = ! empty( $attributes['style']['border']['width'] );
if ( $has_border_width ) {
$border_width = $attributes['style']['border']['width'];
if ( $is_button_inside ) {
$wrapper_styles[] = sprintf( 'border-width: %s;', esc_attr( $border_width ) );
} else {
$button_styles[] = sprintf( 'border-width: %s;', esc_attr( $border_width ) );
$input_styles[] = sprintf( 'border-width: %s;', esc_attr( $border_width ) );
}
}
// Add border width and color styles.
apply_block_core_search_border_styles( $attributes, 'width', $wrapper_styles, $button_styles, $input_styles );
apply_block_core_search_border_styles( $attributes, 'color', $wrapper_styles, $button_styles, $input_styles );
apply_block_core_search_border_styles( $attributes, 'style', $wrapper_styles, $button_styles, $input_styles );
// Add border radius styles.
$has_border_radius = ! empty( $attributes['style']['border']['radius'] );
@ -269,21 +364,6 @@ function styles_for_block_core_search( $attributes ) {
}
}
// Add border color styles.
$has_border_color = ! empty( $attributes['style']['border']['color'] );
if ( $has_border_color ) {
$border_color = $attributes['style']['border']['color'];
// Apply wrapper border color if button placed inside.
if ( $is_button_inside ) {
$wrapper_styles[] = sprintf( 'border-color: %s;', esc_attr( $border_color ) );
} else {
$button_styles[] = sprintf( 'border-color: %s;', esc_attr( $border_color ) );
$input_styles[] = sprintf( 'border-color: %s;', esc_attr( $border_color ) );
}
}
// Add color styles.
$has_text_color = ! empty( $attributes['style']['color']['text'] );
if ( $has_text_color ) {
@ -300,13 +380,98 @@ function styles_for_block_core_search( $attributes ) {
$button_styles[] = sprintf( 'background: %s;', $attributes['style']['color']['gradient'] );
}
// Get typography styles to be shared across inner elements.
$typography_styles = get_typography_styles_for_block_core_search( $attributes );
if ( ! empty( $typography_styles ) ) {
$label_styles [] = $typography_styles;
$button_styles[] = $typography_styles;
$input_styles [] = $typography_styles;
}
// Typography text-decoration is only applied to the label and button.
if ( ! empty( $attributes['style']['typography']['textDecoration'] ) ) {
$text_decoration_value = sprintf( 'text-decoration: %s;', esc_attr( $attributes['style']['typography']['textDecoration'] ) );
$button_styles[] = $text_decoration_value;
// Input opts out of text decoration.
if ( $show_label ) {
$label_styles[] = $text_decoration_value;
}
}
return array(
'input' => ! empty( $input_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $input_styles ) ) ) : '',
'button' => ! empty( $button_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $button_styles ) ) ) : '',
'wrapper' => ! empty( $wrapper_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $wrapper_styles ) ) ) : '',
'label' => ! empty( $label_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $label_styles ) ) ) ) : '',
);
}
/**
* Returns typography classnames depending on whether there are named font sizes/families .
*
* @param array $attributes The block attributes.
*
* @return string The typography color classnames to be applied to the block elements.
*/
function get_typography_classes_for_block_core_search( $attributes ) {
$typography_classes = array();
$has_named_font_family = ! empty( $attributes['fontFamily'] );
$has_named_font_size = ! empty( $attributes['fontSize'] );
if ( $has_named_font_size ) {
$typography_classes[] = sprintf( 'has-%s-font-size', esc_attr( $attributes['fontSize'] ) );
}
if ( $has_named_font_family ) {
$typography_classes[] = sprintf( 'has-%s-font-family', esc_attr( $attributes['fontFamily'] ) );
}
return implode( ' ', $typography_classes );
}
/**
* Returns typography styles to be included in an HTML style tag.
* This excludes text-decoration, which is applied only to the label and button elements of the search block.
*
* @param array $attributes The block attributes.
*
* @return string A string of typography CSS declarations.
*/
function get_typography_styles_for_block_core_search( $attributes ) {
$typography_styles = array();
// Add typography styles.
if ( ! empty( $attributes['style']['typography']['fontSize'] ) ) {
$typography_styles[] = sprintf( 'font-size: %s;', esc_attr( $attributes['style']['typography']['fontSize'] ) );
}
if ( ! empty( $attributes['style']['typography']['fontFamily'] ) ) {
$typography_styles[] = sprintf( 'font-family: %s;', esc_attr( $attributes['style']['typography']['fontFamily'] ) );
}
if ( ! empty( $attributes['style']['typography']['letterSpacing'] ) ) {
$typography_styles[] = sprintf( 'letter-spacing: %s;', esc_attr( $attributes['style']['typography']['letterSpacing'] ) );
}
if ( ! empty( $attributes['style']['typography']['fontWeight'] ) ) {
$typography_styles[] = sprintf( 'font-weight: %s;', esc_attr( $attributes['style']['typography']['fontWeight'] ) );
}
if ( ! empty( $attributes['style']['typography']['fontStyle'] ) ) {
$typography_styles[] = sprintf( 'font-style: %s;', esc_attr( $attributes['style']['typography']['fontStyle'] ) );
}
if ( ! empty( $attributes['style']['typography']['lineHeight'] ) ) {
$typography_styles[] = sprintf( 'line-height: %s;', esc_attr( $attributes['style']['typography']['lineHeight'] ) );
}
if ( ! empty( $attributes['style']['typography']['textTransform'] ) ) {
$typography_styles[] = sprintf( 'text-transform: %s;', esc_attr( $attributes['style']['typography']['textTransform'] ) );
}
return implode( '', $typography_styles );
}
/**
* Returns border color classnames depending on whether there are named or custom border colors.
*
@ -315,13 +480,19 @@ function styles_for_block_core_search( $attributes ) {
* @return string The border color classnames to be applied to the block elements.
*/
function get_border_color_classes_for_block_core_search( $attributes ) {
$border_color_classes = array();
$has_custom_border_color = ! empty( $attributes['style']['border']['color'] );
$border_color_classes = ! empty( $attributes['borderColor'] ) ? sprintf( 'has-border-color has-%s-border-color', $attributes['borderColor'] ) : '';
// If there's a border color style and no `borderColor` text string, we still want to add the generic `has-border-color` class name to the element.
if ( $has_custom_border_color && empty( $attributes['borderColor'] ) ) {
$border_color_classes = 'has-border-color';
$has_named_border_color = ! empty( $attributes['borderColor'] );
if ( $has_custom_border_color || $has_named_border_color ) {
$border_color_classes[] = 'has-border-color';
}
return $border_color_classes;
if ( $has_named_border_color ) {
$border_color_classes[] = sprintf( 'has-%s-border-color', esc_attr( $attributes['borderColor'] ) );
}
return implode( ' ', $border_color_classes );
}
/**

View File

@ -38,6 +38,10 @@
"buttonUseIcon": {
"type": "boolean",
"default": false
},
"query": {
"type": "object",
"default": {}
}
},
"supports": {
@ -50,6 +54,21 @@
"text": true
}
},
"typography": {
"__experimentalSkipSerialization": true,
"__experimentalSelector": ".wp-block-search__label, .wp-block-search__input, .wp-block-search__button",
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"__experimentalBorder": {
"color": true,
"radius": true,

View File

@ -17,6 +17,7 @@
"anchor": true,
"align": [ "center", "wide", "full" ],
"color": {
"enableContrastChecker": false,
"__experimentalSkipSerialization": true,
"gradients": true,
"background": true,
@ -24,6 +25,9 @@
"__experimentalDefaultControls": {
"background": true
}
},
"spacing": {
"margin": [ "top", "bottom" ]
}
},
"styles": [

View File

@ -37,6 +37,10 @@
"__experimentalDuotone": "img, .components-placeholder__illustration, .components-placeholder::before",
"text": false,
"background": false
},
"spacing": {
"margin": true,
"padding": true
}
},
"styles": [

View File

@ -1,98 +0,0 @@
/**
* Colors
*/
/**
* Breakpoints & Media Queries
*/
/**
* SCSS Variables.
*
* Please use variables from this sheet to ensure consistency across the UI.
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
*/
/**
* Colors
*/
/**
* Fonts & basic variables.
*/
/**
* Grid System.
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
*/
/**
* Dimensions.
*/
/**
* Shadows.
*/
/**
* Editor widths.
*/
/**
* Block & Editor UI.
*/
/**
* Block paddings.
*/
/**
* React Native specific.
* These variables do not appear to be used anywhere else.
*/
/**
* Converts a hex value into the rgb equivalent.
*
* @param {string} hex - the hexadecimal value to convert
* @return {string} comma separated rgb values
*/
/**
* Breakpoint mixins
*/
/**
* Long content fade mixin
*
* Creates a fading overlay to signify that the content is longer
* than the space allows.
*/
/**
* Focus styles.
*/
/**
* Applies editor left position to the selector passed as argument
*/
/**
* Styles that are reused verbatim in a few places
*/
/**
* Allows users to opt-out of animations via OS-level preferences.
*/
/**
* Reset default styles for JavaScript UI based pages.
* This is a WP-admin agnostic reset
*/
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
.wp-block-site-logo {
line-height: 0;
}
.wp-block-site-logo a {
display: inline-block;
}
.wp-block-site-logo.is-default-size img {
width: 120px;
height: auto;
}
.wp-block-site-logo a,
.wp-block-site-logo img {
border-radius: inherit;
}
.wp-block-site-logo.aligncenter {
margin-right: auto;
margin-left: auto;
text-align: center;
}
.wp-block-site-logo.is-style-rounded {
border-radius: 9999px;
}

View File

@ -1 +0,0 @@
.wp-block-site-logo{line-height:0}.wp-block-site-logo a{display:inline-block}.wp-block-site-logo.is-default-size img{width:120px;height:auto}.wp-block-site-logo a,.wp-block-site-logo img{border-radius:inherit}.wp-block-site-logo.aligncenter{margin-right:auto;margin-left:auto;text-align:center}.wp-block-site-logo.is-style-rounded{border-radius:9999px}

Some files were not shown because too many files have changed in this diff Show More